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.
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.3.0 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.3.1 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -2433,8 +2433,20 @@ class Column extends CoreFeature{
2433
2433
  }
2434
2434
 
2435
2435
  //return all columns in a group
2436
- getColumns(){
2437
- return this.columns;
2436
+ getColumns(traverse){
2437
+ var columns = [];
2438
+
2439
+ if(traverse){
2440
+ this.columns.forEach((column) => {
2441
+ columns.push(column);
2442
+
2443
+ columns = columns.concat(column.getColumns(true));
2444
+ });
2445
+ }else {
2446
+ columns = this.columns;
2447
+ }
2448
+
2449
+ return columns;
2438
2450
  }
2439
2451
 
2440
2452
  //return all columns in a group
@@ -2662,6 +2674,12 @@ class Column extends CoreFeature{
2662
2674
  }
2663
2675
 
2664
2676
  setMinWidth(minWidth){
2677
+ if(this.maxWidth && minWidth > this.maxWidth){
2678
+ minWidth = this.maxWidth;
2679
+
2680
+ console.warn("the minWidth ("+ minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth ("+ this.maxWidthStyled + ")");
2681
+ }
2682
+
2665
2683
  this.minWidth = minWidth;
2666
2684
  this.minWidthStyled = minWidth ? minWidth + "px" : "";
2667
2685
 
@@ -2673,6 +2691,12 @@ class Column extends CoreFeature{
2673
2691
  }
2674
2692
 
2675
2693
  setMaxWidth(maxWidth){
2694
+ if(this.minWidth && maxWidth < this.minWidth){
2695
+ maxWidth = this.minWidth;
2696
+
2697
+ console.warn("the maxWidth ("+ maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth ("+ this.minWidthStyled + ")");
2698
+ }
2699
+
2676
2700
  this.maxWidth = maxWidth;
2677
2701
  this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";
2678
2702
 
@@ -3581,7 +3605,7 @@ class ColumnCalcs extends Module{
3581
3605
 
3582
3606
  rowsUpdated(row){
3583
3607
  if(this.table.options.groupBy){
3584
- this.recalcRowGroup(this);
3608
+ this.recalcRowGroup(row);
3585
3609
  }else {
3586
3610
  this.recalcActiveRows();
3587
3611
  }
@@ -4052,6 +4076,10 @@ class DataTree extends Module{
4052
4076
  this.field = options.dataTreeChildField;
4053
4077
  this.indent = options.dataTreeChildIndent;
4054
4078
 
4079
+ if(this.options("movableRows")){
4080
+ console.warn("The movableRows option is not available with dataTree enabled, moving of child rows could result in unpredictable behavior");
4081
+ }
4082
+
4055
4083
  if(options.dataTreeBranchElement){
4056
4084
 
4057
4085
  if(options.dataTreeBranchElement === true){
@@ -4437,7 +4465,7 @@ class DataTree extends Module{
4437
4465
  }
4438
4466
 
4439
4467
  getTreeParentRoot(row){
4440
- return row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
4468
+ return row.modules.dataTree && row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
4441
4469
  }
4442
4470
 
4443
4471
  getFilteredTreeChildren(row){
@@ -6765,7 +6793,7 @@ class Edit{
6765
6793
  if(!startVis){
6766
6794
  setTimeout(() => {
6767
6795
  this.popup.hideOnBlur(this._resolveValue.bind(this, true));
6768
- });
6796
+ }, 10);
6769
6797
  }
6770
6798
  }
6771
6799
  }
@@ -9139,6 +9167,9 @@ class Filter extends Module{
9139
9167
  getColumn:function(){
9140
9168
  return column.getComponent();
9141
9169
  },
9170
+ getTable:() => {
9171
+ return this.table;
9172
+ },
9142
9173
  getRow:function(){
9143
9174
  return {
9144
9175
  normalizeHeight:function(){
@@ -11413,7 +11444,7 @@ class Group{
11413
11444
  hide(){
11414
11445
  this.visible = false;
11415
11446
 
11416
- if(this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination){
11447
+ if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){
11417
11448
 
11418
11449
  this.element.classList.remove("tabulator-group-visible");
11419
11450
 
@@ -11436,7 +11467,7 @@ class Group{
11436
11467
 
11437
11468
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
11438
11469
 
11439
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
11470
+ this.groupManager.checkBasicModeGroupHeaderWidth();
11440
11471
 
11441
11472
  }else {
11442
11473
  this.groupManager.updateGroupRows(true);
@@ -11448,7 +11479,7 @@ class Group{
11448
11479
  show(){
11449
11480
  this.visible = true;
11450
11481
 
11451
- if(this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination){
11482
+ if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){
11452
11483
 
11453
11484
  this.element.classList.add("tabulator-group-visible");
11454
11485
 
@@ -11477,7 +11508,7 @@ class Group{
11477
11508
 
11478
11509
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
11479
11510
 
11480
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
11511
+ this.groupManager.checkBasicModeGroupHeaderWidth();
11481
11512
  }else {
11482
11513
  this.groupManager.updateGroupRows(true);
11483
11514
  }
@@ -12238,6 +12269,28 @@ class GroupRows extends Module{
12238
12269
  }
12239
12270
  }
12240
12271
  }
12272
+
12273
+ checkBasicModeGroupHeaderWidth(){
12274
+ var element = this.table.rowManager.tableElement,
12275
+ onlyGroupHeaders = true;
12276
+
12277
+ this.table.rowManager.getDisplayRows().forEach((row, index) =>{
12278
+ this.table.rowManager.styleRow(row, index);
12279
+ element.appendChild(row.getElement());
12280
+ row.initialize(true);
12281
+
12282
+ if(row.type !== "group"){
12283
+ onlyGroupHeaders = false;
12284
+ }
12285
+ });
12286
+
12287
+ if(onlyGroupHeaders){
12288
+ element.style.minWidth = this.table.columnManager.getWidth() + "px";
12289
+ }else {
12290
+ element.style.minWidth = "";
12291
+ }
12292
+ }
12293
+
12241
12294
  }
12242
12295
 
12243
12296
  GroupRows.moduleName = "groupRows";
@@ -12335,7 +12388,7 @@ class History extends Module{
12335
12388
 
12336
12389
  if(this.table.options.groupBy){
12337
12390
 
12338
- rows = row.getComponent().getGroup().rows;
12391
+ rows = row.getComponent().getGroup()._getSelf().rows;
12339
12392
  index = rows.indexOf(row);
12340
12393
 
12341
12394
  if(index){
@@ -13042,11 +13095,11 @@ class Interaction extends Module{
13042
13095
  try{
13043
13096
  if (document.selection) { // IE
13044
13097
  range = document.body.createTextRange();
13045
- range.moveToElementText(this.element);
13098
+ range.moveToElementText(cell.getElement());
13046
13099
  range.select();
13047
13100
  } else if (window.getSelection) {
13048
13101
  range = document.createRange();
13049
- range.selectNode(this.element);
13102
+ range.selectNode(cell.getElement());
13050
13103
  window.getSelection().removeAllRanges();
13051
13104
  window.getSelection().addRange(range);
13052
13105
  }
@@ -17636,8 +17689,9 @@ class ResponsiveLayout extends Module{
17636
17689
  this.subscribe("column-delete", this.initializeResponsivity.bind(this));
17637
17690
 
17638
17691
  this.subscribe("table-redrawing", this.tableRedraw.bind(this));
17639
-
17692
+
17640
17693
  if(this.table.options.responsiveLayout === "collapse"){
17694
+ this.subscribe("row-data-changed", this.generateCollapsedRowContent.bind(this));
17641
17695
  this.subscribe("row-init", this.initializeRow.bind(this));
17642
17696
  this.subscribe("row-layout", this.layoutRow.bind(this));
17643
17697
  }
@@ -20886,6 +20940,8 @@ class ColumnManager extends CoreFeature {
20886
20940
 
20887
20941
  //////////////// Column Details /////////////////
20888
20942
  findColumn(subject){
20943
+ var columns;
20944
+
20889
20945
  if(typeof subject == "object"){
20890
20946
 
20891
20947
  if(subject instanceof Column){
@@ -20895,8 +20951,16 @@ class ColumnManager extends CoreFeature {
20895
20951
  //subject is public column component
20896
20952
  return subject._getSelf() || false;
20897
20953
  }else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){
20954
+
20955
+ columns = [];
20956
+
20957
+ this.columns.forEach((column) => {
20958
+ columns.push(column);
20959
+ columns = columns.concat(column.getColumns(true));
20960
+ });
20961
+
20898
20962
  //subject is a HTML element of the column header
20899
- let match = this.columns.find((column) => {
20963
+ let match = columns.find((column) => {
20900
20964
  return column.element === subject;
20901
20965
  });
20902
20966
 
@@ -22788,6 +22852,8 @@ class RowManager extends CoreFeature{
22788
22852
  }
22789
22853
 
22790
22854
  if(renderClass){
22855
+ this.renderMode = this.table.options.renderVertical;
22856
+
22791
22857
  this.renderer = new renderClass(this.table, this.element, this.tableElement);
22792
22858
  this.renderer.initialize();
22793
22859
 
@@ -23314,7 +23380,9 @@ class InteractionManager extends CoreFeature {
23314
23380
  });
23315
23381
 
23316
23382
  for (let target of elTargets) {
23317
- targets[this.componentMap[target]] = el;
23383
+ if(!targets[this.componentMap[target]]){
23384
+ targets[this.componentMap[target]] = el;
23385
+ }
23318
23386
  }
23319
23387
  }
23320
23388
 
@@ -24002,7 +24070,7 @@ function fitDataStretch(columns, forced){
24002
24070
 
24003
24071
  //resize columns to fit
24004
24072
  function fitColumns(columns, forced){
24005
- var totalWidth = this.table.element.clientWidth; //table element width
24073
+ var totalWidth = this.table.rowManager.element.getBoundingClientRect().width; //table element width
24006
24074
  var fixedWidth = 0; //total width of columns with a defined width
24007
24075
  var flexWidth = 0; //total width available to flexible columns
24008
24076
  var flexGrowUnits = 0; //total number of widthGrow blocks across all columns
@@ -24079,9 +24147,7 @@ function fitColumns(columns, forced){
24079
24147
 
24080
24148
  nextColWidth = changeUnits ? Math.floor(remainingSpace/changeUnits) : remainingSpace;
24081
24149
 
24082
- gap = remainingSpace - (nextColWidth * changeUnits);
24083
-
24084
- gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
24150
+ gap = scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
24085
24151
  }else {
24086
24152
  gap = changeUnits ? freeSpace - (Math.floor(freeSpace/changeUnits) * changeUnits) : freeSpace;
24087
24153
 
@@ -24145,7 +24211,7 @@ function fitColumns(columns, forced){
24145
24211
 
24146
24212
  //increase width of last column to account for rounding errors
24147
24213
  if(flexColumns.length && gapFill > 0){
24148
- flexColumns[flexColumns.length-1].width += + gapFill;
24214
+ flexColumns[flexColumns.length-1].width += gapFill;
24149
24215
  }
24150
24216
 
24151
24217
  //calculate space for columns to be shrunk into
@@ -24161,7 +24227,7 @@ function fitColumns(columns, forced){
24161
24227
  }
24162
24228
 
24163
24229
  //decrease width of last column to account for rounding errors
24164
- if(fixedShrinkColumns.length){
24230
+ if(gapFill && fixedShrinkColumns.length){
24165
24231
  fixedShrinkColumns[fixedShrinkColumns.length-1].width -= gapFill;
24166
24232
  }
24167
24233