tabulator-tables 5.3.0 → 5.3.1

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.0",
3
+ "version": "5.3.1",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -309,6 +309,8 @@ export default class ColumnManager extends CoreFeature {
309
309
 
310
310
  //////////////// Column Details /////////////////
311
311
  findColumn(subject){
312
+ var columns;
313
+
312
314
  if(typeof subject == "object"){
313
315
 
314
316
  if(subject instanceof Column){
@@ -318,8 +320,16 @@ export default class ColumnManager extends CoreFeature {
318
320
  //subject is public column component
319
321
  return subject._getSelf() || false;
320
322
  }else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){
323
+
324
+ columns = [];
325
+
326
+ this.columns.forEach((column) => {
327
+ columns.push(column);
328
+ columns = columns.concat(column.getColumns(true));
329
+ });
330
+
321
331
  //subject is a HTML element of the column header
322
- let match = this.columns.find((column) => {
332
+ let match = columns.find((column) => {
323
333
  return column.element === subject;
324
334
  });
325
335
 
@@ -859,6 +859,8 @@ export default class RowManager extends CoreFeature{
859
859
  }
860
860
 
861
861
  if(renderClass){
862
+ this.renderMode = this.table.options.renderVertical;
863
+
862
864
  this.renderer = new renderClass(this.table, this.element, this.tableElement);
863
865
  this.renderer.initialize();
864
866
 
@@ -481,8 +481,20 @@ class Column extends CoreFeature{
481
481
  }
482
482
 
483
483
  //return all columns in a group
484
- getColumns(){
485
- return this.columns;
484
+ getColumns(traverse){
485
+ var columns = [];
486
+
487
+ if(traverse){
488
+ this.columns.forEach((column) => {
489
+ columns.push(column);
490
+
491
+ columns = columns.concat(column.getColumns(true));
492
+ });
493
+ }else{
494
+ columns = this.columns;
495
+ }
496
+
497
+ return columns;
486
498
  }
487
499
 
488
500
  //return all columns in a group
@@ -710,6 +722,12 @@ class Column extends CoreFeature{
710
722
  }
711
723
 
712
724
  setMinWidth(minWidth){
725
+ if(this.maxWidth && minWidth > this.maxWidth){
726
+ minWidth = this.maxWidth;
727
+
728
+ console.warn("the minWidth ("+ minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth ("+ this.maxWidthStyled + ")");
729
+ }
730
+
713
731
  this.minWidth = minWidth;
714
732
  this.minWidthStyled = minWidth ? minWidth + "px" : "";
715
733
 
@@ -721,6 +739,12 @@ class Column extends CoreFeature{
721
739
  }
722
740
 
723
741
  setMaxWidth(maxWidth){
742
+ if(this.minWidth && maxWidth < this.minWidth){
743
+ maxWidth = this.minWidth;
744
+
745
+ console.warn("the maxWidth ("+ maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth ("+ this.minWidthStyled + ")");
746
+ }
747
+
724
748
  this.maxWidth = maxWidth;
725
749
  this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";
726
750
 
@@ -219,7 +219,9 @@ export default class InteractionManager extends CoreFeature {
219
219
  });
220
220
 
221
221
  for (let target of elTargets) {
222
- targets[this.componentMap[target]] = el;
222
+ if(!targets[this.componentMap[target]]){
223
+ targets[this.componentMap[target]] = el;
224
+ }
223
225
  }
224
226
  }
225
227
 
@@ -93,7 +93,7 @@ class ColumnCalcs extends Module{
93
93
 
94
94
  rowsUpdated(row){
95
95
  if(this.table.options.groupBy){
96
- this.recalcRowGroup(this);
96
+ this.recalcRowGroup(row);
97
97
  }else{
98
98
  this.recalcActiveRows();
99
99
  }
@@ -51,6 +51,10 @@ class DataTree extends Module{
51
51
  this.field = options.dataTreeChildField;
52
52
  this.indent = options.dataTreeChildIndent;
53
53
 
54
+ if(this.options("movableRows")){
55
+ console.warn("The movableRows option is not available with dataTree enabled, moving of child rows could result in unpredictable behavior");
56
+ }
57
+
54
58
  if(options.dataTreeBranchElement){
55
59
 
56
60
  if(options.dataTreeBranchElement === true){
@@ -436,7 +440,7 @@ class DataTree extends Module{
436
440
  }
437
441
 
438
442
  getTreeParentRoot(row){
439
- return row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
443
+ return row.modules.dataTree && row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
440
444
  }
441
445
 
442
446
  getFilteredTreeChildren(row){
@@ -896,7 +896,7 @@ export default class Edit{
896
896
  if(!startVis){
897
897
  setTimeout(() => {
898
898
  this.popup.hideOnBlur(this._resolveValue.bind(this, true));
899
- });
899
+ }, 10);
900
900
  }
901
901
  }
902
902
  }
@@ -373,6 +373,9 @@ class Filter extends Module{
373
373
  getColumn:function(){
374
374
  return column.getComponent();
375
375
  },
376
+ getTable:() => {
377
+ return this.table;
378
+ },
376
379
  getRow:function(){
377
380
  return {
378
381
  normalizeHeight:function(){
@@ -358,7 +358,7 @@ class Group{
358
358
  hide(){
359
359
  this.visible = false;
360
360
 
361
- if(this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination){
361
+ if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){
362
362
 
363
363
  this.element.classList.remove("tabulator-group-visible");
364
364
 
@@ -381,7 +381,7 @@ class Group{
381
381
 
382
382
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
383
383
 
384
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
384
+ this.groupManager.checkBasicModeGroupHeaderWidth();
385
385
 
386
386
  }else{
387
387
  this.groupManager.updateGroupRows(true);
@@ -393,7 +393,7 @@ class Group{
393
393
  show(){
394
394
  this.visible = true;
395
395
 
396
- if(this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination){
396
+ if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){
397
397
 
398
398
  this.element.classList.add("tabulator-group-visible");
399
399
 
@@ -422,7 +422,7 @@ class Group{
422
422
 
423
423
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
424
424
 
425
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
425
+ this.groupManager.checkBasicModeGroupHeaderWidth();
426
426
  }else{
427
427
  this.groupManager.updateGroupRows(true);
428
428
  }
@@ -583,6 +583,28 @@ class GroupRows extends Module{
583
583
  }
584
584
  }
585
585
  }
586
+
587
+ checkBasicModeGroupHeaderWidth(){
588
+ var element = this.table.rowManager.tableElement,
589
+ onlyGroupHeaders = true;
590
+
591
+ this.table.rowManager.getDisplayRows().forEach((row, index) =>{
592
+ this.table.rowManager.styleRow(row, index);
593
+ element.appendChild(row.getElement());
594
+ row.initialize(true);
595
+
596
+ if(row.type !== "group"){
597
+ onlyGroupHeaders = false;
598
+ }
599
+ });
600
+
601
+ if(onlyGroupHeaders){
602
+ element.style.minWidth = this.table.columnManager.getWidth() + "px";
603
+ }else{
604
+ element.style.minWidth = "";
605
+ }
606
+ }
607
+
586
608
  }
587
609
 
588
610
  GroupRows.moduleName = "groupRows";
@@ -46,7 +46,7 @@ class History extends Module{
46
46
 
47
47
  if(this.table.options.groupBy){
48
48
 
49
- rows = row.getComponent().getGroup().rows;
49
+ rows = row.getComponent().getGroup()._getSelf().rows;
50
50
  index = rows.indexOf(row);
51
51
 
52
52
  if(index){
@@ -138,11 +138,11 @@ class Interaction extends Module{
138
138
  try{
139
139
  if (document.selection) { // IE
140
140
  range = document.body.createTextRange();
141
- range.moveToElementText(this.element);
141
+ range.moveToElementText(cell.getElement());
142
142
  range.select();
143
143
  } else if (window.getSelection) {
144
144
  range = document.createRange();
145
- range.selectNode(this.element);
145
+ range.selectNode(cell.getElement());
146
146
  window.getSelection().removeAllRanges();
147
147
  window.getSelection().addRange(range);
148
148
  }
@@ -1,6 +1,6 @@
1
1
  //resize columns to fit
2
2
  export default function(columns, forced){
3
- var totalWidth = this.table.element.clientWidth; //table element width
3
+ var totalWidth = this.table.rowManager.element.getBoundingClientRect().width; //table element width
4
4
  var fixedWidth = 0; //total width of columns with a defined width
5
5
  var flexWidth = 0; //total width available to flexible columns
6
6
  var flexGrowUnits = 0; //total number of widthGrow blocks across all columns
@@ -77,9 +77,7 @@ export default function(columns, forced){
77
77
 
78
78
  nextColWidth = changeUnits ? Math.floor(remainingSpace/changeUnits) : remainingSpace;
79
79
 
80
- gap = remainingSpace - (nextColWidth * changeUnits);
81
-
82
- gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
80
+ gap = scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
83
81
  }else{
84
82
  gap = changeUnits ? freeSpace - (Math.floor(freeSpace/changeUnits) * changeUnits) : freeSpace;
85
83
 
@@ -143,7 +141,7 @@ export default function(columns, forced){
143
141
 
144
142
  //increase width of last column to account for rounding errors
145
143
  if(flexColumns.length && gapFill > 0){
146
- flexColumns[flexColumns.length-1].width += + gapFill;
144
+ flexColumns[flexColumns.length-1].width += gapFill;
147
145
  }
148
146
 
149
147
  //calculate space for columns to be shrunk into
@@ -159,7 +157,7 @@ export default function(columns, forced){
159
157
  }
160
158
 
161
159
  //decrease width of last column to account for rounding errors
162
- if(fixedShrinkColumns.length){
160
+ if(gapFill && fixedShrinkColumns.length){
163
161
  fixedShrinkColumns[fixedShrinkColumns.length-1].width -= gapFill;
164
162
  }
165
163
 
@@ -33,8 +33,9 @@ class ResponsiveLayout extends Module{
33
33
  this.subscribe("column-delete", this.initializeResponsivity.bind(this));
34
34
 
35
35
  this.subscribe("table-redrawing", this.tableRedraw.bind(this));
36
-
36
+
37
37
  if(this.table.options.responsiveLayout === "collapse"){
38
+ this.subscribe("row-data-changed", this.generateCollapsedRowContent.bind(this));
38
39
  this.subscribe("row-init", this.initializeRow.bind(this));
39
40
  this.subscribe("row-layout", this.layoutRow.bind(this));
40
41
  }
@@ -341,4 +342,4 @@ class ResponsiveLayout extends Module{
341
342
 
342
343
  ResponsiveLayout.moduleName = "responsiveLayout";
343
344
 
344
- export default ResponsiveLayout;
345
+ export default ResponsiveLayout;