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/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tabulator",
3
3
  "main": "dist/js/tabulator.js",
4
- "version": "5.3.0",
4
+ "version": "5.3.1",
5
5
  "description": "Interactive table generation JavaScript library",
6
6
  "keywords": [
7
7
  "table",
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.3.0 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.3.1 (c) Oliver Folkerd 2022 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -1624,8 +1624,19 @@
1624
1624
 
1625
1625
  }, {
1626
1626
  key: "getColumns",
1627
- value: function getColumns() {
1628
- return this.columns;
1627
+ value: function getColumns(traverse) {
1628
+ var columns = [];
1629
+
1630
+ if (traverse) {
1631
+ this.columns.forEach(function (column) {
1632
+ columns.push(column);
1633
+ columns = columns.concat(column.getColumns(true));
1634
+ });
1635
+ } else {
1636
+ columns = this.columns;
1637
+ }
1638
+
1639
+ return columns;
1629
1640
  } //return all columns in a group
1630
1641
 
1631
1642
  }, {
@@ -1855,6 +1866,11 @@
1855
1866
  }, {
1856
1867
  key: "setMinWidth",
1857
1868
  value: function setMinWidth(minWidth) {
1869
+ if (this.maxWidth && minWidth > this.maxWidth) {
1870
+ minWidth = this.maxWidth;
1871
+ console.warn("the minWidth (" + minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth (" + this.maxWidthStyled + ")");
1872
+ }
1873
+
1858
1874
  this.minWidth = minWidth;
1859
1875
  this.minWidthStyled = minWidth ? minWidth + "px" : "";
1860
1876
  this.element.style.minWidth = this.minWidthStyled;
@@ -1865,6 +1881,11 @@
1865
1881
  }, {
1866
1882
  key: "setMaxWidth",
1867
1883
  value: function setMaxWidth(maxWidth) {
1884
+ if (this.minWidth && maxWidth < this.minWidth) {
1885
+ maxWidth = this.minWidth;
1886
+ console.warn("the maxWidth (" + maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth (" + this.minWidthStyled + ")");
1887
+ }
1888
+
1868
1889
  this.maxWidth = maxWidth;
1869
1890
  this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";
1870
1891
  this.element.style.maxWidth = this.maxWidthStyled;
@@ -3324,6 +3345,8 @@
3324
3345
  }, {
3325
3346
  key: "findColumn",
3326
3347
  value: function findColumn(subject) {
3348
+ var columns;
3349
+
3327
3350
  if (_typeof(subject) == "object") {
3328
3351
  if (subject instanceof Column) {
3329
3352
  //subject is column element
@@ -3332,8 +3355,13 @@
3332
3355
  //subject is public column component
3333
3356
  return subject._getSelf() || false;
3334
3357
  } else if (typeof HTMLElement !== "undefined" && subject instanceof HTMLElement) {
3335
- //subject is a HTML element of the column header
3336
- var match = this.columns.find(function (column) {
3358
+ columns = [];
3359
+ this.columns.forEach(function (column) {
3360
+ columns.push(column);
3361
+ columns = columns.concat(column.getColumns(true));
3362
+ }); //subject is a HTML element of the column header
3363
+
3364
+ var match = columns.find(function (column) {
3337
3365
  return column.element === subject;
3338
3366
  });
3339
3367
  return match || false;
@@ -5920,6 +5948,7 @@
5920
5948
  }
5921
5949
 
5922
5950
  if (renderClass) {
5951
+ this.renderMode = this.table.options.renderVertical;
5923
5952
  this.renderer = new renderClass(this.table, this.element, this.tableElement);
5924
5953
  this.renderer.initialize();
5925
5954
 
@@ -6487,7 +6516,10 @@
6487
6516
  try {
6488
6517
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
6489
6518
  var target = _step3.value;
6490
- targets[this.componentMap[target]] = el;
6519
+
6520
+ if (!targets[this.componentMap[target]]) {
6521
+ targets[this.componentMap[target]] = el;
6522
+ }
6491
6523
  }
6492
6524
  } catch (err) {
6493
6525
  _iterator3.e(err);
@@ -7737,7 +7769,7 @@
7737
7769
 
7738
7770
  //resize columns to fit
7739
7771
  function fitColumns (columns, forced) {
7740
- var totalWidth = this.table.element.clientWidth; //table element width
7772
+ var totalWidth = this.table.rowManager.element.getBoundingClientRect().width; //table element width
7741
7773
 
7742
7774
  var fixedWidth = 0; //total width of columns with a defined width
7743
7775
 
@@ -7820,8 +7852,7 @@
7820
7852
  });
7821
7853
  remainingSpace = freeSpace - oversizeSpace;
7822
7854
  nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace;
7823
- gap = remainingSpace - nextColWidth * changeUnits;
7824
- gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
7855
+ gap = scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);
7825
7856
  } else {
7826
7857
  gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace;
7827
7858
  undersizeCols.forEach(function (column) {
@@ -7876,7 +7907,7 @@
7876
7907
  gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false); //increase width of last column to account for rounding errors
7877
7908
 
7878
7909
  if (flexColumns.length && gapFill > 0) {
7879
- flexColumns[flexColumns.length - 1].width += +gapFill;
7910
+ flexColumns[flexColumns.length - 1].width += gapFill;
7880
7911
  } //calculate space for columns to be shrunk into
7881
7912
 
7882
7913
 
@@ -7890,7 +7921,7 @@
7890
7921
  } //decrease width of last column to account for rounding errors
7891
7922
 
7892
7923
 
7893
- if (fixedShrinkColumns.length) {
7924
+ if (gapFill && fixedShrinkColumns.length) {
7894
7925
  fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill;
7895
7926
  }
7896
7927
 
@@ -10490,7 +10521,7 @@
10490
10521
  key: "rowsUpdated",
10491
10522
  value: function rowsUpdated(row) {
10492
10523
  if (this.table.options.groupBy) {
10493
- this.recalcRowGroup(this);
10524
+ this.recalcRowGroup(row);
10494
10525
  } else {
10495
10526
  this.recalcActiveRows();
10496
10527
  }
@@ -11023,6 +11054,10 @@
11023
11054
  this.field = options.dataTreeChildField;
11024
11055
  this.indent = options.dataTreeChildIndent;
11025
11056
 
11057
+ if (this.options("movableRows")) {
11058
+ console.warn("The movableRows option is not available with dataTree enabled, moving of child rows could result in unpredictable behavior");
11059
+ }
11060
+
11026
11061
  if (options.dataTreeBranchElement) {
11027
11062
  if (options.dataTreeBranchElement === true) {
11028
11063
  this.branchEl = document.createElement("div");
@@ -11419,7 +11454,7 @@
11419
11454
  }, {
11420
11455
  key: "getTreeParentRoot",
11421
11456
  value: function getTreeParentRoot(row) {
11422
- return row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
11457
+ return row.modules.dataTree && row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;
11423
11458
  }
11424
11459
  }, {
11425
11460
  key: "getFilteredTreeChildren",
@@ -13834,7 +13869,7 @@
13834
13869
  if (!startVis) {
13835
13870
  setTimeout(function () {
13836
13871
  _this13.popup.hideOnBlur(_this13._resolveValue.bind(_this13, true));
13837
- });
13872
+ }, 10);
13838
13873
  }
13839
13874
  }
13840
13875
  }
@@ -16267,6 +16302,9 @@
16267
16302
  getColumn: function getColumn() {
16268
16303
  return column.getComponent();
16269
16304
  },
16305
+ getTable: function getTable() {
16306
+ return _this3.table;
16307
+ },
16270
16308
  getRow: function getRow() {
16271
16309
  return {
16272
16310
  normalizeHeight: function normalizeHeight() {}
@@ -18637,7 +18675,7 @@
18637
18675
  value: function hide() {
18638
18676
  this.visible = false;
18639
18677
 
18640
- if (this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination) {
18678
+ if (this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination) {
18641
18679
  this.element.classList.remove("tabulator-group-visible");
18642
18680
 
18643
18681
  if (this.groupList.length) {
@@ -18655,7 +18693,7 @@
18655
18693
  }
18656
18694
 
18657
18695
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
18658
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
18696
+ this.groupManager.checkBasicModeGroupHeaderWidth();
18659
18697
  } else {
18660
18698
  this.groupManager.updateGroupRows(true);
18661
18699
  }
@@ -18667,7 +18705,7 @@
18667
18705
  value: function show() {
18668
18706
  this.visible = true;
18669
18707
 
18670
- if (this.groupManager.table.rowManager.getRenderMode() == "classic" && !this.groupManager.table.options.pagination) {
18708
+ if (this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination) {
18671
18709
  this.element.classList.add("tabulator-group-visible");
18672
18710
  var prev = this.generateElement();
18673
18711
 
@@ -18691,7 +18729,7 @@
18691
18729
  }
18692
18730
 
18693
18731
  this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
18694
- this.groupManager.table.rowManager.checkClassicModeGroupHeaderWidth();
18732
+ this.groupManager.checkBasicModeGroupHeaderWidth();
18695
18733
  } else {
18696
18734
  this.groupManager.updateGroupRows(true);
18697
18735
  }
@@ -19497,6 +19535,30 @@
19497
19535
  }
19498
19536
  }
19499
19537
  }
19538
+ }, {
19539
+ key: "checkBasicModeGroupHeaderWidth",
19540
+ value: function checkBasicModeGroupHeaderWidth() {
19541
+ var _this6 = this;
19542
+
19543
+ var element = this.table.rowManager.tableElement,
19544
+ onlyGroupHeaders = true;
19545
+ this.table.rowManager.getDisplayRows().forEach(function (row, index) {
19546
+ _this6.table.rowManager.styleRow(row, index);
19547
+
19548
+ element.appendChild(row.getElement());
19549
+ row.initialize(true);
19550
+
19551
+ if (row.type !== "group") {
19552
+ onlyGroupHeaders = false;
19553
+ }
19554
+ });
19555
+
19556
+ if (onlyGroupHeaders) {
19557
+ element.style.minWidth = this.table.columnManager.getWidth() + "px";
19558
+ } else {
19559
+ element.style.minWidth = "";
19560
+ }
19561
+ }
19500
19562
  }]);
19501
19563
 
19502
19564
  return GroupRows;
@@ -19613,7 +19675,7 @@
19613
19675
  var index, rows;
19614
19676
 
19615
19677
  if (this.table.options.groupBy) {
19616
- rows = row.getComponent().getGroup().rows;
19678
+ rows = row.getComponent().getGroup()._getSelf().rows;
19617
19679
  index = rows.indexOf(row);
19618
19680
 
19619
19681
  if (index) {
@@ -20372,11 +20434,11 @@
20372
20434
  if (document.selection) {
20373
20435
  // IE
20374
20436
  range = document.body.createTextRange();
20375
- range.moveToElementText(this.element);
20437
+ range.moveToElementText(cell.getElement());
20376
20438
  range.select();
20377
20439
  } else if (window.getSelection) {
20378
20440
  range = document.createRange();
20379
- range.selectNode(this.element);
20441
+ range.selectNode(cell.getElement());
20380
20442
  window.getSelection().removeAllRanges();
20381
20443
  window.getSelection().addRange(range);
20382
20444
  }
@@ -25207,6 +25269,7 @@
25207
25269
  this.subscribe("table-redrawing", this.tableRedraw.bind(this));
25208
25270
 
25209
25271
  if (this.table.options.responsiveLayout === "collapse") {
25272
+ this.subscribe("row-data-changed", this.generateCollapsedRowContent.bind(this));
25210
25273
  this.subscribe("row-init", this.initializeRow.bind(this));
25211
25274
  this.subscribe("row-layout", this.layoutRow.bind(this));
25212
25275
  }