tabulator-tables 5.1.3 → 5.1.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.
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.1.3 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.1.4 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -2847,6 +2847,8 @@ class Row extends CoreFeature{
2847
2847
 
2848
2848
  this.generateCells();
2849
2849
 
2850
+ this.initialized = true;
2851
+
2850
2852
  this.table.columnManager.renderer.renderRowCells(this);
2851
2853
 
2852
2854
  if(force){
@@ -2855,8 +2857,6 @@ class Row extends CoreFeature{
2855
2857
 
2856
2858
  this.dispatch("row-layout", this);
2857
2859
 
2858
- this.initialized = true;
2859
-
2860
2860
  if(this.table.options.rowFormatter){
2861
2861
  this.table.options.rowFormatter(this.getComponent());
2862
2862
  }
@@ -7906,10 +7906,10 @@ class Export extends Module{
7906
7906
  rowEl.classList.add("tabulator-print-table-row");
7907
7907
 
7908
7908
  row.columns.forEach((col) => {
7909
-
7910
7909
  if(col){
7911
7910
  var cellEl = document.createElement("td"),
7912
7911
  column = col.component._column,
7912
+ index = this.table.columnManager.findColumnIndex(column),
7913
7913
  value = col.value;
7914
7914
 
7915
7915
  var cellWrapper = {
@@ -7968,8 +7968,8 @@ class Export extends Module{
7968
7968
  cellEl.innerHTML = value;
7969
7969
  }
7970
7970
 
7971
- if(styles.firstCell){
7972
- this.mapElementStyles(styles.firstCell, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom", "border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size"]);
7971
+ if(styles.styleCells[index] || styles.firstCell){
7972
+ this.mapElementStyles(styles.styleCells[index] || styles.firstCell, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom", "border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "text-align"]);
7973
7973
 
7974
7974
  if(column.definition.align){
7975
7975
  cellEl.style.textAlign = column.definition.align;
@@ -8572,7 +8572,9 @@ class Filter extends Module{
8572
8572
  editorElement.addEventListener("focus", (e) => {
8573
8573
  var left = this.table.columnManager.element.scrollLeft;
8574
8574
 
8575
- if(left !== this.table.rowManager.element.scrollLeft){
8575
+ var headerPos = this.table.rowManager.element.scrollLeft + parseInt(this.table.columnManager.element.style.marginLeft);
8576
+
8577
+ if(left !== headerPos){
8576
8578
  this.table.rowManager.scrollHorizontal(left);
8577
8579
  this.table.columnManager.scrollHorizontal(left);
8578
8580
  }
@@ -9582,8 +9584,9 @@ function rowSelection(cell, formatterParams, onRendered){
9582
9584
  var blocked = false;
9583
9585
 
9584
9586
  checkbox.type = 'checkbox';
9585
-
9586
9587
 
9588
+ checkbox.setAttribute("aria-label", "Select Row");
9589
+
9587
9590
  if(this.table.modExists("selectRow", true)){
9588
9591
 
9589
9592
  checkbox.addEventListener("click", (e) => {
@@ -9863,10 +9866,10 @@ Format.moduleName = "format";
9863
9866
  Format.formatters = defaultFormatters;
9864
9867
 
9865
9868
  class FrozenColumns extends Module{
9866
-
9869
+
9867
9870
  constructor(table){
9868
9871
  super(table);
9869
-
9872
+
9870
9873
  this.leftColumns = [];
9871
9874
  this.rightColumns = [];
9872
9875
  this.leftMargin = 0;
@@ -9876,10 +9879,10 @@ class FrozenColumns extends Module{
9876
9879
  this.active = false;
9877
9880
  this.scrollEndTimer = false;
9878
9881
  this.blocked = true;
9879
-
9882
+
9880
9883
  this.registerColumnOption("frozen");
9881
9884
  }
9882
-
9885
+
9883
9886
  //reset initial state
9884
9887
  reset(){
9885
9888
  this.initializationMode = "left";
@@ -9889,11 +9892,11 @@ class FrozenColumns extends Module{
9889
9892
  this.rightMargin = 0;
9890
9893
  this.rightMargin = 0;
9891
9894
  this.active = false;
9892
-
9895
+
9893
9896
  this.table.columnManager.headersElement.style.marginLeft = 0;
9894
9897
  this.table.columnManager.element.style.paddingRight = 0;
9895
9898
  }
9896
-
9899
+
9897
9900
  initialize(){
9898
9901
  this.subscribe("cell-layout", this.layoutCell.bind(this));
9899
9902
  this.subscribe("column-init", this.initializeColumn.bind(this));
@@ -9906,183 +9909,191 @@ class FrozenColumns extends Module{
9906
9909
  this.subscribe("layout-refreshing", this.blockLayout.bind(this));
9907
9910
  this.subscribe("layout-refreshed", this.unblockLayout.bind(this));
9908
9911
  }
9909
-
9912
+
9910
9913
  blockLayout(){
9911
9914
  this.blocked = true;
9912
9915
  }
9913
-
9916
+
9914
9917
  unblockLayout(){
9915
9918
  this.blocked = false;
9916
9919
  }
9917
-
9920
+
9918
9921
  layoutCell(cell){
9919
9922
  this.layoutElement(cell.element, cell.column);
9920
9923
  }
9921
-
9924
+
9922
9925
  //initialize specific column
9923
9926
  initializeColumn(column){
9924
9927
  var config = {margin:0, edge:false};
9925
-
9928
+
9926
9929
  if(!column.isGroup){
9927
-
9930
+
9928
9931
  if(this.frozenCheck(column)){
9929
-
9932
+
9930
9933
  config.position = this.initializationMode;
9931
-
9934
+
9932
9935
  if(this.initializationMode == "left"){
9933
9936
  this.leftColumns.push(column);
9934
9937
  }else {
9935
9938
  this.rightColumns.unshift(column);
9936
9939
  }
9937
-
9940
+
9938
9941
  this.active = true;
9939
-
9942
+
9940
9943
  column.modules.frozen = config;
9941
9944
  }else {
9942
9945
  this.initializationMode = "right";
9943
9946
  }
9944
9947
  }
9945
9948
  }
9946
-
9949
+
9947
9950
  frozenCheck(column){
9948
-
9951
+
9949
9952
  if(column.parent.isGroup && column.definition.frozen){
9950
9953
  console.warn("Frozen Column Error - Parent column group must be frozen, not individual columns or sub column groups");
9951
9954
  }
9952
-
9955
+
9953
9956
  if(column.parent.isGroup){
9954
9957
  return this.frozenCheck(column.parent);
9955
9958
  }else {
9956
9959
  return column.definition.frozen;
9957
9960
  }
9958
9961
  }
9959
-
9962
+
9960
9963
  //quick layout to smooth horizontal scrolling
9961
9964
  scrollHorizontal(){
9962
9965
  var rows;
9963
-
9966
+
9964
9967
  if(this.active){
9965
9968
  clearTimeout(this.scrollEndTimer);
9966
9969
 
9967
- //layout all rows after scroll is complete
9968
- this.scrollEndTimer = setTimeout(() => {
9969
- this.layout();
9970
- }, 100);
9971
-
9972
9970
  rows = this.table.rowManager.getVisibleRows();
9973
-
9974
- this.calcMargins();
9975
-
9971
+
9972
+ this.calcMargins(true);
9973
+
9976
9974
  this.layoutColumnPosition();
9977
-
9975
+
9978
9976
  this.layoutCalcRows();
9979
-
9977
+
9980
9978
  rows.forEach((row) => {
9981
9979
  if(row.type === "row"){
9982
9980
  this.layoutRow(row);
9983
9981
  }
9984
9982
  });
9985
-
9986
- this.table.rowManager.tableElement.style.marginRight = this.rightMargin;
9987
9983
  }
9988
9984
  }
9989
-
9985
+
9990
9986
  //calculate margins for rows
9991
- calcMargins(){
9992
- this.leftMargin = this._calcSpace(this.leftColumns, this.leftColumns.length) + "px";
9993
- this.table.columnManager.headersElement.style.marginLeft = this.leftMargin;
9994
-
9995
- this.rightMargin = this._calcSpace(this.rightColumns, this.rightColumns.length) + "px";
9996
- this.table.columnManager.element.style.paddingRight = this.rightMargin;
9997
-
9987
+ calcMargins(scroll){
9988
+
9989
+ if(!scroll){
9990
+ this.leftMargin = this._calcSpace(this.leftColumns, this.leftColumns.length) + "px";
9991
+ this.rightMargin = this._calcSpace(this.rightColumns, this.rightColumns.length) + "px";
9992
+ this.table.rowManager.tableElement.style.marginRight = this.rightMargin;
9993
+ }
9994
+
9998
9995
  //calculate right frozen columns
9999
9996
  this.rightPadding = this.table.rowManager.element.clientWidth + this.table.columnManager.scrollLeft;
10000
9997
  }
10001
-
9998
+
10002
9999
  //layout calculation rows
10003
10000
  layoutCalcRows(){
10004
10001
  if(this.table.modExists("columnCalcs")){
10005
10002
  if(this.table.modules.columnCalcs.topInitialized && this.table.modules.columnCalcs.topRow){
10006
10003
  this.layoutRow(this.table.modules.columnCalcs.topRow);
10007
10004
  }
10008
-
10005
+
10009
10006
  if(this.table.modules.columnCalcs.botInitialized && this.table.modules.columnCalcs.botRow){
10010
10007
  this.layoutRow(this.table.modules.columnCalcs.botRow);
10011
10008
  }
10012
-
10009
+
10013
10010
  if(this.table.modExists("groupRows")){
10014
10011
  this.layoutGroupCalcs(this.table.modules.groupRows.getGroups());
10015
10012
  }
10016
10013
  }
10017
10014
  }
10018
-
10015
+
10019
10016
  layoutGroupCalcs(groups){
10020
10017
  groups.forEach((group) => {
10021
10018
  if(group.calcs.top){
10022
10019
  this.layoutRow(group.calcs.top);
10023
10020
  }
10024
-
10021
+
10025
10022
  if(group.calcs.bottom){
10026
10023
  this.layoutRow(group.calcs.bottom);
10027
10024
  }
10028
-
10025
+
10029
10026
  if(group.groupList && group.groupList.length){
10030
10027
  this.layoutGroupCalcs(group.groupList && group.groupList);
10031
10028
  }
10032
10029
  });
10033
10030
  }
10034
-
10031
+
10035
10032
  //calculate column positions and layout headers
10036
10033
  layoutColumnPosition(allCells){
10037
-
10038
10034
  var leftParents = [];
10035
+
10036
+ var leftMargin = 0;
10037
+ var rightMargin = 0;
10038
+
10039
+ this.table.columnManager.headersElement.style.marginLeft = this.leftMargin;
10040
+ this.table.columnManager.element.style.paddingRight = this.rightMargin;
10039
10041
 
10040
- this.leftColumns.forEach((column, i) => {
10041
- column.modules.frozen.margin = (this._calcSpace(this.leftColumns, i) + this.table.columnManager.scrollLeft) + "px";
10042
+ this.leftColumns.forEach((column, i) => {
10043
+ column.modules.frozen.margin = (leftMargin + this.table.columnManager.scrollLeft) + "px";
10042
10044
 
10045
+ if(column.visible){
10046
+ leftMargin += column.getWidth();
10047
+ }
10048
+
10043
10049
  if(i == this.leftColumns.length - 1){
10044
10050
  column.modules.frozen.edge = true;
10045
10051
  }else {
10046
10052
  column.modules.frozen.edge = false;
10047
10053
  }
10048
-
10054
+
10049
10055
  if(column.parent.isGroup){
10050
10056
  var parentEl = this.getColGroupParentElement(column);
10051
10057
  if(!leftParents.includes(parentEl)){
10052
10058
  this.layoutElement(parentEl, column);
10053
10059
  leftParents.push(parentEl);
10054
10060
  }
10055
-
10061
+
10056
10062
  if(column.modules.frozen.edge){
10057
10063
  parentEl.classList.add("tabulator-frozen-" + column.modules.frozen.position);
10058
10064
  }
10059
10065
  }else {
10060
10066
  this.layoutElement(column.getElement(), column);
10061
10067
  }
10062
-
10068
+
10063
10069
  if(allCells){
10064
10070
  column.cells.forEach((cell) => {
10065
10071
  this.layoutElement(cell.getElement(true), column);
10066
10072
  });
10067
10073
  }
10068
10074
  });
10069
-
10075
+
10070
10076
  this.rightColumns.forEach((column, i) => {
10071
- column.modules.frozen.margin = (this.rightPadding - this._calcSpace(this.rightColumns, i + 1)) + "px";
10072
10077
 
10078
+ if(column.visible){
10079
+ rightMargin += column.getWidth();
10080
+ }
10081
+
10082
+ column.modules.frozen.margin = (this.rightPadding - rightMargin) + "px";
10083
+
10073
10084
  if(i == this.rightColumns.length - 1){
10074
10085
  column.modules.frozen.edge = true;
10075
10086
  }else {
10076
10087
  column.modules.frozen.edge = false;
10077
10088
  }
10078
-
10079
-
10089
+
10090
+
10080
10091
  if(column.parent.isGroup){
10081
10092
  this.layoutElement(this.getColGroupParentElement(column), column);
10082
10093
  }else {
10083
10094
  this.layoutElement(column.getElement(), column);
10084
10095
  }
10085
-
10096
+
10086
10097
  if(allCells){
10087
10098
  column.cells.forEach((cell) => {
10088
10099
  this.layoutElement(cell.getElement(true), column);
@@ -10090,82 +10101,79 @@ class FrozenColumns extends Module{
10090
10101
  }
10091
10102
  });
10092
10103
  }
10093
-
10104
+
10094
10105
  getColGroupParentElement(column){
10095
10106
  return column.parent.isGroup ? this.getColGroupParentElement(column.parent) : column.getElement();
10096
10107
  }
10097
-
10108
+
10098
10109
  //layout columns appropriately
10099
10110
  layout(){
10100
-
10101
10111
  if(this.active && !this.blocked){
10102
10112
  //calculate row padding
10103
10113
  this.calcMargins();
10104
-
10114
+
10105
10115
  this.table.rowManager.getDisplayRows().forEach((row) =>{
10106
10116
  if(row.type === "row"){
10107
10117
  this.layoutRow(row);
10108
10118
  }
10109
10119
  });
10110
-
10120
+
10111
10121
  this.layoutCalcRows();
10112
-
10122
+
10113
10123
  //calculate left columns
10114
10124
  this.layoutColumnPosition(true);
10115
-
10116
- this.table.rowManager.tableElement.style.marginRight = this.rightMargin;
10117
10125
  }
10118
10126
  }
10119
-
10127
+
10120
10128
  layoutRow(row){
10121
10129
  var rowEl = row.getElement();
10122
-
10130
+
10123
10131
  rowEl.style.paddingLeft = this.leftMargin;
10124
-
10132
+
10125
10133
  if(this.table.options.layout === "fitDataFill" && this.rightColumns.length){
10126
10134
  this.table.rowManager.getTableElement().style.minWidth = "calc(100% - " + this.rightMargin + ")";
10127
10135
  }
10128
-
10136
+
10129
10137
  this.leftColumns.forEach((column) => {
10130
10138
  var cell = row.getCell(column);
10131
-
10139
+
10132
10140
  if(cell){
10133
10141
  this.layoutElement(cell.getElement(true), column);
10134
10142
  }
10135
10143
  });
10136
-
10144
+
10137
10145
  this.rightColumns.forEach((column) => {
10138
10146
  var cell = row.getCell(column);
10139
-
10147
+
10140
10148
  if(cell){
10141
10149
  this.layoutElement(cell.getElement(true), column);
10142
10150
  }
10143
10151
  });
10144
10152
  }
10145
-
10153
+
10146
10154
  layoutElement(element, column){
10147
-
10155
+
10148
10156
  if(column.modules.frozen){
10149
10157
  element.style.position = "absolute";
10150
10158
  element.style.left = column.modules.frozen.margin;
10151
-
10159
+
10152
10160
  element.classList.add("tabulator-frozen");
10153
-
10161
+
10154
10162
  if(column.modules.frozen.edge){
10155
10163
  element.classList.add("tabulator-frozen-" + column.modules.frozen.position);
10156
10164
  }
10157
10165
  }
10158
10166
  }
10159
-
10167
+
10160
10168
  _calcSpace(columns, index){
10161
10169
  var width = 0;
10162
-
10170
+
10163
10171
  for (let i = 0; i < index; i++){
10164
10172
  if(columns[i].visible){
10165
10173
  width += columns[i].getWidth();
10166
10174
  }
10167
10175
  }
10168
-
10176
+
10169
10177
  return width;
10170
10178
  }
10171
10179
  }
@@ -14253,28 +14261,36 @@ function rows(pageSize, currentRow, currentPage, totalRows, totalPages){
14253
14261
  ofEl = document.createElement("span"),
14254
14262
  totalEl = document.createElement("span"),
14255
14263
  rowsEl = document.createElement("span");
14256
-
14264
+
14257
14265
  this.table.modules.localize.langBind("pagination|counter|showing", (value) => {
14258
14266
  showingEl.innerHTML = value;
14259
14267
  });
14260
-
14261
- valueEl.innerHTML = " " + currentRow + "-" + Math.min((currentRow + pageSize - 1), totalRows) + " ";
14262
-
14268
+
14263
14269
  this.table.modules.localize.langBind("pagination|counter|of", (value) => {
14264
14270
  ofEl.innerHTML = value;
14265
14271
  });
14266
-
14267
- totalEl.innerHTML = " " + totalRows + " ";
14268
-
14272
+
14269
14273
  this.table.modules.localize.langBind("pagination|counter|rows", (value) => {
14270
14274
  rowsEl.innerHTML = value;
14271
14275
  });
14272
-
14273
- el.appendChild(showingEl);
14274
- el.appendChild(valueEl);
14275
- el.appendChild(ofEl);
14276
- el.appendChild(totalEl);
14277
- el.appendChild(rowsEl);
14276
+
14277
+ if(totalRows){
14278
+ valueEl.innerHTML = " " + currentRow + "-" + Math.min((currentRow + pageSize - 1), totalRows) + " ";
14279
+
14280
+ totalEl.innerHTML = " " + totalRows + " ";
14281
+
14282
+ el.appendChild(showingEl);
14283
+ el.appendChild(valueEl);
14284
+ el.appendChild(ofEl);
14285
+ el.appendChild(totalEl);
14286
+ el.appendChild(rowsEl);
14287
+ }else {
14288
+ valueEl.innerHTML = " 0 ";
14289
+
14290
+ el.appendChild(showingEl);
14291
+ el.appendChild(valueEl);
14292
+ el.appendChild(rowsEl);
14293
+ }
14278
14294
 
14279
14295
  return el;
14280
14296
  }
@@ -15164,8 +15180,8 @@ class Page extends Module{
15164
15180
 
15165
15181
  //handle the footer element being redrawn
15166
15182
  footerRedraw(){
15167
- var footer = this.table.footerManager.element;
15168
-
15183
+ var footer = this.table.footerManager.containerElement;
15184
+
15169
15185
  if((Math.ceil(footer.clientWidth) - footer.scrollWidth) < 0){
15170
15186
  this.pagesElement.style.display = 'none';
15171
15187
  }else {
@@ -17223,7 +17239,9 @@ class SelectRow extends Module{
17223
17239
  self._deselectRow(self.selectedRows[0], true);
17224
17240
  }
17225
17241
 
17226
- self._rowSelectionChanged(silent);
17242
+ if(rowCount){
17243
+ self._rowSelectionChanged(silent);
17244
+ }
17227
17245
 
17228
17246
  }else {
17229
17247
  if(Array.isArray(rows)){
@@ -18994,7 +19012,7 @@ class VirtualDomHorizontal extends Renderer{
18994
19012
  this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window;
18995
19013
 
18996
19014
  var row = this.chain("rows-sample", [1], [], () => {
18997
- return this.table.rowManager.getDisplayRows()[0];
19015
+ return this.table.rowManager.getDisplayRows();
18998
19016
  })[0];
18999
19017
 
19000
19018
  if(row){
@@ -21685,7 +21703,7 @@ class FooterManager extends CoreFeature{
21685
21703
  this.containerElement.innerHTML = this.table.options.footerElement;
21686
21704
  }else {
21687
21705
  this.external = true;
21688
- this.element = document.querySelector(this.table.options.footerElement);
21706
+ this.containerElement = document.querySelector(this.table.options.footerElement);
21689
21707
  }
21690
21708
  break;
21691
21709
 
@@ -22002,7 +22020,7 @@ class InteractionManager extends CoreFeature {
22002
22020
  return row.getElement() === target;
22003
22021
  });
22004
22022
 
22005
- if(targets["row"].parentNode && targets["row"].parentNode.closest(".tabulator-row")){
22023
+ if(targets["row"] && targets["row"].parentNode && targets["row"].parentNode.closest(".tabulator-row")){
22006
22024
  targets[key] = false;
22007
22025
  }
22008
22026
  }
@@ -23433,7 +23451,7 @@ class Tabulator {
23433
23451
  _clearObjectPointers(){
23434
23452
  this.options.columns = this.options.columns.slice(0);
23435
23453
 
23436
- if(this.options.data && !this.options.reactiveData){
23454
+ if(Array.isArray(this.options.data) && !this.options.reactiveData){
23437
23455
  this.options.data = this.options.data.slice(0);
23438
23456
  }
23439
23457
  }