tabulator-tables 5.4.2 → 5.4.3

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 (66) hide show
  1. package/dist/css/tabulator.css +1 -0
  2. package/dist/css/tabulator.css.map +1 -1
  3. package/dist/css/tabulator.min.css +1 -1
  4. package/dist/css/tabulator.min.css.map +1 -1
  5. package/dist/css/tabulator_bootstrap3.css +1 -0
  6. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  7. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  8. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  9. package/dist/css/tabulator_bootstrap4.css +1 -0
  10. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  11. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  12. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  13. package/dist/css/tabulator_bootstrap5.css +1 -0
  14. package/dist/css/tabulator_bootstrap5.css.map +1 -1
  15. package/dist/css/tabulator_bootstrap5.min.css +1 -1
  16. package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
  17. package/dist/css/tabulator_bulma.css +1 -0
  18. package/dist/css/tabulator_bulma.css.map +1 -1
  19. package/dist/css/tabulator_bulma.min.css +1 -1
  20. package/dist/css/tabulator_bulma.min.css.map +1 -1
  21. package/dist/css/tabulator_materialize.css +1 -0
  22. package/dist/css/tabulator_materialize.css.map +1 -1
  23. package/dist/css/tabulator_materialize.min.css +1 -1
  24. package/dist/css/tabulator_materialize.min.css.map +1 -1
  25. package/dist/css/tabulator_midnight.css +1 -0
  26. package/dist/css/tabulator_midnight.css.map +1 -1
  27. package/dist/css/tabulator_midnight.min.css +1 -1
  28. package/dist/css/tabulator_midnight.min.css.map +1 -1
  29. package/dist/css/tabulator_modern.css +1 -0
  30. package/dist/css/tabulator_modern.css.map +1 -1
  31. package/dist/css/tabulator_modern.min.css +1 -1
  32. package/dist/css/tabulator_modern.min.css.map +1 -1
  33. package/dist/css/tabulator_semanticui.css +1 -0
  34. package/dist/css/tabulator_semanticui.css.map +1 -1
  35. package/dist/css/tabulator_semanticui.min.css +1 -1
  36. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  37. package/dist/css/tabulator_simple.css +1 -0
  38. package/dist/css/tabulator_simple.css.map +1 -1
  39. package/dist/css/tabulator_simple.min.css +1 -1
  40. package/dist/css/tabulator_simple.min.css.map +1 -1
  41. package/dist/css/tabulator_site.css +1 -0
  42. package/dist/css/tabulator_site.css.map +1 -1
  43. package/dist/css/tabulator_site.min.css +1 -1
  44. package/dist/css/tabulator_site.min.css.map +1 -1
  45. package/dist/js/tabulator.js +280 -222
  46. package/dist/js/tabulator.js.map +1 -1
  47. package/dist/js/tabulator.min.js +2 -2
  48. package/dist/js/tabulator.min.js.map +1 -1
  49. package/dist/js/tabulator_esm.js +280 -222
  50. package/dist/js/tabulator_esm.js.map +1 -1
  51. package/dist/js/tabulator_esm.min.js +2 -2
  52. package/dist/js/tabulator_esm.min.js.map +1 -1
  53. package/package.json +1 -1
  54. package/src/js/core/RowManager.js +49 -30
  55. package/src/js/core/Tabulator.js +7 -8
  56. package/src/js/core/tools/Popup.js +1 -1
  57. package/src/js/modules/Edit/List.js +1 -1
  58. package/src/js/modules/Edit/inputMask.js +1 -1
  59. package/src/js/modules/Export/Export.js +151 -145
  60. package/src/js/modules/Filter/Filter.js +11 -8
  61. package/src/js/modules/GroupRows/Group.js +10 -7
  62. package/src/js/modules/GroupRows/GroupRows.js +23 -7
  63. package/src/js/modules/Localize/Localize.js +0 -9
  64. package/src/js/modules/Print/Print.js +15 -2
  65. package/src/js/modules/SelectRow/SelectRow.js +10 -2
  66. package/src/scss/tabulator.scss +1 -0
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.4.2 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.4.3 (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) :
@@ -4568,18 +4568,32 @@
4568
4568
  }
4569
4569
 
4570
4570
  initializePlaceholder(){
4571
+ var placeholder = this.table.options.placeholder;
4572
+
4571
4573
  //configure placeholder element
4572
- if(typeof this.table.options.placeholder == "string"){
4574
+ if(placeholder){
4573
4575
  let el = document.createElement("div");
4574
4576
  el.classList.add("tabulator-placeholder");
4575
-
4576
- let contents = document.createElement("div");
4577
- contents.classList.add("tabulator-placeholder-contents");
4578
- contents.innerHTML = this.table.options.placeholder;
4579
-
4580
- el.appendChild(contents);
4581
-
4582
- this.placeholderContents = contents;
4577
+
4578
+ if(typeof placeholder == "string"){
4579
+ let contents = document.createElement("div");
4580
+ contents.classList.add("tabulator-placeholder-contents");
4581
+ contents.innerHTML = placeholder;
4582
+
4583
+ el.appendChild(contents);
4584
+
4585
+ this.placeholderContents = contents;
4586
+
4587
+ }else if(typeof HTMLElement !== "undefined" && placeholder instanceof HTMLElement){
4588
+
4589
+ el.appendChild(placeholder);
4590
+ this.placeholderContents = placeholder;
4591
+ }else {
4592
+ console.warn("Invalid placeholder provided, must be string or HTML Element", placeholder);
4593
+
4594
+ this.el = null;
4595
+ }
4596
+
4583
4597
  this.placeholder = el;
4584
4598
  }
4585
4599
  }
@@ -4737,18 +4751,24 @@
4737
4751
  _wipeElements(){
4738
4752
  this.dispatch("rows-wipe");
4739
4753
 
4754
+ this.destroy();
4755
+
4756
+ this.adjustTableSize();
4757
+
4758
+ this.dispatch("rows-wiped");
4759
+ }
4760
+
4761
+ destroy(){
4740
4762
  this.rows.forEach((row) => {
4741
4763
  row.wipe();
4742
4764
  });
4743
-
4765
+
4744
4766
  this.rows = [];
4745
4767
  this.activeRows = [];
4746
4768
  this.activeRowsPipeline = [];
4747
4769
  this.activeRowsCount = 0;
4748
4770
  this.displayRows = [];
4749
4771
  this.displayRowsCount = 0;
4750
-
4751
- this.adjustTableSize();
4752
4772
  }
4753
4773
 
4754
4774
  deleteRow(row, blockRedraw){
@@ -4796,7 +4816,7 @@
4796
4816
  }
4797
4817
 
4798
4818
  //add multiple rows
4799
- addRows(data, pos, index){
4819
+ addRows(data, pos, index, refreshDisplayOnly){
4800
4820
  var rows = [];
4801
4821
 
4802
4822
  return new Promise((resolve, reject) => {
@@ -4815,8 +4835,8 @@
4815
4835
  rows.push(row);
4816
4836
  this.dispatch("row-added", row, data, pos, index);
4817
4837
  });
4818
-
4819
- this.refreshActiveData(false, false, true);
4838
+
4839
+ this.refreshActiveData(refreshDisplayOnly ? "displayPipeline" : false, false, true);
4820
4840
 
4821
4841
  this.regenerateRowPositions();
4822
4842
 
@@ -5296,22 +5316,21 @@
5296
5316
  getRows(type){
5297
5317
  var rows = [];
5298
5318
 
5299
- if(!type || type === true){
5300
- rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;
5301
- }else {
5302
- switch(type){
5303
- case "active":
5304
- rows = this.activeRows;
5305
- break;
5319
+ switch(type){
5320
+ case "active":
5321
+ rows = this.activeRows;
5322
+ break;
5323
+
5324
+ case "display":
5325
+ rows = this.table.rowManager.getDisplayRows();
5326
+ break;
5306
5327
 
5307
- case "display":
5308
- rows = this.table.rowManager.getDisplayRows();
5309
- break;
5310
-
5311
- case "visible":
5312
- rows = this.getVisibleRows(false, true);
5313
- break;
5314
- }
5328
+ case "visible":
5329
+ rows = this.getVisibleRows(false, true);
5330
+ break;
5331
+
5332
+ default:
5333
+ rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;
5315
5334
  }
5316
5335
 
5317
5336
  return rows;
@@ -6554,7 +6573,7 @@
6554
6573
  this.blurEvent = this.hide.bind(this, false);
6555
6574
  this.escEvent = this._escapeCheck.bind(this);
6556
6575
 
6557
- this.destroyBinding = this.tableDestroyed;
6576
+ this.destroyBinding = this.tableDestroyed.bind(this);
6558
6577
  this.destroyed = false;
6559
6578
  }
6560
6579
 
@@ -7334,15 +7353,6 @@
7334
7353
  this.langList.default.headerFilters.default = placeholder;
7335
7354
  }
7336
7355
 
7337
- //set header filter placeholder by column
7338
- setHeaderFilterColumnPlaceholder(column, placeholder){
7339
- this.langList.default.headerFilters.columns[column] = placeholder;
7340
-
7341
- if(this.lang && !this.lang.headerFilters.columns[column]){
7342
- this.lang.headerFilters.columns[column] = placeholder;
7343
- }
7344
- }
7345
-
7346
7356
  //setup a lang description object
7347
7357
  installLang(locale, lang){
7348
7358
  if(this.langList[locale]){
@@ -7972,13 +7982,7 @@
7972
7982
  this.eventBus.dispatch("table-destroy");
7973
7983
 
7974
7984
  //clear row data
7975
- this.rowManager.rows.forEach(function(row){
7976
- row.wipe();
7977
- });
7978
-
7979
- this.rowManager.rows = [];
7980
- this.rowManager.activeRows = [];
7981
- this.rowManager.displayRows = [];
7985
+ this.rowManager.destroy();
7982
7986
 
7983
7987
  //clear DOM
7984
7988
  while(element.firstChild) element.removeChild(element.firstChild);
@@ -8113,7 +8117,12 @@
8113
8117
  if(!responses){
8114
8118
  resolve();
8115
8119
  }
8120
+ })
8121
+ .catch((e) => {
8122
+ reject("Update Error - Unable to update row", item, e);
8116
8123
  });
8124
+ }else {
8125
+ reject("Update Error - Unable to find row", item);
8117
8126
  }
8118
8127
  });
8119
8128
  }else {
@@ -8269,7 +8278,7 @@
8269
8278
  data = JSON.parse(data);
8270
8279
  }
8271
8280
 
8272
- return this.rowManager.addRows(data, pos, index)
8281
+ return this.rowManager.addRows(data, pos, index, true)
8273
8282
  .then((rows)=>{
8274
8283
  return rows[0].getComponent();
8275
8284
  });
@@ -11171,7 +11180,7 @@
11171
11180
  var index = el.value.length,
11172
11181
  char = e.key;
11173
11182
 
11174
- if(e.keyCode > 46){
11183
+ if(e.keyCode > 46 && !e.ctrlKey && !e.metaKey){
11175
11184
  if(index >= mask.length){
11176
11185
  e.preventDefault();
11177
11186
  e.stopPropagation();
@@ -12922,7 +12931,7 @@
12922
12931
  if(this.currentItems[0]){
12923
12932
  output = this.currentItems[0].value;
12924
12933
  }else {
12925
- initialValue = this.initialValues[0];
12934
+ initialValue = Array.isArray(this.initialValues) ? this.initialValues[0] : this.initialValues;
12926
12935
 
12927
12936
  if(initialValue === null || typeof initialValue === "undefined" || initialValue === ""){
12928
12937
  output = initialValue;
@@ -14108,57 +14117,57 @@
14108
14117
  }
14109
14118
 
14110
14119
  class Export extends Module{
14111
-
14120
+
14112
14121
  constructor(table){
14113
14122
  super(table);
14114
-
14123
+
14115
14124
  this.config = {};
14116
14125
  this.cloneTableStyle = true;
14117
14126
  this.colVisProp = "";
14118
-
14127
+
14119
14128
  this.registerTableOption("htmlOutputConfig", false); //html output config
14120
-
14129
+
14121
14130
  this.registerColumnOption("htmlOutput");
14122
14131
  this.registerColumnOption("titleHtmlOutput");
14123
14132
  }
14124
-
14133
+
14125
14134
  initialize(){
14126
14135
  this.registerTableFunction("getHtml", this.getHtml.bind(this));
14127
14136
  }
14128
-
14137
+
14129
14138
  ///////////////////////////////////
14130
14139
  ///////// Table Functions /////////
14131
14140
  ///////////////////////////////////
14132
-
14133
-
14141
+
14142
+
14134
14143
  ///////////////////////////////////
14135
14144
  ///////// Internal Logic //////////
14136
14145
  ///////////////////////////////////
14137
-
14146
+
14138
14147
  generateExportList(config, style, range, colVisProp){
14139
14148
  this.cloneTableStyle = style;
14140
14149
  this.config = config || {};
14141
14150
  this.colVisProp = colVisProp;
14142
-
14151
+
14143
14152
  var headers = this.config.columnHeaders !== false ? this.headersToExportRows(this.generateColumnGroupHeaders()) : [];
14144
14153
  var body = this.bodyToExportRows(this.rowLookup(range));
14145
-
14154
+
14146
14155
  return headers.concat(body);
14147
14156
  }
14148
-
14157
+
14149
14158
  generateTable(config, style, range, colVisProp){
14150
14159
  var list = this.generateExportList(config, style, range, colVisProp);
14151
-
14160
+
14152
14161
  return this.generateTableElement(list);
14153
14162
  }
14154
-
14163
+
14155
14164
  rowLookup(range){
14156
14165
  var rows = [];
14157
-
14166
+
14158
14167
  if(typeof range == "function"){
14159
14168
  range.call(this.table).forEach((row) =>{
14160
14169
  row = this.table.rowManager.findRow(row);
14161
-
14170
+
14162
14171
  if(row){
14163
14172
  rows.push(row);
14164
14173
  }
@@ -14169,15 +14178,15 @@
14169
14178
  case "visible":
14170
14179
  rows = this.table.rowManager.getVisibleRows(false, true);
14171
14180
  break;
14172
-
14181
+
14173
14182
  case "all":
14174
14183
  rows = this.table.rowManager.rows;
14175
14184
  break;
14176
-
14185
+
14177
14186
  case "selected":
14178
14187
  rows = this.table.modules.selectRow.selectedRows;
14179
14188
  break;
14180
-
14189
+
14181
14190
  case "active":
14182
14191
  default:
14183
14192
  if(this.table.options.pagination){
@@ -14187,56 +14196,56 @@
14187
14196
  }
14188
14197
  }
14189
14198
  }
14190
-
14199
+
14191
14200
  return Object.assign([], rows);
14192
14201
  }
14193
-
14202
+
14194
14203
  generateColumnGroupHeaders(){
14195
14204
  var output = [];
14196
-
14205
+
14197
14206
  var columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex;
14198
-
14207
+
14199
14208
  columns.forEach((column) => {
14200
14209
  var colData = this.processColumnGroup(column);
14201
-
14210
+
14202
14211
  if(colData){
14203
14212
  output.push(colData);
14204
14213
  }
14205
14214
  });
14206
-
14215
+
14207
14216
  return output;
14208
14217
  }
14209
-
14218
+
14210
14219
  processColumnGroup(column){
14211
14220
  var subGroups = column.columns,
14212
14221
  maxDepth = 0,
14213
14222
  title = column.definition["title" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))] || column.definition.title;
14214
-
14223
+
14215
14224
  var groupData = {
14216
14225
  title:title,
14217
14226
  column:column,
14218
14227
  depth:1,
14219
14228
  };
14220
-
14229
+
14221
14230
  if(subGroups.length){
14222
14231
  groupData.subGroups = [];
14223
14232
  groupData.width = 0;
14224
-
14233
+
14225
14234
  subGroups.forEach((subGroup) => {
14226
14235
  var subGroupData = this.processColumnGroup(subGroup);
14227
-
14236
+
14228
14237
  if(subGroupData){
14229
14238
  groupData.width += subGroupData.width;
14230
14239
  groupData.subGroups.push(subGroupData);
14231
-
14240
+
14232
14241
  if(subGroupData.depth > maxDepth){
14233
14242
  maxDepth = subGroupData.depth;
14234
14243
  }
14235
14244
  }
14236
14245
  });
14237
-
14246
+
14238
14247
  groupData.depth += maxDepth;
14239
-
14248
+
14240
14249
  if(!groupData.width){
14241
14250
  return false;
14242
14251
  }
@@ -14247,75 +14256,75 @@
14247
14256
  return false;
14248
14257
  }
14249
14258
  }
14250
-
14259
+
14251
14260
  return groupData;
14252
14261
  }
14253
-
14262
+
14254
14263
  columnVisCheck(column){
14255
14264
  var visProp = column.definition[this.colVisProp];
14256
-
14265
+
14257
14266
  if(typeof visProp === "function"){
14258
14267
  visProp = visProp.call(this.table, column.getComponent());
14259
14268
  }
14260
-
14269
+
14261
14270
  return visProp !== false && (column.visible || (!column.visible && visProp));
14262
14271
  }
14263
-
14272
+
14264
14273
  headersToExportRows(columns){
14265
14274
  var headers = [],
14266
14275
  headerDepth = 0,
14267
14276
  exportRows = [];
14268
-
14277
+
14269
14278
  function parseColumnGroup(column, level){
14270
-
14279
+
14271
14280
  var depth = headerDepth - level;
14272
-
14281
+
14273
14282
  if(typeof headers[level] === "undefined"){
14274
14283
  headers[level] = [];
14275
14284
  }
14276
-
14285
+
14277
14286
  column.height = column.subGroups ? 1 : (depth - column.depth) + 1;
14278
-
14287
+
14279
14288
  headers[level].push(column);
14280
-
14289
+
14281
14290
  if(column.height > 1){
14282
14291
  for(let i = 1; i < column.height; i ++){
14283
-
14292
+
14284
14293
  if(typeof headers[level + i] === "undefined"){
14285
14294
  headers[level + i] = [];
14286
14295
  }
14287
-
14296
+
14288
14297
  headers[level + i].push(false);
14289
14298
  }
14290
14299
  }
14291
-
14300
+
14292
14301
  if(column.width > 1){
14293
14302
  for(let i = 1; i < column.width; i ++){
14294
14303
  headers[level].push(false);
14295
14304
  }
14296
14305
  }
14297
-
14306
+
14298
14307
  if(column.subGroups){
14299
14308
  column.subGroups.forEach(function(subGroup){
14300
14309
  parseColumnGroup(subGroup, level+1);
14301
14310
  });
14302
14311
  }
14303
14312
  }
14304
-
14313
+
14305
14314
  //calculate maximum header depth
14306
14315
  columns.forEach(function(column){
14307
14316
  if(column.depth > headerDepth){
14308
14317
  headerDepth = column.depth;
14309
14318
  }
14310
14319
  });
14311
-
14320
+
14312
14321
  columns.forEach(function(column){
14313
14322
  parseColumnGroup(column,0);
14314
14323
  });
14315
-
14324
+
14316
14325
  headers.forEach((header) => {
14317
14326
  var columns = [];
14318
-
14327
+
14319
14328
  header.forEach((col) => {
14320
14329
  if(col){
14321
14330
  let title = typeof col.title === "undefined" ? "" : col.title;
@@ -14324,78 +14333,78 @@
14324
14333
  columns.push(null);
14325
14334
  }
14326
14335
  });
14327
-
14336
+
14328
14337
  exportRows.push(new ExportRow("header", columns));
14329
14338
  });
14330
-
14339
+
14331
14340
  return exportRows;
14332
14341
  }
14333
-
14342
+
14334
14343
  bodyToExportRows(rows){
14335
-
14344
+
14336
14345
  var columns = [];
14337
14346
  var exportRows = [];
14338
-
14347
+
14339
14348
  this.table.columnManager.columnsByIndex.forEach((column) => {
14340
14349
  if (this.columnVisCheck(column)) {
14341
14350
  columns.push(column.getComponent());
14342
14351
  }
14343
14352
  });
14344
-
14353
+
14345
14354
  if(this.config.columnCalcs !== false && this.table.modExists("columnCalcs")){
14346
14355
  if(this.table.modules.columnCalcs.topInitialized){
14347
14356
  rows.unshift(this.table.modules.columnCalcs.topRow);
14348
14357
  }
14349
-
14358
+
14350
14359
  if(this.table.modules.columnCalcs.botInitialized){
14351
14360
  rows.push(this.table.modules.columnCalcs.botRow);
14352
14361
  }
14353
14362
  }
14354
-
14363
+
14355
14364
  rows = rows.filter((row) => {
14356
14365
  switch(row.type){
14357
14366
  case "group":
14358
14367
  return this.config.rowGroups !== false;
14359
-
14368
+
14360
14369
  case "calc":
14361
14370
  return this.config.columnCalcs !== false;
14362
-
14371
+
14363
14372
  case "row":
14364
14373
  return !(this.table.options.dataTree && this.config.dataTree === false && row.modules.dataTree.parent);
14365
14374
  }
14366
-
14375
+
14367
14376
  return true;
14368
14377
  });
14369
-
14378
+
14370
14379
  rows.forEach((row, i) => {
14371
14380
  var rowData = row.getData(this.colVisProp);
14372
14381
  var exportCols = [];
14373
14382
  var indent = 0;
14374
-
14383
+
14375
14384
  switch(row.type){
14376
14385
  case "group":
14377
14386
  indent = row.level;
14378
14387
  exportCols.push(new ExportColumn(row.key, row.getComponent(), columns.length, 1));
14379
14388
  break;
14380
-
14389
+
14381
14390
  case "calc" :
14382
14391
  case "row" :
14383
14392
  columns.forEach((col) => {
14384
14393
  exportCols.push(new ExportColumn(col._column.getFieldValue(rowData), col, 1, 1));
14385
14394
  });
14386
-
14395
+
14387
14396
  if(this.table.options.dataTree && this.config.dataTree !== false){
14388
14397
  indent = row.modules.dataTree.index;
14389
14398
  }
14390
14399
  break;
14391
14400
  }
14392
-
14401
+
14393
14402
  exportRows.push(new ExportRow(row.type, exportCols, row.getComponent(), indent));
14394
14403
  });
14395
-
14404
+
14396
14405
  return exportRows;
14397
14406
  }
14398
-
14407
+
14399
14408
  generateTableElement(list){
14400
14409
  var table = document.createElement("table"),
14401
14410
  headerEl = document.createElement("thead"),
@@ -14403,68 +14412,68 @@
14403
14412
  styles = this.lookupTableStyles(),
14404
14413
  rowFormatter = this.table.options["rowFormatter" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))],
14405
14414
  setup = {};
14406
-
14415
+
14407
14416
  setup.rowFormatter = rowFormatter !== null ? rowFormatter : this.table.options.rowFormatter;
14408
-
14417
+
14409
14418
  if(this.table.options.dataTree &&this.config.dataTree !== false && this.table.modExists("columnCalcs")){
14410
14419
  setup.treeElementField = this.table.modules.dataTree.elementField;
14411
14420
  }
14412
-
14421
+
14413
14422
  //assign group header formatter
14414
14423
  setup.groupHeader = this.table.options["groupHeader" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))];
14415
-
14424
+
14416
14425
  if(setup.groupHeader && !Array.isArray(setup.groupHeader)){
14417
14426
  setup.groupHeader = [setup.groupHeader];
14418
14427
  }
14419
-
14428
+
14420
14429
  table.classList.add("tabulator-print-table");
14421
-
14430
+
14422
14431
  this.mapElementStyles(this.table.columnManager.getHeadersElement(), headerEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
14423
-
14424
-
14432
+
14433
+
14425
14434
  if(list.length > 1000){
14426
14435
  console.warn("It may take a long time to render an HTML table with more than 1000 rows");
14427
14436
  }
14428
-
14437
+
14429
14438
  list.forEach((row, i) => {
14430
14439
  let rowEl;
14431
-
14440
+
14432
14441
  switch(row.type){
14433
14442
  case "header":
14434
14443
  headerEl.appendChild(this.generateHeaderElement(row, setup, styles));
14435
14444
  break;
14436
-
14445
+
14437
14446
  case "group":
14438
14447
  bodyEl.appendChild(this.generateGroupElement(row, setup, styles));
14439
14448
  break;
14440
-
14449
+
14441
14450
  case "calc":
14442
14451
  bodyEl.appendChild(this.generateCalcElement(row, setup, styles));
14443
14452
  break;
14444
-
14453
+
14445
14454
  case "row":
14446
14455
  rowEl = this.generateRowElement(row, setup, styles);
14447
-
14456
+
14448
14457
  this.mapElementStyles(((i % 2) && styles.evenRow) ? styles.evenRow : styles.oddRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
14449
14458
  bodyEl.appendChild(rowEl);
14450
14459
  break;
14451
14460
  }
14452
14461
  });
14453
-
14462
+
14454
14463
  if(headerEl.innerHTML){
14455
14464
  table.appendChild(headerEl);
14456
14465
  }
14457
-
14466
+
14458
14467
  table.appendChild(bodyEl);
14459
-
14460
-
14468
+
14469
+
14461
14470
  this.mapElementStyles(this.table.element, table, ["border-top", "border-left", "border-right", "border-bottom"]);
14462
14471
  return table;
14463
14472
  }
14464
-
14473
+
14465
14474
  lookupTableStyles(){
14466
14475
  var styles = {};
14467
-
14476
+
14468
14477
  //lookup row styles
14469
14478
  if(this.cloneTableStyle && window.getComputedStyle){
14470
14479
  styles.oddRow = this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)");
@@ -14472,41 +14481,41 @@
14472
14481
  styles.calcRow = this.table.element.querySelector(".tabulator-row.tabulator-calcs");
14473
14482
  styles.firstRow = this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)");
14474
14483
  styles.firstGroup = this.table.element.getElementsByClassName("tabulator-group")[0];
14475
-
14484
+
14476
14485
  if(styles.firstRow){
14477
14486
  styles.styleCells = styles.firstRow.getElementsByClassName("tabulator-cell");
14478
14487
  styles.firstCell = styles.styleCells[0];
14479
14488
  styles.lastCell = styles.styleCells[styles.styleCells.length - 1];
14480
14489
  }
14481
14490
  }
14482
-
14491
+
14483
14492
  return styles;
14484
14493
  }
14485
-
14494
+
14486
14495
  generateHeaderElement(row, setup, styles){
14487
14496
  var rowEl = document.createElement("tr");
14488
-
14497
+
14489
14498
  row.columns.forEach((column) => {
14490
14499
  if(column){
14491
14500
  var cellEl = document.createElement("th");
14492
14501
  var classNames = column.component._column.definition.cssClass ? column.component._column.definition.cssClass.split(" ") : [];
14493
-
14502
+
14494
14503
  cellEl.colSpan = column.width;
14495
14504
  cellEl.rowSpan = column.height;
14496
-
14505
+
14497
14506
  cellEl.innerHTML = column.value;
14498
-
14507
+
14499
14508
  if(this.cloneTableStyle){
14500
14509
  cellEl.style.boxSizing = "border-box";
14501
14510
  }
14502
-
14511
+
14503
14512
  classNames.forEach(function(className) {
14504
14513
  cellEl.classList.add(className);
14505
14514
  });
14506
-
14515
+
14507
14516
  this.mapElementStyles(column.component.getElement(), cellEl, ["text-align", "border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
14508
14517
  this.mapElementStyles(column.component._column.contentElement, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);
14509
-
14518
+
14510
14519
  if(column.component._column.visible){
14511
14520
  this.mapElementStyles(column.component.getElement(), cellEl, ["width"]);
14512
14521
  }else {
@@ -14514,26 +14523,26 @@
14514
14523
  cellEl.style.width = column.component._column.definition.width + "px";
14515
14524
  }
14516
14525
  }
14517
-
14526
+
14518
14527
  if(column.component._column.parent){
14519
14528
  this.mapElementStyles(column.component._column.parent.groupElement, cellEl, ["border-top"]);
14520
14529
  }
14521
-
14530
+
14522
14531
  rowEl.appendChild(cellEl);
14523
14532
  }
14524
14533
  });
14525
-
14534
+
14526
14535
  return rowEl;
14527
14536
  }
14528
-
14537
+
14529
14538
  generateGroupElement(row, setup, styles){
14530
-
14539
+
14531
14540
  var rowEl = document.createElement("tr"),
14532
14541
  cellEl = document.createElement("td"),
14533
14542
  group = row.columns[0];
14534
-
14543
+
14535
14544
  rowEl.classList.add("tabulator-print-table-row");
14536
-
14545
+
14537
14546
  if(setup.groupHeader && setup.groupHeader[row.indent]){
14538
14547
  group.value = setup.groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);
14539
14548
  }else {
@@ -14541,39 +14550,39 @@
14541
14550
  group.value = row.component._group.generator(group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);
14542
14551
  }
14543
14552
  }
14544
-
14553
+
14545
14554
  cellEl.colSpan = group.width;
14546
14555
  cellEl.innerHTML = group.value;
14547
-
14556
+
14548
14557
  rowEl.classList.add("tabulator-print-table-group");
14549
14558
  rowEl.classList.add("tabulator-group-level-" + row.indent);
14550
-
14559
+
14551
14560
  if(group.component.isVisible()){
14552
14561
  rowEl.classList.add("tabulator-group-visible");
14553
14562
  }
14554
-
14563
+
14555
14564
  this.mapElementStyles(styles.firstGroup, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
14556
14565
  this.mapElementStyles(styles.firstGroup, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);
14557
-
14566
+
14558
14567
  rowEl.appendChild(cellEl);
14559
-
14568
+
14560
14569
  return rowEl;
14561
14570
  }
14562
-
14571
+
14563
14572
  generateCalcElement(row, setup, styles){
14564
14573
  var rowEl = this.generateRowElement(row, setup, styles);
14565
-
14574
+
14566
14575
  rowEl.classList.add("tabulator-print-table-calcs");
14567
14576
  this.mapElementStyles(styles.calcRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
14568
-
14577
+
14569
14578
  return rowEl;
14570
14579
  }
14571
-
14580
+
14572
14581
  generateRowElement(row, setup, styles){
14573
14582
  var rowEl = document.createElement("tr");
14574
-
14583
+
14575
14584
  rowEl.classList.add("tabulator-print-table-row");
14576
-
14585
+
14577
14586
  row.columns.forEach((col, i) => {
14578
14587
  if(col){
14579
14588
  var cellEl = document.createElement("td"),
@@ -14581,7 +14590,7 @@
14581
14590
  index = this.table.columnManager.findColumnIndex(column),
14582
14591
  value = col.value,
14583
14592
  cellStyle;
14584
-
14593
+
14585
14594
  var cellWrapper = {
14586
14595
  modules:{},
14587
14596
  getValue:function(){
@@ -14607,13 +14616,13 @@
14607
14616
  },
14608
14617
  column:column,
14609
14618
  };
14610
-
14619
+
14611
14620
  var classNames = column.definition.cssClass ? column.definition.cssClass.split(" ") : [];
14612
-
14621
+
14613
14622
  classNames.forEach(function(className) {
14614
14623
  cellEl.classList.add(className);
14615
14624
  });
14616
-
14625
+
14617
14626
  if(this.table.modExists("format") && this.config.formatCells !== false){
14618
14627
  value = this.table.modules.format.formatExportValue(cellWrapper, this.colVisProp);
14619
14628
  }else {
@@ -14621,29 +14630,29 @@
14621
14630
  case "object":
14622
14631
  value = value !== null ? JSON.stringify(value) : "";
14623
14632
  break;
14624
-
14633
+
14625
14634
  case "undefined":
14626
14635
  value = "";
14627
14636
  break;
14628
14637
  }
14629
14638
  }
14630
-
14639
+
14631
14640
  if(value instanceof Node){
14632
14641
  cellEl.appendChild(value);
14633
14642
  }else {
14634
14643
  cellEl.innerHTML = value;
14635
14644
  }
14636
-
14645
+
14637
14646
  cellStyle = styles.styleCells && styles.styleCells[index] ? styles.styleCells[index] : styles.firstCell;
14638
-
14647
+
14639
14648
  if(cellStyle){
14640
14649
  this.mapElementStyles(cellStyle, 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"]);
14641
-
14650
+
14642
14651
  if(column.definition.align){
14643
14652
  cellEl.style.textAlign = column.definition.align;
14644
14653
  }
14645
14654
  }
14646
-
14655
+
14647
14656
  if(this.table.options.dataTree && this.config.dataTree !== false){
14648
14657
  if((setup.treeElementField && setup.treeElementField == column.field) || (!setup.treeElementField && i == 0)){
14649
14658
  if(row.component._row.modules.dataTree.controlEl){
@@ -14654,39 +14663,43 @@
14654
14663
  }
14655
14664
  }
14656
14665
  }
14657
-
14666
+
14658
14667
  rowEl.appendChild(cellEl);
14659
-
14668
+
14660
14669
  if(cellWrapper.modules.format && cellWrapper.modules.format.renderedCallback){
14661
14670
  cellWrapper.modules.format.renderedCallback();
14662
14671
  }
14663
-
14664
- if(setup.rowFormatter && this.config.formatCells !== false){
14665
- setup.rowFormatter(row.component);
14666
- }
14667
14672
  }
14668
14673
  });
14674
+
14675
+ if(setup.rowFormatter && row.type === "row" && this.config.formatCells !== false){
14676
+ let formatComponent = Object.assign(row.component);
14669
14677
 
14678
+ formatComponent.getElement = function(){return rowEl;};
14679
+
14680
+ setup.rowFormatter(row.component);
14681
+ }
14682
+
14670
14683
  return rowEl;
14671
14684
  }
14672
-
14685
+
14673
14686
  generateHTMLTable(list){
14674
14687
  var holder = document.createElement("div");
14675
-
14688
+
14676
14689
  holder.appendChild(this.generateTableElement(list));
14677
-
14690
+
14678
14691
  return holder.innerHTML;
14679
14692
  }
14680
-
14693
+
14681
14694
  getHtml(visible, style, config, colVisProp){
14682
14695
  var list = this.generateExportList(config || this.table.options.htmlOutputConfig, style, visible, colVisProp || "htmlOutput");
14683
-
14696
+
14684
14697
  return this.generateHTMLTable(list);
14685
14698
  }
14686
-
14699
+
14687
14700
  mapElementStyles(from, to, props){
14688
14701
  if(this.cloneTableStyle && from && to){
14689
-
14702
+
14690
14703
  var lookup = {
14691
14704
  "background-color" : "backgroundColor",
14692
14705
  "color" : "fontColor",
@@ -14704,12 +14717,14 @@
14704
14717
  "padding-right" : "paddingRight",
14705
14718
  "padding-bottom" : "paddingBottom",
14706
14719
  };
14707
-
14720
+
14708
14721
  if(window.getComputedStyle){
14709
14722
  var fromStyle = window.getComputedStyle(from);
14710
-
14723
+
14711
14724
  props.forEach(function(prop){
14712
- to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);
14725
+ if(!to.style[lookup[prop]]){
14726
+ to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);
14727
+ }
14713
14728
  });
14714
14729
  }
14715
14730
  }
@@ -15007,11 +15022,6 @@
15007
15022
  var def = column.definition;
15008
15023
 
15009
15024
  if(def.headerFilter){
15010
-
15011
- if(typeof def.headerFilterPlaceholder !== "undefined" && def.field){
15012
- this.module("localize").setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder);
15013
- }
15014
-
15015
15025
  this.initializeColumn(column);
15016
15026
  }
15017
15027
  }
@@ -15123,13 +15133,17 @@
15123
15133
  var self = this,
15124
15134
  success = column.modules.filter.success,
15125
15135
  field = column.getField(),
15126
- filterElement, editor, editorElement, cellWrapper, typingTimer, searchTrigger, params;
15136
+ filterElement, editor, editorElement, cellWrapper, typingTimer, searchTrigger, params, onRenderedCallback;
15127
15137
 
15128
15138
  column.modules.filter.value = initialValue;
15129
15139
 
15130
15140
  //handle aborted edit
15131
15141
  function cancel(){}
15132
15142
 
15143
+ function onRendered(callback){
15144
+ onRenderedCallback = callback;
15145
+ }
15146
+
15133
15147
  if(column.modules.filter.headerElement && column.modules.filter.headerElement.parentNode){
15134
15148
  column.contentElement.removeChild(column.modules.filter.headerElement.parentNode);
15135
15149
  }
@@ -15214,7 +15228,7 @@
15214
15228
 
15215
15229
  params = typeof params === "function" ? params.call(self.table, cellWrapper) : params;
15216
15230
 
15217
- editorElement = editor.call(this.table.modules.edit, cellWrapper, function(){}, success, cancel, params);
15231
+ editorElement = editor.call(this.table.modules.edit, cellWrapper, onRendered, success, cancel, params);
15218
15232
 
15219
15233
  if(!editorElement){
15220
15234
  console.warn("Filter Error - Cannot add filter to " + field + " column, editor returned a value of false");
@@ -15228,7 +15242,7 @@
15228
15242
 
15229
15243
  //set Placeholder Text
15230
15244
  self.langBind("headerFilters|columns|" + column.definition.field, function(value){
15231
- editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : self.langText("headerFilters|default"));
15245
+ editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : (column.definition.headerFilterPlaceholder || self.langText("headerFilters|default")));
15232
15246
  });
15233
15247
 
15234
15248
  //focus on element on click
@@ -15310,6 +15324,10 @@
15310
15324
  if(!reinitialize){
15311
15325
  self.headerFilterColumns.push(column);
15312
15326
  }
15327
+
15328
+ if(onRenderedCallback){
15329
+ onRenderedCallback();
15330
+ }
15313
15331
  }
15314
15332
  }else {
15315
15333
  console.warn("Filter Error - Cannot add header filter, column has no field set:", column.definition.title);
@@ -17170,7 +17188,7 @@
17170
17188
  this.arrowElement = document.createElement("div");
17171
17189
  this.arrowElement.classList.add("tabulator-group-toggle");
17172
17190
  this.arrowElement.appendChild(arrow);
17173
-
17191
+
17174
17192
  //setup movable rows
17175
17193
  if(this.groupManager.table.options.movableRows !== false && this.groupManager.table.modExists("moveRow")){
17176
17194
  this.groupManager.table.modules.moveRow.initializeGroupHeader(this);
@@ -17308,19 +17326,22 @@
17308
17326
  this.parent.removeGroup(this);
17309
17327
  }else {
17310
17328
  this.groupManager.removeGroup(this);
17311
- }
17329
+ }
17312
17330
 
17313
17331
  this.groupManager.updateGroupRows(true);
17332
+
17314
17333
  }else {
17315
17334
 
17316
17335
  if(el.parentNode){
17317
17336
  el.parentNode.removeChild(el);
17318
17337
  }
17319
-
17320
- this.generateGroupHeaderContents();
17321
-
17322
- if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){
17323
- this.groupManager.table.modules.columnCalcs.recalcGroup(this);
17338
+
17339
+ if(!this.groupManager.blockRedraw){
17340
+ this.generateGroupHeaderContents();
17341
+
17342
+ if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){
17343
+ this.groupManager.table.modules.columnCalcs.recalcGroup(this);
17344
+ }
17324
17345
  }
17325
17346
 
17326
17347
  }
@@ -17705,6 +17726,8 @@
17705
17726
  this.groups = {}; //hold row groups
17706
17727
 
17707
17728
  this.displayHandler = this.getRows.bind(this);
17729
+
17730
+ this.blockRedraw = false;
17708
17731
 
17709
17732
  //register table options
17710
17733
  this.registerTableOption("groupBy", false); //enable table grouping and set field to group by
@@ -17733,6 +17756,10 @@
17733
17756
 
17734
17757
  //initialize group configuration
17735
17758
  initialize(){
17759
+ this.subscribe("table-destroy", this._blockRedrawing.bind(this));
17760
+ this.subscribe("rows-wipe", this._blockRedrawing.bind(this));
17761
+ this.subscribe("rows-wiped", this._restore_redrawing.bind(this));
17762
+
17736
17763
  if(this.table.options.groupBy){
17737
17764
  if(this.table.options.groupUpdateOnCellEdit){
17738
17765
  this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
@@ -17759,6 +17786,14 @@
17759
17786
  }
17760
17787
  }
17761
17788
 
17789
+ _blockRedrawing(){
17790
+ this.blockRedraw = true;
17791
+ }
17792
+
17793
+ _restore_redrawing(){
17794
+ this.blockRedraw = false;
17795
+ }
17796
+
17762
17797
  configureGroupSetup(){
17763
17798
  if(this.table.options.groupBy){
17764
17799
  var groupBy = this.table.options.groupBy,
@@ -18244,13 +18279,15 @@
18244
18279
 
18245
18280
  updateGroupRows(force){
18246
18281
  var output = [];
18247
-
18248
- this.groupList.forEach((group) => {
18249
- output = output.concat(group.getHeadersAndRows());
18250
- });
18251
-
18252
- if(force){
18253
- this.refreshData(true, this.displayHandler);
18282
+
18283
+ if(!this.blockRedraw){
18284
+ this.groupList.forEach((group) => {
18285
+ output = output.concat(group.getHeadersAndRows());
18286
+ });
18287
+
18288
+ if(force){
18289
+ this.refreshData(true);
18290
+ }
18254
18291
  }
18255
18292
 
18256
18293
  return output;
@@ -22666,6 +22703,8 @@
22666
22703
 
22667
22704
  this.element = false;
22668
22705
  this.manualBlock = false;
22706
+ this.beforeprintEventHandler = null;
22707
+ this.afterprintEventHandler = null;
22669
22708
 
22670
22709
  this.registerTableOption("printAsHtml", false); //enable print as html
22671
22710
  this.registerTableOption("printFormatter", false); //printing page formatter
@@ -22681,13 +22720,24 @@
22681
22720
 
22682
22721
  initialize(){
22683
22722
  if(this.table.options.printAsHtml){
22684
- window.addEventListener("beforeprint", this.replaceTable.bind(this));
22685
- window.addEventListener("afterprint", this.cleanup.bind(this));
22723
+ this.beforeprintEventHandler = this.replaceTable.bind(this);
22724
+ this.afterprintEventHandler = this.cleanup.bind(this);
22725
+
22726
+ window.addEventListener("beforeprint", this.beforeprintEventHandler );
22727
+ window.addEventListener("afterprint", this.afterprintEventHandler);
22728
+ this.subscribe("table-destroy", this.destroy.bind(this));
22686
22729
  }
22687
22730
 
22688
22731
  this.registerTableFunction("print", this.printFullscreen.bind(this));
22689
22732
  }
22690
22733
 
22734
+ destroy(){
22735
+ if(this.table.options.printAsHtml){
22736
+ window.removeEventListener( "beforeprint", this.beforeprintEventHandler );
22737
+ window.removeEventListener( "afterprint", this.afterprintEventHandler );
22738
+ }
22739
+ }
22740
+
22691
22741
  ///////////////////////////////////
22692
22742
  ///////// Table Functions /////////
22693
22743
  ///////////////////////////////////
@@ -24177,7 +24227,7 @@
24177
24227
  row.modules.select = {selected:false};
24178
24228
 
24179
24229
  //set row selection class
24180
- if(self.table.options.selectableCheck.call(this.table, row.getComponent())){
24230
+ if(self.checkRowSelectability(row)){
24181
24231
  element.classList.add("tabulator-selectable");
24182
24232
  element.classList.remove("tabulator-unselectable");
24183
24233
 
@@ -24288,10 +24338,18 @@
24288
24338
  this.lastClickedRow = row;
24289
24339
  }
24290
24340
  }
24341
+
24342
+ checkRowSelectability(row){
24343
+ if(row.type === "row"){
24344
+ return this.table.options.selectableCheck.call(this.table, row.getComponent());
24345
+ }
24346
+
24347
+ return false;
24348
+ }
24291
24349
 
24292
24350
  //toggle row selection
24293
24351
  toggleRow(row){
24294
- if(this.table.options.selectableCheck.call(this.table, row.getComponent())){
24352
+ if(this.checkRowSelectability(row)){
24295
24353
  if(row.modules.select && row.modules.select.selected){
24296
24354
  this._deselectRow(row);
24297
24355
  }else {