tabulator-tables 5.0.3 → 5.0.8

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 (57) hide show
  1. package/bower.json +1 -1
  2. package/build/rollup.js +1 -1
  3. package/dist/css/tabulator_bootstrap3.css +9 -0
  4. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  5. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  6. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  7. package/dist/css/tabulator_bulma.css +5 -1
  8. package/dist/css/tabulator_bulma.css.map +1 -1
  9. package/dist/css/tabulator_bulma.min.css +1 -1
  10. package/dist/css/tabulator_bulma.min.css.map +1 -1
  11. package/dist/css/tabulator_semanticui.css +11 -2
  12. package/dist/css/tabulator_semanticui.css.map +1 -1
  13. package/dist/css/tabulator_semanticui.min.css +1 -1
  14. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  15. package/dist/js/tabulator.js +456 -307
  16. package/dist/js/tabulator.js.map +1 -1
  17. package/dist/js/tabulator.min.js +2 -2
  18. package/dist/js/tabulator.min.js.map +1 -1
  19. package/dist/js/tabulator_esm.js +483 -354
  20. package/dist/js/tabulator_esm.js.map +1 -1
  21. package/dist/js/tabulator_esm.min.js +2 -2
  22. package/dist/js/tabulator_esm.min.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/js/core/ColumnManager.js +18 -17
  25. package/src/js/core/RowManager.js +5 -3
  26. package/src/js/core/Tabulator.js +180 -125
  27. package/src/js/core/column/Column.js +2 -2
  28. package/src/js/core/tools/{ComponentFuctionBinder.js → ComponentFunctionBinder.js} +1 -1
  29. package/src/js/core/tools/Helpers.js +19 -13
  30. package/src/js/core/tools/InteractionMonitor.js +4 -1
  31. package/src/js/core/tools/OptionsList.js +2 -2
  32. package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +22 -1
  33. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +1 -1
  34. package/src/js/modules/DataTree/DataTree.js +1 -1
  35. package/src/js/modules/Edit/Edit.js +7 -6
  36. package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
  37. package/src/js/modules/Filter/Filter.js +9 -4
  38. package/src/js/modules/Format/defaults/formatters/datetime.js +2 -2
  39. package/src/js/modules/Format/defaults/formatters/datetimediff.js +1 -1
  40. package/src/js/modules/Format/defaults/formatters/money.js +8 -1
  41. package/src/js/modules/FrozenColumns/FrozenColumns.js +21 -0
  42. package/src/js/modules/FrozenRows/FrozenRows.js +4 -1
  43. package/src/js/modules/GroupRows/Group.js +10 -4
  44. package/src/js/modules/GroupRows/GroupRows.js +41 -29
  45. package/src/js/modules/History/History.js +3 -1
  46. package/src/js/modules/History/defaults/redoers.js +1 -0
  47. package/src/js/modules/History/defaults/undoers.js +1 -0
  48. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +8 -29
  49. package/src/js/modules/MoveColumns/MoveColumns.js +64 -61
  50. package/src/js/modules/Page/Page.js +2 -1
  51. package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +5 -1
  52. package/src/js/modules/SelectRow/SelectRow.js +3 -3
  53. package/src/js/modules/Sort/Sort.js +1 -1
  54. package/src/js/modules/Sort/defaults/sorters/datetime.js +3 -2
  55. package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +9 -0
  56. package/src/scss/themes/bulma/tabulator_bulma.scss +5 -1
  57. package/src/scss/themes/semanticui/tabulator_semanticui.scss +12 -7
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.0.3 (c) Oliver Folkerd 2021 */
1
+ /* Tabulator v5.0.8 (c) Oliver Folkerd 2021 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -195,7 +195,7 @@ class Module extends CoreFeature{
195
195
  }
196
196
  }
197
197
 
198
- class Helpers$1{
198
+ class Helpers{
199
199
 
200
200
  static elVisible(el){
201
201
  return !(el.offsetWidth <= 0 && el.offsetHeight <= 0);
@@ -210,25 +210,31 @@ class Helpers$1{
210
210
  };
211
211
  }
212
212
 
213
- static deepClone(obj, clone, list = {}){
213
+ static deepClone(obj, clone, list = []){
214
+ var objectProto = {}.__proto__,
215
+ arrayProto = [].__proto__;
216
+
214
217
  if (!clone){
215
218
  clone = Object.assign(Array.isArray(obj) ? [] : {}, obj);
216
219
  }
217
220
 
218
221
  for(var i in obj) {
219
- let subject = obj[i];
220
-
221
- if(subject != null && typeof(subject) === "object"){
222
- if (subject instanceof Date) {
223
- clone[i] = new Date(subject);
224
- } else {
225
- if(list[subject]){
226
- clone[i] = list[subject];
227
- }else {
228
- list[subject] = Object.assign(Array.isArray(obj) ? [] : {}, obj);
229
- clone[i] = this.deepClone(subject, list[subject], list);
230
- }
222
+ let subject = obj[i],
223
+ match, copy;
224
+
225
+ if(subject != null && typeof subject === "object" && (subject.__proto__ === objectProto || subject.__proto__ === arrayProto)){
226
+ match = list.findIndex((item) => {
227
+ return item.subject === subject;
228
+ });
229
+
230
+ if(match > -1){
231
+ clone[i] = list[match].copy;
232
+ }else {
233
+ copy = Object.assign(Array.isArray(subject) ? [] : {}, subject);
234
+
235
+ list.unshift({subject, copy});
231
236
 
237
+ clone[i] = this.deepClone(subject, copy, list);
232
238
  }
233
239
  }
234
240
  }
@@ -320,7 +326,7 @@ class Accessor extends Module{
320
326
  rowComponent = row.getComponent();
321
327
 
322
328
  //clone data object with deep copy to isolate internal data from returned result
323
- var data = Helpers$1.deepClone(row.data || {});
329
+ var data = Helpers.deepClone(row.data || {});
324
330
 
325
331
  this.table.columnManager.traverse(function(column){
326
332
  var value, accessor, params, colCompnent;
@@ -486,6 +492,26 @@ function defaultLoaderPromise(url, config, params){
486
492
  });
487
493
  }
488
494
 
495
+ function generateParamsList$1(data, prefix){
496
+ var output = [];
497
+
498
+ prefix = prefix || "";
499
+
500
+ if(Array.isArray(data)){
501
+ data.forEach((item, i) => {
502
+ output = output.concat(generateParamsList$1(item, prefix ? prefix + "[" + i + "]" : i));
503
+ });
504
+ }else if (typeof data === "object"){
505
+ for (var key in data){
506
+ output = output.concat(generateParamsList$1(data[key], prefix ? prefix + "[" + key + "]" : key));
507
+ }
508
+ }else {
509
+ output.push({key:prefix, value:data});
510
+ }
511
+
512
+ return output;
513
+ }
514
+
489
515
  var defaultContentTypeFormatters = {
490
516
  "json":{
491
517
  headers:{
@@ -499,7 +525,8 @@ var defaultContentTypeFormatters = {
499
525
  headers:{
500
526
  },
501
527
  body:function(url, config, params){
502
- var output = this.generateParamsList(params),
528
+
529
+ var output = generateParamsList$1(params),
503
530
  form = new FormData();
504
531
 
505
532
  output.forEach(function(item){
@@ -1153,7 +1180,7 @@ class CellComponent {
1153
1180
  }
1154
1181
  }
1155
1182
 
1156
- class Cell$1 extends CoreFeature{
1183
+ class Cell extends CoreFeature{
1157
1184
  constructor(column, row){
1158
1185
  super(column.table);
1159
1186
 
@@ -1621,7 +1648,7 @@ class ColumnComponent {
1621
1648
  }
1622
1649
  }
1623
1650
 
1624
- var defaultOptions = {
1651
+ var defaultColumnOptions = {
1625
1652
  "title": undefined,
1626
1653
  "field": undefined,
1627
1654
  "columns": undefined,
@@ -2303,7 +2330,7 @@ class Column$1 extends CoreFeature{
2303
2330
  this.reinitializeWidth();
2304
2331
  }
2305
2332
 
2306
- this.table.columnManager._verticalAlignHeaders();
2333
+ this.table.columnManager.verticalAlignHeaders();
2307
2334
 
2308
2335
  this.dispatch("column-show", this, responsiveToggle);
2309
2336
 
@@ -2328,7 +2355,7 @@ class Column$1 extends CoreFeature{
2328
2355
 
2329
2356
  this.element.style.display = "none";
2330
2357
 
2331
- this.table.columnManager._verticalAlignHeaders();
2358
+ this.table.columnManager.verticalAlignHeaders();
2332
2359
 
2333
2360
  if(this.parent.isGroup){
2334
2361
  this.parent.checkColumnVisibility();
@@ -2530,7 +2557,7 @@ class Column$1 extends CoreFeature{
2530
2557
  //////////////// Cell Management /////////////////
2531
2558
  //generate cell for this column
2532
2559
  generateCell(row){
2533
- var cell = new Cell$1(this, row);
2560
+ var cell = new Cell(this, row);
2534
2561
 
2535
2562
  this.cells.push(cell);
2536
2563
 
@@ -2652,7 +2679,7 @@ class Column$1 extends CoreFeature{
2652
2679
  }
2653
2680
  }
2654
2681
 
2655
- Column$1.defaultOptionList = defaultOptions;
2682
+ Column$1.defaultOptionList = defaultColumnOptions;
2656
2683
 
2657
2684
  //public row object
2658
2685
  class RowComponent$1 {
@@ -2745,7 +2772,7 @@ class RowComponent$1 {
2745
2772
  }
2746
2773
  }
2747
2774
 
2748
- class Row$1 extends CoreFeature{
2775
+ class Row extends CoreFeature{
2749
2776
  constructor (data, parent, type = "row"){
2750
2777
  super(parent.table);
2751
2778
 
@@ -2960,7 +2987,7 @@ class Row$1 extends CoreFeature{
2960
2987
 
2961
2988
  //update the rows data
2962
2989
  updateData(updatedData){
2963
- var visible = this.element && Helpers$1.elVisible(this.element),
2990
+ var visible = this.element && Helpers.elVisible(this.element),
2964
2991
  tempData = {},
2965
2992
  newRowData;
2966
2993
 
@@ -3587,7 +3614,7 @@ class ColumnCalcs extends Module{
3587
3614
  this.table.modules.mutator.disable();
3588
3615
  }
3589
3616
 
3590
- row = new Row$1(rowData, this, "calc");
3617
+ row = new Row(rowData, this, "calc");
3591
3618
 
3592
3619
  if(this.table.modExists("mutator")){
3593
3620
  this.table.modules.mutator.enable();
@@ -3599,7 +3626,7 @@ class ColumnCalcs extends Module{
3599
3626
 
3600
3627
  row.getComponent = () => {
3601
3628
  if(!row.component){
3602
- row.component = new CalcComponent(this);
3629
+ row.component = new CalcComponent(row);
3603
3630
  }
3604
3631
 
3605
3632
  return row.component;
@@ -3631,7 +3658,7 @@ class ColumnCalcs extends Module{
3631
3658
  this.genColumn.definition.cssClass = column.definition.cssClass;
3632
3659
 
3633
3660
  //generate cell and assign to correct column
3634
- var cell = new Cell$1(this.genColumn, row);
3661
+ var cell = new Cell(this.genColumn, row);
3635
3662
  cell.getElement();
3636
3663
  cell.column = column;
3637
3664
  cell.setWidth();
@@ -4014,7 +4041,7 @@ class DataTree extends Module{
4014
4041
 
4015
4042
  output.push(row);
4016
4043
 
4017
- if(row instanceof Row$1){
4044
+ if(row instanceof Row){
4018
4045
 
4019
4046
  row.create();
4020
4047
 
@@ -4078,7 +4105,7 @@ class DataTree extends Module{
4078
4105
  }
4079
4106
 
4080
4107
  childArray.forEach((childData) => {
4081
- var childRow = new Row$1(childData || {}, this.table.rowManager);
4108
+ var childRow = new Row(childData || {}, this.table.rowManager);
4082
4109
 
4083
4110
  childRow.create();
4084
4111
 
@@ -4155,7 +4182,7 @@ class DataTree extends Module{
4155
4182
  }
4156
4183
 
4157
4184
  children.forEach((childRow) => {
4158
- if(childRow instanceof Row$1){
4185
+ if(childRow instanceof Row){
4159
4186
  output.push(childRow);
4160
4187
  }
4161
4188
  });
@@ -4226,7 +4253,7 @@ class DataTree extends Module{
4226
4253
 
4227
4254
  if(typeof subject == "object"){
4228
4255
 
4229
- if(subject instanceof Row$1){
4256
+ if(subject instanceof Row){
4230
4257
  //subject is row element
4231
4258
  match = subject.data;
4232
4259
  }else if(subject instanceof RowComponent){
@@ -4235,7 +4262,7 @@ class DataTree extends Module{
4235
4262
  }else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){
4236
4263
  if(parent.modules.dataTree){
4237
4264
  match = parent.modules.dataTree.children.find((childRow) => {
4238
- return childRow instanceof Row$1 ? childRow.element === subject : false;
4265
+ return childRow instanceof Row ? childRow.element === subject : false;
4239
4266
  });
4240
4267
 
4241
4268
  if(match){
@@ -4280,7 +4307,7 @@ class DataTree extends Module{
4280
4307
  }
4281
4308
 
4282
4309
  config.children.forEach((childRow) => {
4283
- if(childRow instanceof Row$1){
4310
+ if(childRow instanceof Row){
4284
4311
  output.push(component ? childRow.getComponent() : childRow);
4285
4312
 
4286
4313
  if(recurse){
@@ -4295,7 +4322,7 @@ class DataTree extends Module{
4295
4322
 
4296
4323
  checkForRestyle(cell){
4297
4324
  if(!cell.row.cells.indexOf(cell)){
4298
- cell.row.reinitialize();
4325
+ this.layoutRow(cell.row);
4299
4326
  }
4300
4327
  }
4301
4328
 
@@ -5603,7 +5630,7 @@ function select(cell, onRendered, success, cancel, editorParams){
5603
5630
  }
5604
5631
 
5605
5632
 
5606
- var offset = Helpers$1.elOffset(cellEl);
5633
+ var offset = Helpers.elOffset(cellEl);
5607
5634
 
5608
5635
  listEl.style.minWidth = cellEl.offsetWidth + "px";
5609
5636
 
@@ -6080,7 +6107,7 @@ function autocomplete(cell, onRendered, success, cancel, editorParams){
6080
6107
  if(!listEl.parentNode){
6081
6108
  while(listEl.firstChild) listEl.removeChild(listEl.firstChild);
6082
6109
 
6083
- var offset = Helpers$1.elOffset(cellEl);
6110
+ var offset = Helpers.elOffset(cellEl);
6084
6111
 
6085
6112
  listEl.style.minWidth = cellEl.offsetWidth + "px";
6086
6113
 
@@ -6395,8 +6422,8 @@ function star(cell, onRendered, success, cancel, editorParams){
6395
6422
  //draggable progress bar
6396
6423
  function progress(cell, onRendered, success, cancel, editorParams){
6397
6424
  var element = cell.getElement(),
6398
- max = typeof editorParams.max === "undefined" ? ( element.getElementsByTagName("div")[0].getAttribute("max") || 100) : editorParams.max,
6399
- min = typeof editorParams.min === "undefined" ? ( element.getElementsByTagName("div")[0].getAttribute("min") || 0) : editorParams.min,
6425
+ max = typeof editorParams.max === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("max")) || 100) : editorParams.max,
6426
+ min = typeof editorParams.min === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("min")) || 0) : editorParams.min,
6400
6427
  percent = (max - min) / 100,
6401
6428
  value = cell.getValue() || 0,
6402
6429
  handle = document.createElement("div"),
@@ -6768,7 +6795,7 @@ class Edit extends Module{
6768
6795
  nextCell = this.findNextEditableCell(prevRow, prevRow.cells.length);
6769
6796
 
6770
6797
  if(nextCell){
6771
- nextCell.edit();
6798
+ nextCell.getComponent().edit();
6772
6799
  return true;
6773
6800
  }
6774
6801
  }
@@ -6799,7 +6826,7 @@ class Edit extends Module{
6799
6826
  nextCell = this.findNextEditableCell(nextRow, -1);
6800
6827
 
6801
6828
  if(nextCell){
6802
- nextCell.edit();
6829
+ nextCell.getComponent().edit();
6803
6830
  return true;
6804
6831
  }
6805
6832
  }
@@ -6823,7 +6850,7 @@ class Edit extends Module{
6823
6850
  nextCell = this.findPrevEditableCell(cell.row, index);
6824
6851
 
6825
6852
  if(nextCell){
6826
- nextCell.edit();
6853
+ nextCell.getComponent().edit();
6827
6854
  return true;
6828
6855
  }
6829
6856
  }
@@ -6845,7 +6872,7 @@ class Edit extends Module{
6845
6872
  nextCell = this.findNextEditableCell(cell.row, index);
6846
6873
 
6847
6874
  if(nextCell){
6848
- nextCell.edit();
6875
+ nextCell.getComponent().edit();
6849
6876
  return true;
6850
6877
  }
6851
6878
  }
@@ -6867,7 +6894,7 @@ class Edit extends Module{
6867
6894
  nextRow = this.table.rowManager.prevDisplayRow(cell.row, true);
6868
6895
 
6869
6896
  if(nextRow){
6870
- nextRow.cells[index].edit();
6897
+ nextRow.cells[index].getComponent().edit();
6871
6898
  return true;
6872
6899
  }
6873
6900
  }
@@ -6889,7 +6916,7 @@ class Edit extends Module{
6889
6916
  nextRow = this.table.rowManager.nextDisplayRow(cell.row, true);
6890
6917
 
6891
6918
  if(nextRow){
6892
- nextRow.cells[index].edit();
6919
+ nextRow.cells[index].getComponent().edit();
6893
6920
  return true;
6894
6921
  }
6895
6922
  }
@@ -8091,6 +8118,7 @@ class Filter extends Module{
8091
8118
  this.prevHeaderFilterChangeCheck = "{}";
8092
8119
 
8093
8120
  this.changed = false; //has filtering changed since last render
8121
+ this.tableInitialized = false;
8094
8122
 
8095
8123
  this.registerTableOption("filterMode", "local"); //local or remote filtering
8096
8124
 
@@ -8158,6 +8186,8 @@ class Filter extends Module{
8158
8186
  }
8159
8187
  });
8160
8188
  }
8189
+
8190
+ this.tableInitialized = true;
8161
8191
  }
8162
8192
 
8163
8193
  remoteFilterParams(data, config, silent, params){
@@ -8621,10 +8651,12 @@ class Filter extends Module{
8621
8651
  }
8622
8652
 
8623
8653
  refreshFilter(){
8624
- if(this.table.options.filterMode === "remote"){
8625
- this.reloadData();
8626
- }else {
8627
- this.refreshData();
8654
+ if(this.tableInitialized){
8655
+ if(this.table.options.filterMode === "remote"){
8656
+ this.reloadData();
8657
+ }else {
8658
+ this.refreshData(true);
8659
+ }
8628
8660
  }
8629
8661
 
8630
8662
  //TODO - Persist left position of row manager
@@ -8968,10 +9000,12 @@ function textarea$1(cell, formatterParams, onRendered){
8968
9000
 
8969
9001
  function money(cell, formatterParams, onRendered){
8970
9002
  var floatVal = parseFloat(cell.getValue()),
9003
+ sign = "",
8971
9004
  number, integer, decimal, rgx;
8972
9005
 
8973
9006
  var decimalSym = formatterParams.decimal || ".";
8974
9007
  var thousandSym = formatterParams.thousand || ",";
9008
+ var negativeSign = formatterParams.negativeSign || "-";
8975
9009
  var symbol = formatterParams.symbol || "";
8976
9010
  var after = !!formatterParams.symbolAfter;
8977
9011
  var precision = typeof formatterParams.precision !== "undefined" ? formatterParams.precision : 2;
@@ -8980,6 +9014,11 @@ function money(cell, formatterParams, onRendered){
8980
9014
  return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));
8981
9015
  }
8982
9016
 
9017
+ if(floatVal < 0){
9018
+ floatVal = Math.abs(floatVal);
9019
+ sign = negativeSign;
9020
+ }
9021
+
8983
9022
  number = precision !== false ? floatVal.toFixed(precision) : floatVal;
8984
9023
  number = String(number).split(".");
8985
9024
 
@@ -8992,7 +9031,7 @@ function money(cell, formatterParams, onRendered){
8992
9031
  integer = integer.replace(rgx, "$1" + thousandSym + "$2");
8993
9032
  }
8994
9033
 
8995
- return after ? integer + decimal + symbol : symbol + integer + decimal;
9034
+ return after ? sign + integer + decimal + symbol : sign + symbol + integer + decimal;
8996
9035
  }
8997
9036
 
8998
9037
  function link(cell, formatterParams, onRendered){
@@ -9134,7 +9173,7 @@ function datetime(cell, formatterParams, onRendered){
9134
9173
  var value = cell.getValue();
9135
9174
 
9136
9175
  if(typeof DT != "undefined"){
9137
- var newDatetime = (window.DateTime || luxon.DateTime).fromFormat(value, inputFormat);
9176
+ var newDatetime = DT.fromFormat(String(value), inputFormat);
9138
9177
 
9139
9178
  if(newDatetime.isValid){
9140
9179
 
@@ -9145,7 +9184,7 @@ function datetime(cell, formatterParams, onRendered){
9145
9184
  return newDatetime.toFormat(outputFormat);
9146
9185
  }else {
9147
9186
 
9148
- if(invalid === true){
9187
+ if(invalid === true || !value){
9149
9188
  return value;
9150
9189
  }else if(typeof invalid === "function"){
9151
9190
  return invalid(value);
@@ -9169,7 +9208,7 @@ function datetimediff (cell, formatterParams, onRendered) {
9169
9208
  var value = cell.getValue();
9170
9209
 
9171
9210
  if(typeof DT != "undefined"){
9172
- var newDatetime = DT.fromFormat(value, inputFormat);
9211
+ var newDatetime = DT.fromFormat(String(value), inputFormat);
9173
9212
 
9174
9213
  if (newDatetime.isValid){
9175
9214
  if(humanize);else {
@@ -9879,12 +9918,33 @@ class FrozenColumns extends Module{
9879
9918
  if(this.table.modules.columnCalcs.topInitialized && this.table.modules.columnCalcs.topRow){
9880
9919
  this.layoutRow(this.table.modules.columnCalcs.topRow);
9881
9920
  }
9921
+
9882
9922
  if(this.table.modules.columnCalcs.botInitialized && this.table.modules.columnCalcs.botRow){
9883
9923
  this.layoutRow(this.table.modules.columnCalcs.botRow);
9884
9924
  }
9925
+
9926
+ if(this.table.modExists("groupRows")){
9927
+ this.layoutGroupCalcs(this.table.modules.groupRows.getGroups());
9928
+ }
9885
9929
  }
9886
9930
  }
9887
9931
 
9932
+ layoutGroupCalcs(groups){
9933
+ groups.forEach((group) => {
9934
+ if(group.calcs.top){
9935
+ this.layoutRow(group.calcs.top);
9936
+ }
9937
+
9938
+ if(group.calcs.bottom){
9939
+ this.layoutRow(group.calcs.bottom);
9940
+ }
9941
+
9942
+ if(group.groupList && group.groupList.length){
9943
+ this.layoutGroupCalcs(group.groupList && group.groupList);
9944
+ }
9945
+ });
9946
+ }
9947
+
9888
9948
  //calculate column positions and layout headers
9889
9949
  layoutColumnPosition(allCells){
9890
9950
 
@@ -10119,7 +10179,10 @@ class FrozenRows extends Module{
10119
10179
 
10120
10180
  if(index > -1){
10121
10181
  var rowEl = row.getElement();
10122
- rowEl.parentNode.removeChild(rowEl);
10182
+
10183
+ if(rowEl.parentNode){
10184
+ rowEl.parentNode.removeChild(rowEl);
10185
+ }
10123
10186
 
10124
10187
  this.rows.splice(index, 1);
10125
10188
  }
@@ -10242,10 +10305,16 @@ class Group{
10242
10305
  group.wipe();
10243
10306
  });
10244
10307
  }else {
10245
- this.element = false;
10246
- this.arrowElement = false;
10247
- this.elementContents = false;
10308
+ this.rows.forEach((row) => {
10309
+ if(row.modules){
10310
+ delete row.modules.group;
10311
+ }
10312
+ });
10248
10313
  }
10314
+
10315
+ this.element = false;
10316
+ this.arrowElement = false;
10317
+ this.elementContents = false;
10249
10318
  }
10250
10319
 
10251
10320
  createElements(){
@@ -10467,7 +10536,7 @@ class Group{
10467
10536
  }
10468
10537
 
10469
10538
  this.generateGroupHeaderContents();
10470
-
10539
+
10471
10540
  if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){
10472
10541
  this.groupManager.table.modules.columnCalcs.recalcGroup(this);
10473
10542
  }
@@ -10808,7 +10877,7 @@ class Group{
10808
10877
  this.initialized = false;
10809
10878
  this.height = 0;
10810
10879
 
10811
- if(Helpers$1.elVisible(this.element)){
10880
+ if(Helpers.elVisible(this.element)){
10812
10881
  this.initialize(true);
10813
10882
  }
10814
10883
  }
@@ -10891,6 +10960,34 @@ class GroupRows extends Module{
10891
10960
 
10892
10961
  //initialize group configuration
10893
10962
  initialize(){
10963
+ if(this.table.options.groupBy){
10964
+
10965
+ this.configureGroupSetup();
10966
+
10967
+ if(this.table.options.groupUpdateOnCellEdit){
10968
+ this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
10969
+ this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);
10970
+ }
10971
+
10972
+ this.subscribe("row-deleting", this.rowDeleting.bind(this));
10973
+ this.subscribe("row-deleted", this.rowsUpdated.bind(this));
10974
+ this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));
10975
+ this.subscribe("rows-wipe", this.wipe.bind(this));
10976
+ this.subscribe("rows-added", this.rowsUpdated.bind(this));
10977
+ this.subscribe("row-moving", this.rowMoving.bind(this));
10978
+ this.subscribe("row-adding-index", this.rowAddingIndex.bind(this));
10979
+
10980
+ this.subscribe("rows-sample", this.rowSample.bind(this));
10981
+
10982
+ this.subscribe("render-virtual-fill", this.virtualRenderFill.bind(this));
10983
+
10984
+ this.registerDisplayHandler(this.displayHandler, 20);
10985
+
10986
+ this.initialized = true;
10987
+ }
10988
+ }
10989
+
10990
+ configureGroupSetup(){
10894
10991
  if(this.table.options.groupBy){
10895
10992
  var groupBy = this.table.options.groupBy,
10896
10993
  startOpen = this.table.options.groupStartOpen,
@@ -10978,27 +11075,6 @@ class GroupRows extends Module{
10978
11075
  if(groupHeader){
10979
11076
  this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader];
10980
11077
  }
10981
-
10982
- if(this.table.options.groupUpdateOnCellEdit){
10983
- this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
10984
- this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);
10985
- }
10986
-
10987
- this.subscribe("row-deleting", this.rowDeleting.bind(this));
10988
- this.subscribe("row-deleted", this.rowsUpdated.bind(this));
10989
- this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));
10990
- this.subscribe("rows-wipe", this.wipe.bind(this));
10991
- this.subscribe("rows-added", this.rowsUpdated.bind(this));
10992
- this.subscribe("row-moving", this.rowMoving.bind(this));
10993
- this.subscribe("row-adding-index", this.rowAddingIndex.bind(this));
10994
-
10995
- this.subscribe("rows-sample", this.rowSample.bind(this));
10996
-
10997
- this.subscribe("render-virtual-fill", this.virtualRenderFill.bind(this));
10998
-
10999
- this.registerDisplayHandler(this.displayHandler, 20);
11000
-
11001
- this.initialized = true;
11002
11078
  }
11003
11079
  }
11004
11080
 
@@ -11063,23 +11139,28 @@ class GroupRows extends Module{
11063
11139
 
11064
11140
  setGroupBy(groups){
11065
11141
  this.table.options.groupBy = groups;
11066
- this.initialize();
11067
- this.refreshData(false, "display");
11142
+ if(!this.initialized){
11143
+ this.initialize();
11144
+ }else {
11145
+ this.configureGroupSetup();
11146
+ }
11147
+
11148
+ this.refreshData();
11068
11149
 
11069
11150
  this.trackChanges();
11070
11151
  }
11071
11152
 
11072
11153
  setGroupValues(groupValues){
11073
11154
  this.table.options.groupValues = groupValues;
11074
- this.initialize();
11075
- this.refreshData(false, "display");
11155
+ this.configureGroupSetup();
11156
+ this.refreshData();
11076
11157
 
11077
11158
  this.trackChanges();
11078
11159
  }
11079
11160
 
11080
11161
  setGroupStartOpen(values){
11081
11162
  this.table.options.groupStartOpen = values;
11082
- this.initialize();
11163
+ this.configureGroupSetup();
11083
11164
 
11084
11165
  if(this.table.options.groupBy){
11085
11166
  this.refreshData();
@@ -11092,7 +11173,7 @@ class GroupRows extends Module{
11092
11173
 
11093
11174
  setGroupHeader(values){
11094
11175
  this.table.options.groupHeader = values;
11095
- this.initialize();
11176
+ this.configureGroupSetup();
11096
11177
 
11097
11178
  if(this.table.options.groupBy){
11098
11179
  this.refreshData();
@@ -11173,7 +11254,7 @@ class GroupRows extends Module{
11173
11254
 
11174
11255
  //return appropriate rows with group headers
11175
11256
  getRows(rows){
11176
- if(this.groupIDLookups.length){
11257
+ if(this.table.options.groupBy && this.groupIDLookups.length){
11177
11258
 
11178
11259
  this.dispatchExternal("dataGrouping");
11179
11260
 
@@ -11288,7 +11369,7 @@ class GroupRows extends Module{
11288
11369
  var oldGroups = this.groups;
11289
11370
 
11290
11371
  this.groups = {};
11291
- this.groupList =[];
11372
+ this.groupList = [];
11292
11373
 
11293
11374
  if(this.allowedValues && this.allowedValues[0]){
11294
11375
  this.allowedValues[0].forEach((value) => {
@@ -11417,6 +11498,7 @@ GroupRows.moduleName = "groupRows";
11417
11498
  var defaultUndoers = {
11418
11499
  cellEdit: function(action){
11419
11500
  action.component.setValueProcessData(action.data.oldValue);
11501
+ action.component.cellRendered();
11420
11502
  },
11421
11503
 
11422
11504
  rowAdd: function(action){
@@ -11442,6 +11524,7 @@ var defaultUndoers = {
11442
11524
  var defaultRedoers = {
11443
11525
  cellEdit: function(action){
11444
11526
  action.component.setValueProcessData(action.data.newValue);
11527
+ action.component.cellRendered();
11445
11528
  },
11446
11529
 
11447
11530
  rowAdd: function(action){
@@ -11519,7 +11602,7 @@ class History extends Module{
11519
11602
  }
11520
11603
  }
11521
11604
 
11522
- this.history.action("rowDelete", row, {data:row.getData(), pos:!index, index:index});
11605
+ this.action("rowDelete", row, {data:row.getData(), pos:!index, index:index});
11523
11606
  }
11524
11607
 
11525
11608
  cellUpdated(cell){
@@ -11638,17 +11721,17 @@ class HtmlTableImport extends Module{
11638
11721
  }
11639
11722
 
11640
11723
  initialize(){
11641
- this.subscribe("table-building", this.tableElementCheck.bind(this));
11724
+ this.tableElementCheck();
11642
11725
  }
11643
11726
 
11644
11727
  tableElementCheck(){
11645
- if(this.table.element.tagName === "TABLE"){
11728
+ if(this.table.originalElement && this.table.originalElement.tagName === "TABLE"){
11646
11729
  this.parseTable();
11647
11730
  }
11648
11731
  }
11649
11732
 
11650
11733
  parseTable(){
11651
- var element = this.table.element,
11734
+ var element = this.table.originalElement,
11652
11735
  options = this.table.options,
11653
11736
  columns = options.columns,
11654
11737
  headers = element.getElementsByTagName("th"),
@@ -11661,7 +11744,7 @@ class HtmlTableImport extends Module{
11661
11744
 
11662
11745
  rows = rows ? rows.getElementsByTagName("tr") : [];
11663
11746
 
11664
- //check for tablator inline options
11747
+ //check for Tabulator inline options
11665
11748
  this._extractOptions(element, options);
11666
11749
 
11667
11750
  if(headers.length){
@@ -11692,34 +11775,15 @@ class HtmlTableImport extends Module{
11692
11775
  data.push(item);
11693
11776
  }
11694
11777
 
11695
- //create new element
11696
- var newElement = document.createElement("div");
11697
-
11698
- //transfer attributes to new element
11699
- var attributes = element.attributes;
11700
-
11701
- // loop through attributes and apply them on div
11702
-
11703
- for(var i in attributes){
11704
- if(typeof attributes[i] == "object"){
11705
- newElement.setAttribute(attributes[i].name, attributes[i].value);
11706
- }
11707
- }
11708
-
11709
- // replace table with div element
11710
- element.parentNode.replaceChild(newElement, element);
11711
-
11712
11778
  options.data = data;
11713
11779
 
11714
11780
  this.dispatchExternal("htmlImported");
11715
-
11716
- this.table.element = newElement;
11717
11781
  }
11718
11782
 
11719
11783
  //extract tabulator attribute options
11720
11784
  _extractOptions(element, options, defaultOptions){
11721
11785
  var attributes = element.attributes;
11722
- var optionsArr = defaultOptions ? Object.assign([], defaultOptions) : Object.keys(options);
11786
+ var optionsArr = defaultOptions ? Object.keys(defaultOptions) : Object.keys(options);
11723
11787
  var optionsList = {};
11724
11788
 
11725
11789
  optionsArr.forEach((item) => {
@@ -11786,11 +11850,8 @@ class HtmlTableImport extends Module{
11786
11850
  col.width = width;
11787
11851
  }
11788
11852
 
11789
- //check for tablator inline options
11790
- header.attributes;
11791
-
11792
- // //check for tablator inline options
11793
- this._extractOptions(header, col, Column.prototype.defaultOptionList);
11853
+ //check for Tabulator inline options
11854
+ this._extractOptions(header, col, this.table.columnManager.optionsList.registeredDefaults);
11794
11855
 
11795
11856
  this.fieldIndex[index] = col.field;
11796
11857
 
@@ -12110,7 +12171,7 @@ class Interaction extends Module{
12110
12171
 
12111
12172
  if(this.columnSubscribers[action]){
12112
12173
 
12113
- if(component instanceof Cell$1){
12174
+ if(component instanceof Cell){
12114
12175
  callback = component.column.definition[action];
12115
12176
  }else if(component instanceof Column$1){
12116
12177
  callback = component.definition[action];
@@ -12696,7 +12757,7 @@ class Menu extends Module{
12696
12757
 
12697
12758
  this.positionReversedX = false;
12698
12759
  }else {
12699
- parentOffset = Helpers$1.elOffset(parentEl);
12760
+ parentOffset = Helpers.elOffset(parentEl);
12700
12761
  x = parentOffset.left + parentEl.offsetWidth;
12701
12762
  y = parentOffset.top - 1;
12702
12763
  }
@@ -12767,10 +12828,10 @@ class Menu extends Module{
12767
12828
  Menu.moduleName = "menu";
12768
12829
 
12769
12830
  class MoveColumns extends Module{
12770
-
12831
+
12771
12832
  constructor(table){
12772
12833
  super(table);
12773
-
12834
+
12774
12835
  this.placeholderElement = this.createPlaceholderElement();
12775
12836
  this.hoverElement = false; //floating column header element
12776
12837
  this.checkTimeout = false; //click check timeout holder
@@ -12783,38 +12844,39 @@ class MoveColumns extends Module{
12783
12844
  this.autoScrollStep = 5; //auto scroll distance in pixels
12784
12845
  this.autoScrollTimeout = false; //auto scroll timeout
12785
12846
  this.touchMove = false;
12786
-
12847
+
12787
12848
  this.moveHover = this.moveHover.bind(this);
12788
12849
  this.endMove = this.endMove.bind(this);
12789
-
12850
+
12790
12851
  this.registerTableOption("movableColumns", false); //enable movable columns
12791
12852
  }
12792
-
12853
+
12793
12854
  createPlaceholderElement(){
12794
12855
  var el = document.createElement("div");
12795
-
12856
+
12796
12857
  el.classList.add("tabulator-col");
12797
12858
  el.classList.add("tabulator-col-placeholder");
12798
-
12859
+
12799
12860
  return el;
12800
12861
  }
12801
-
12862
+
12802
12863
  initialize(){
12803
- this.subscribe("column-init", this.initializeColumn.bind(this));
12864
+ if(this.table.options.movableColumns){
12865
+ this.subscribe("column-init", this.initializeColumn.bind(this));
12866
+ }
12804
12867
  }
12805
-
12868
+
12806
12869
  initializeColumn(column){
12807
12870
  var self = this,
12808
12871
  config = {},
12809
12872
  colEl;
12810
-
12873
+
12811
12874
  if(!column.modules.frozen){
12812
-
12813
12875
  colEl = column.getElement();
12814
-
12876
+
12815
12877
  config.mousemove = function(e){
12816
12878
  if(column.parent === self.moving.parent){
12817
- if((((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(colEl).left) + self.table.columnManager.element.scrollLeft) > (column.getWidth() / 2)){
12879
+ if((((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(colEl).left) + self.table.columnManager.element.scrollLeft) > (column.getWidth() / 2)){
12818
12880
  if(self.toCol !== column || !self.toColAfter){
12819
12881
  colEl.parentNode.insertBefore(self.placeholderElement, colEl.nextSibling);
12820
12882
  self.moveColumn(column, true);
@@ -12827,7 +12889,7 @@ class MoveColumns extends Module{
12827
12889
  }
12828
12890
  }
12829
12891
  }.bind(self);
12830
-
12892
+
12831
12893
  colEl.addEventListener("mousedown", function(e){
12832
12894
  self.touchMove = false;
12833
12895
  if(e.which === 1){
@@ -12836,7 +12898,7 @@ class MoveColumns extends Module{
12836
12898
  }, self.checkPeriod);
12837
12899
  }
12838
12900
  });
12839
-
12901
+
12840
12902
  colEl.addEventListener("mouseup", function(e){
12841
12903
  if(e.which === 1){
12842
12904
  if(self.checkTimeout){
@@ -12844,18 +12906,18 @@ class MoveColumns extends Module{
12844
12906
  }
12845
12907
  }
12846
12908
  });
12847
-
12909
+
12848
12910
  self.bindTouchEvents(column);
12849
12911
  }
12850
-
12912
+
12851
12913
  column.modules.moveColumn = config;
12852
12914
  }
12853
-
12915
+
12854
12916
  bindTouchEvents(column){
12855
12917
  var colEl = column.getElement(),
12856
12918
  startXMove = false, //shifting center position of the cell
12857
12919
  nextCol, prevCol, nextColWidth, prevColWidth, nextColWidthLast, prevColWidthLast;
12858
-
12920
+
12859
12921
  colEl.addEventListener("touchstart", (e) => {
12860
12922
  this.checkTimeout = setTimeout(() => {
12861
12923
  this.touchMove = true;
@@ -12866,27 +12928,27 @@ class MoveColumns extends Module{
12866
12928
  nextColWidthLast = 0;
12867
12929
  prevColWidthLast = 0;
12868
12930
  startXMove = false;
12869
-
12931
+
12870
12932
  this.startMove(e, column);
12871
12933
  }, this.checkPeriod);
12872
12934
  }, {passive: true});
12873
-
12935
+
12874
12936
  colEl.addEventListener("touchmove", (e) => {
12875
12937
  var diff, moveToCol;
12876
-
12938
+
12877
12939
  if(this.moving){
12878
12940
  this.moveHover(e);
12879
-
12941
+
12880
12942
  if(!startXMove){
12881
12943
  startXMove = e.touches[0].pageX;
12882
12944
  }
12883
-
12945
+
12884
12946
  diff = e.touches[0].pageX - startXMove;
12885
-
12947
+
12886
12948
  if(diff > 0){
12887
12949
  if(nextCol && diff - nextColWidthLast > nextColWidth){
12888
12950
  moveToCol = nextCol;
12889
-
12951
+
12890
12952
  if(moveToCol !== column){
12891
12953
  startXMove = e.touches[0].pageX;
12892
12954
  moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement().nextSibling);
@@ -12896,7 +12958,7 @@ class MoveColumns extends Module{
12896
12958
  }else {
12897
12959
  if(prevCol && -diff - prevColWidthLast > prevColWidth){
12898
12960
  moveToCol = prevCol;
12899
-
12961
+
12900
12962
  if(moveToCol !== column){
12901
12963
  startXMove = e.touches[0].pageX;
12902
12964
  moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement());
@@ -12904,7 +12966,7 @@ class MoveColumns extends Module{
12904
12966
  }
12905
12967
  }
12906
12968
  }
12907
-
12969
+
12908
12970
  if(moveToCol){
12909
12971
  nextCol = moveToCol.nextColumn();
12910
12972
  nextColWidthLast = nextColWidth;
@@ -12915,7 +12977,7 @@ class MoveColumns extends Module{
12915
12977
  }
12916
12978
  }
12917
12979
  }, {passive: true});
12918
-
12980
+
12919
12981
  colEl.addEventListener("touchend", (e) => {
12920
12982
  if(this.checkTimeout){
12921
12983
  clearTimeout(this.checkTimeout);
@@ -12925,41 +12987,43 @@ class MoveColumns extends Module{
12925
12987
  }
12926
12988
  });
12927
12989
  }
12928
-
12990
+
12929
12991
  startMove(e, column){
12930
- var element = column.getElement();
12931
-
12992
+ var element = column.getElement(),
12993
+ headerElement = this.table.columnManager.getElement(),
12994
+ headersElement = this.table.columnManager.getHeadersElement();
12995
+
12932
12996
  this.moving = column;
12933
- this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(element).left;
12934
-
12997
+ this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;
12998
+
12935
12999
  this.table.element.classList.add("tabulator-block-select");
12936
-
13000
+
12937
13001
  //create placeholder
12938
13002
  this.placeholderElement.style.width = column.getWidth() + "px";
12939
13003
  this.placeholderElement.style.height = column.getHeight() + "px";
12940
-
13004
+
12941
13005
  element.parentNode.insertBefore(this.placeholderElement, element);
12942
13006
  element.parentNode.removeChild(element);
12943
-
13007
+
12944
13008
  //create hover element
12945
13009
  this.hoverElement = element.cloneNode(true);
12946
13010
  this.hoverElement.classList.add("tabulator-moving");
12947
-
13011
+
12948
13012
  this.table.columnManager.getElement().appendChild(this.hoverElement);
12949
-
13013
+
12950
13014
  this.hoverElement.style.left = "0";
12951
- this.hoverElement.style.bottom = "0";
12952
-
13015
+ this.hoverElement.style.bottom = (headerElement.clientHeight - headersElement.offsetHeight) + "px";
13016
+
12953
13017
  if(!this.touchMove){
12954
13018
  this._bindMouseMove();
12955
-
13019
+
12956
13020
  document.body.addEventListener("mousemove", this.moveHover);
12957
13021
  document.body.addEventListener("mouseup", this.endMove);
12958
13022
  }
12959
-
13023
+
12960
13024
  this.moveHover(e);
12961
13025
  }
12962
-
13026
+
12963
13027
  _bindMouseMove(){
12964
13028
  this.table.columnManager.columnsByIndex.forEach(function(column){
12965
13029
  if(column.modules.moveColumn.mousemove){
@@ -12967,7 +13031,7 @@ class MoveColumns extends Module{
12967
13031
  }
12968
13032
  });
12969
13033
  }
12970
-
13034
+
12971
13035
  _unbindMouseMove(){
12972
13036
  this.table.columnManager.columnsByIndex.forEach(function(column){
12973
13037
  if(column.modules.moveColumn.mousemove){
@@ -12975,65 +13039,65 @@ class MoveColumns extends Module{
12975
13039
  }
12976
13040
  });
12977
13041
  }
12978
-
13042
+
12979
13043
  moveColumn(column, after){
12980
13044
  var movingCells = this.moving.getCells();
12981
-
13045
+
12982
13046
  this.toCol = column;
12983
13047
  this.toColAfter = after;
12984
-
13048
+
12985
13049
  if(after){
12986
13050
  column.getCells().forEach(function(cell, i){
12987
13051
  var cellEl = cell.getElement(true);
12988
-
12989
- if(cellEl.parentNode){
13052
+
13053
+ if(cellEl.parentNode && movingCells[i]){
12990
13054
  cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl.nextSibling);
12991
13055
  }
12992
13056
  });
12993
13057
  }else {
12994
13058
  column.getCells().forEach(function(cell, i){
12995
13059
  var cellEl = cell.getElement(true);
12996
-
12997
- if(cellEl.parentNode){
13060
+
13061
+ if(cellEl.parentNode && movingCells[i]){
12998
13062
  cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl);
12999
13063
  }
13000
13064
  });
13001
13065
  }
13002
13066
  }
13003
-
13067
+
13004
13068
  endMove(e){
13005
13069
  if(e.which === 1 || this.touchMove){
13006
13070
  this._unbindMouseMove();
13007
-
13071
+
13008
13072
  this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);
13009
13073
  this.placeholderElement.parentNode.removeChild(this.placeholderElement);
13010
13074
  this.hoverElement.parentNode.removeChild(this.hoverElement);
13011
-
13075
+
13012
13076
  this.table.element.classList.remove("tabulator-block-select");
13013
-
13077
+
13014
13078
  if(this.toCol){
13015
13079
  this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
13016
13080
  }
13017
-
13081
+
13018
13082
  this.moving = false;
13019
13083
  this.toCol = false;
13020
13084
  this.toColAfter = false;
13021
-
13085
+
13022
13086
  if(!this.touchMove){
13023
13087
  document.body.removeEventListener("mousemove", this.moveHover);
13024
13088
  document.body.removeEventListener("mouseup", this.endMove);
13025
13089
  }
13026
13090
  }
13027
13091
  }
13028
-
13092
+
13029
13093
  moveHover(e){
13030
13094
  var columnHolder = this.table.columnManager.getElement(),
13031
13095
  scrollLeft = columnHolder.scrollLeft,
13032
- xPos = ((this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(columnHolder).left) + scrollLeft,
13096
+ xPos = ((this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(columnHolder).left) + scrollLeft,
13033
13097
  scrollPos;
13034
-
13098
+
13035
13099
  this.hoverElement.style.left = (xPos - this.startX) + "px";
13036
-
13100
+
13037
13101
  if(xPos - scrollLeft < this.autoScrollMargin){
13038
13102
  if(!this.autoScrollTimeout){
13039
13103
  this.autoScrollTimeout = setTimeout(() => {
@@ -13043,7 +13107,7 @@ class MoveColumns extends Module{
13043
13107
  }, 1);
13044
13108
  }
13045
13109
  }
13046
-
13110
+
13047
13111
  if(scrollLeft + columnHolder.clientWidth - xPos < this.autoScrollMargin){
13048
13112
  if(!this.autoScrollTimeout){
13049
13113
  this.autoScrollTimeout = setTimeout(() => {
@@ -13131,7 +13195,7 @@ class MoveRows extends Module{
13131
13195
 
13132
13196
  //same table drag drop
13133
13197
  config.mousemove = function(e){
13134
- if(((e.pageY - Helpers$1.elOffset(group.element).top) + self.table.rowManager.element.scrollTop) > (group.getHeight() / 2)){
13198
+ if(((e.pageY - Helpers.elOffset(group.element).top) + self.table.rowManager.element.scrollTop) > (group.getHeight() / 2)){
13135
13199
  if(self.toRow !== group || !self.toRowAfter){
13136
13200
  var rowEl = group.getElement();
13137
13201
  rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);
@@ -13165,7 +13229,7 @@ class MoveRows extends Module{
13165
13229
  config.mousemove = function(e){
13166
13230
  var rowEl = row.getElement();
13167
13231
 
13168
- if(((e.pageY - Helpers$1.elOffset(rowEl).top) + self.table.rowManager.element.scrollTop) > (row.getHeight() / 2)){
13232
+ if(((e.pageY - Helpers.elOffset(rowEl).top) + self.table.rowManager.element.scrollTop) > (row.getHeight() / 2)){
13169
13233
  if(self.toRow !== row || !self.toRowAfter){
13170
13234
  rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);
13171
13235
  self.moveRow(row, true);
@@ -14019,7 +14083,8 @@ class Page extends Module{
14019
14083
  margin = this.table.options.progressiveLoadScrollMargin || (element.clientHeight * 2);
14020
14084
 
14021
14085
  if(diff < margin){
14022
- this.nextPage();
14086
+ this.nextPage()
14087
+ .catch(() => {}); //consume the exception thrown when on the last page
14023
14088
  }
14024
14089
  }
14025
14090
  }
@@ -16257,10 +16322,14 @@ class ResponsiveLayout extends Module{
16257
16322
  },
16258
16323
  };
16259
16324
 
16325
+ function onRendered(callback){
16326
+ callback();
16327
+ }
16328
+
16260
16329
  output.push({
16261
16330
  field: column.field,
16262
16331
  title: column.definition.title,
16263
- value: column.modules.format.formatter.call(self.table.modules.format, mockCellComponent, column.modules.format.params)
16332
+ value: column.modules.format.formatter.call(self.table.modules.format, mockCellComponent, column.modules.format.params, onRendered)
16264
16333
  });
16265
16334
  }else {
16266
16335
  output.push({
@@ -16344,9 +16413,9 @@ class SelectRow extends Module{
16344
16413
  this.subscribe("row-init", this.initializeRow.bind(this));
16345
16414
  this.subscribe("row-deleting", this.rowDeleted.bind(this));
16346
16415
  this.subscribe("rows-wipe", this.clearSelectionData.bind(this));
16347
- this.subscribe("rows-retrieve", this.clearSelectionData.bind(this));
16416
+ this.subscribe("rows-retrieve", this.rowRetrieve.bind(this));
16348
16417
 
16349
- if(this.table.options.selectable && this.table.options.selectablePersistence){
16418
+ if(this.table.options.selectable && !this.table.options.selectablePersistence){
16350
16419
  this.subscribe("data-refeshing", this.deselectRows.bind(this));
16351
16420
  }
16352
16421
  }
@@ -16360,7 +16429,6 @@ class SelectRow extends Module{
16360
16429
  this._deselectRow(row, true);
16361
16430
  }
16362
16431
 
16363
-
16364
16432
  clearSelectionData(silent){
16365
16433
  this.selecting = false;
16366
16434
  this.lastClickedRow = false;
@@ -16608,6 +16676,7 @@ class SelectRow extends Module{
16608
16676
  var self = this,
16609
16677
  rowCount;
16610
16678
 
16679
+ console.trace("deselect");
16611
16680
  if(typeof rows == "undefined"){
16612
16681
 
16613
16682
  rowCount = self.selectedRows.length;
@@ -16825,8 +16894,9 @@ function datetime$1(a, b, aRow, bRow, column, dir, params){
16825
16894
  emptyAlign = 0;
16826
16895
 
16827
16896
  if(typeof DT != "undefined"){
16828
- a = DT.fromFormat(a, format);
16829
- b = DT.fromFormat(b, format);
16897
+ a = DT.fromFormat(String(a), format);
16898
+ b = DT.fromFormat(String(b), format);
16899
+
16830
16900
  if(!a.isValid){
16831
16901
  emptyAlign = !b.isValid ? 0 : -1;
16832
16902
  }else if(!b.isValid){
@@ -17197,7 +17267,7 @@ class Sort extends Module{
17197
17267
  if(this.table.options.sortMode === "remote"){
17198
17268
  this.reloadData();
17199
17269
  }else {
17200
- this.refreshData();
17270
+ this.refreshData(true);
17201
17271
  }
17202
17272
 
17203
17273
  //TODO - Persist left position of row manager
@@ -17851,7 +17921,7 @@ var modules = /*#__PURE__*/Object.freeze({
17851
17921
  ValidateModule: Validate
17852
17922
  });
17853
17923
 
17854
- var defaultOptions$1 = {
17924
+ var defaultOptions = {
17855
17925
 
17856
17926
  debugEventsExternal:false, //flag to console log events
17857
17927
  debugEventsInternal:false, //flag to console log events
@@ -17913,10 +17983,10 @@ var defaultOptions$1 = {
17913
17983
  };
17914
17984
 
17915
17985
  class OptionsList {
17916
- constructor(table, msgType){
17986
+ constructor(table, msgType, defaults = {}){
17917
17987
  this.table = table;
17918
17988
  this.msgType = msgType;
17919
- this.registeredDefaults = {};
17989
+ this.registeredDefaults = Object.assign({}, defaults);
17920
17990
  }
17921
17991
 
17922
17992
  register(option, value){
@@ -18097,8 +18167,8 @@ class Renderer extends CoreFeature{
18097
18167
 
18098
18168
  //check row visibility
18099
18169
  if(!ifVisible){
18100
- if(Helpers$1.elVisible(rowEl)){
18101
- offset = Helpers$1.elOffset(rowEl).top - Helpers$1.elOffset(this.elementVertical).top;
18170
+ if(Helpers.elVisible(rowEl)){
18171
+ offset = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top;
18102
18172
 
18103
18173
  if(offset > 0 && offset < this.elementVertical.clientHeight - rowEl.offsetHeight){
18104
18174
  return false;
@@ -18656,7 +18726,7 @@ class ColumnManager extends CoreFeature {
18656
18726
  this.columnsByIndex = []; //columns by index
18657
18727
  this.columnsByField = {}; //columns by field
18658
18728
  this.scrollLeft = 0;
18659
- this.optionsList = new OptionsList(this.table, "column definition");
18729
+ this.optionsList = new OptionsList(this.table, "column definition", defaultColumnOptions);
18660
18730
 
18661
18731
  this.renderer = null;
18662
18732
  }
@@ -18701,6 +18771,7 @@ class ColumnManager extends CoreFeature {
18701
18771
  var el = document.createElement("div");
18702
18772
 
18703
18773
  el.classList.add("tabulator-headers");
18774
+ el.setAttribute("role", "row");
18704
18775
 
18705
18776
  return el;
18706
18777
  }
@@ -18709,6 +18780,7 @@ class ColumnManager extends CoreFeature {
18709
18780
  var el = document.createElement("div");
18710
18781
 
18711
18782
  el.classList.add("tabulator-header");
18783
+ el.setAttribute("role", "rowgroup");
18712
18784
 
18713
18785
  if(!this.table.options.headerVisible){
18714
18786
  el.classList.add("tabulator-header-hidden");
@@ -18867,9 +18939,9 @@ class ColumnManager extends CoreFeature {
18867
18939
  index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;
18868
18940
 
18869
18941
  if(nextToColumn && index > -1){
18870
-
18871
- var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn());
18872
- var nextEl = nextToColumn.getElement();
18942
+ var topColumn = nextToColumn.getTopColumn();
18943
+ var parentIndex = this.columns.indexOf(topColumn);
18944
+ var nextEl = topColumn.getElement();
18873
18945
 
18874
18946
  if(before){
18875
18947
  this.columns.splice(parentIndex, 0, column);
@@ -18878,7 +18950,6 @@ class ColumnManager extends CoreFeature {
18878
18950
  this.columns.splice(parentIndex + 1, 0, column);
18879
18951
  nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);
18880
18952
  }
18881
-
18882
18953
  }else {
18883
18954
  if(before){
18884
18955
  this.columns.unshift(column);
@@ -18887,10 +18958,10 @@ class ColumnManager extends CoreFeature {
18887
18958
  this.columns.push(column);
18888
18959
  this.headersElement.appendChild(column.getElement());
18889
18960
  }
18890
-
18891
- column.columnRendered();
18892
18961
  }
18893
18962
 
18963
+ column.columnRendered();
18964
+
18894
18965
  return column;
18895
18966
  }
18896
18967
 
@@ -18913,7 +18984,7 @@ class ColumnManager extends CoreFeature {
18913
18984
  }
18914
18985
 
18915
18986
  //ensure column headers take up the correct amount of space in column groups
18916
- _verticalAlignHeaders(){
18987
+ verticalAlignHeaders(){
18917
18988
  var minHeight = 0;
18918
18989
 
18919
18990
  this.columns.forEach((column) => {
@@ -19070,7 +19141,7 @@ class ColumnManager extends CoreFeature {
19070
19141
  to.element.parentNode.insertBefore(to.element, from.element);
19071
19142
  }
19072
19143
 
19073
- this._verticalAlignHeaders();
19144
+ this.verticalAlignHeaders();
19074
19145
 
19075
19146
  this.table.rowManager.reinitialize();
19076
19147
  }
@@ -19245,13 +19316,11 @@ class ColumnManager extends CoreFeature {
19245
19316
 
19246
19317
  this.dispatch("column-add", definition, before, nextToColumn);
19247
19318
 
19248
- this.redraw(true);
19249
-
19250
19319
  if(this.layoutMode() != "fitColumns"){
19251
19320
  column.reinitializeWidth();
19252
19321
  }
19253
19322
 
19254
- this._verticalAlignHeaders();
19323
+ this.redraw(true);
19255
19324
 
19256
19325
  this.table.rowManager.reinitialize();
19257
19326
 
@@ -19285,18 +19354,18 @@ class ColumnManager extends CoreFeature {
19285
19354
  this.columns.splice(index, 1);
19286
19355
  }
19287
19356
 
19288
- this._verticalAlignHeaders();
19357
+ this.verticalAlignHeaders();
19289
19358
 
19290
19359
  this.redraw();
19291
19360
  }
19292
19361
 
19293
19362
  //redraw columns
19294
19363
  redraw(force){
19295
- if(force){
19296
- if(Helpers$1.elVisible(this.element)){
19297
- this._verticalAlignHeaders();
19298
- }
19364
+ if(Helpers.elVisible(this.element)){
19365
+ this.verticalAlignHeaders();
19366
+ }
19299
19367
 
19368
+ if(force){
19300
19369
  this.table.rowManager.resetScroll();
19301
19370
  this.table.rowManager.reinitialize();
19302
19371
  }
@@ -19370,7 +19439,7 @@ class BaiscVertical extends Renderer{
19370
19439
  }
19371
19440
 
19372
19441
  scrollToRowNearestTop(row){
19373
- var rowTop = Helpers$1.elOffset(row.getElement()).top;
19442
+ var rowTop = Helpers.elOffset(row.getElement()).top;
19374
19443
 
19375
19444
  return !(Math.abs(this.elementVertical.scrollTop - rowTop) > Math.abs(this.elementVertical.scrollTop + this.elementVertical.clientHeight - rowTop));
19376
19445
  }
@@ -19378,7 +19447,7 @@ class BaiscVertical extends Renderer{
19378
19447
  scrollToRow(row){
19379
19448
  var rowEl = row.getElement();
19380
19449
 
19381
- this.elementVertical.scrollTop = Helpers$1.elOffset(rowEl).top - Helpers$1.elOffset(this.elementVertical).top + this.elementVertical.scrollTop;
19450
+ this.elementVertical.scrollTop = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top + this.elementVertical.scrollTop;
19382
19451
  }
19383
19452
 
19384
19453
  visibleRows(includingBuffer){
@@ -19640,7 +19709,7 @@ class VirtualDomVertical extends Renderer{
19640
19709
  position -= topPad;
19641
19710
  }
19642
19711
 
19643
- if(rowsCount && Helpers$1.elVisible(this.elementVertical)){
19712
+ if(rowsCount && Helpers.elVisible(this.elementVertical)){
19644
19713
  this.vDomTop = position;
19645
19714
 
19646
19715
  this.vDomBottom = position -1;
@@ -19999,6 +20068,7 @@ class RowManager extends CoreFeature{
19999
20068
 
20000
20069
  el.classList.add("tabulator-tableholder");
20001
20070
  el.setAttribute("tabindex", 0);
20071
+ el.setAttribute("role", "rowgroup");
20002
20072
 
20003
20073
  return el;
20004
20074
  }
@@ -20007,6 +20077,7 @@ class RowManager extends CoreFeature{
20007
20077
  var el = document.createElement("div");
20008
20078
 
20009
20079
  el.classList.add("tabulator-table");
20080
+ el.setAttribute("role", "rowgroup");
20010
20081
 
20011
20082
  return el;
20012
20083
  }
@@ -20068,7 +20139,7 @@ class RowManager extends CoreFeature{
20068
20139
  ////////////////// Row Manipulation //////////////////
20069
20140
  findRow(subject){
20070
20141
  if(typeof subject == "object"){
20071
- if(subject instanceof Row$1){
20142
+ if(subject instanceof Row){
20072
20143
  //subject is row element
20073
20144
  return subject;
20074
20145
  }else if(subject instanceof RowComponent$1){
@@ -20151,7 +20222,7 @@ class RowManager extends CoreFeature{
20151
20222
 
20152
20223
  data.forEach((def, i) => {
20153
20224
  if(def && typeof def === "object"){
20154
- var row = new Row$1(def, this);
20225
+ var row = new Row(def, this);
20155
20226
  this.rows.push(row);
20156
20227
  }else {
20157
20228
  console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);
@@ -20254,7 +20325,7 @@ class RowManager extends CoreFeature{
20254
20325
  this.dispatch("row-added", row, data, pos, index);
20255
20326
  });
20256
20327
 
20257
- this.reRenderInPosition();
20328
+ this.refreshActiveData(false, false, true);
20258
20329
 
20259
20330
  this.regenerateRowNumbers();
20260
20331
 
@@ -20283,7 +20354,7 @@ class RowManager extends CoreFeature{
20283
20354
  }
20284
20355
 
20285
20356
  addRowActual(data, pos, index, blockRedraw){
20286
- var row = data instanceof Row$1 ? data : new Row$1(data || {}, this),
20357
+ var row = data instanceof Row ? data : new Row(data || {}, this),
20287
20358
  top = this.findAddRowPos(pos),
20288
20359
  allIndex = -1,
20289
20360
  activeIndex, chainResult;
@@ -20442,7 +20513,7 @@ class RowManager extends CoreFeature{
20442
20513
  nextRow = this.getDisplayRows()[index+1];
20443
20514
  }
20444
20515
 
20445
- if(nextRow && (!(nextRow instanceof Row$1) || nextRow.type != "row")){
20516
+ if(nextRow && (!(nextRow instanceof Row) || nextRow.type != "row")){
20446
20517
  return this.nextDisplayRow(nextRow, rowOnly);
20447
20518
  }
20448
20519
 
@@ -20457,7 +20528,7 @@ class RowManager extends CoreFeature{
20457
20528
  prevRow = this.getDisplayRows()[index-1];
20458
20529
  }
20459
20530
 
20460
- if(rowOnly && prevRow && (!(prevRow instanceof Row$1) || prevRow.type != "row")){
20531
+ if(rowOnly && prevRow && (!(prevRow instanceof Row) || prevRow.type != "row")){
20461
20532
  return this.prevDisplayRow(prevRow, rowOnly);
20462
20533
  }
20463
20534
 
@@ -20636,7 +20707,7 @@ class RowManager extends CoreFeature{
20636
20707
  //case to handle scenario when trying to skip past end stage
20637
20708
  }
20638
20709
 
20639
- if(Helpers$1.elVisible(this.element)){
20710
+ if(Helpers.elVisible(this.element)){
20640
20711
  if(renderInPosition){
20641
20712
  this.reRenderInPosition();
20642
20713
  }else {
@@ -20799,13 +20870,13 @@ class RowManager extends CoreFeature{
20799
20870
  }
20800
20871
 
20801
20872
  renderTable(){
20802
-
20803
20873
  this.dispatchExternal("renderStarted");
20804
20874
 
20805
20875
  this.element.scrollTop = 0;
20806
20876
 
20877
+ this._clearTable();
20878
+
20807
20879
  if(this.displayRowsCount){
20808
- this._clearTable();
20809
20880
  this.renderer.renderRows();
20810
20881
 
20811
20882
  if(this.firstRender){
@@ -21085,7 +21156,7 @@ class InteractionManager extends CoreFeature {
21085
21156
  constructor (table){
21086
21157
  super(table);
21087
21158
 
21088
- this.el = this.table.element;
21159
+ this.el = null;
21089
21160
 
21090
21161
  this.abortClasses = ["tabulator-headers", "tabulator-table"];
21091
21162
 
@@ -21110,7 +21181,10 @@ class InteractionManager extends CoreFeature {
21110
21181
  "tabulator-group":"group",
21111
21182
  "tabulator-col":"column",
21112
21183
  };
21184
+ }
21113
21185
 
21186
+ initialize(){
21187
+ this.el = this.table.element;
21114
21188
  this.buildListenerMap();
21115
21189
  this.bindSubscriptionWatchers();
21116
21190
  }
@@ -21288,7 +21362,7 @@ class InteractionManager extends CoreFeature {
21288
21362
  }
21289
21363
  }
21290
21364
 
21291
- class ComponentFuctionBinder{
21365
+ class ComponentFunctionBinder{
21292
21366
 
21293
21367
  constructor(table){
21294
21368
  this.table = table;
@@ -22174,7 +22248,7 @@ class Localize extends Module{
22174
22248
  }
22175
22249
 
22176
22250
  initialize(){
22177
- this.langList = Helpers$1.deepClone(Localize.langs);
22251
+ this.langList = Helpers.deepClone(Localize.langs);
22178
22252
 
22179
22253
  if(this.table.options.columnDefaults.headerFilterPlaceholder !== false){
22180
22254
  this.setHeaderFilterPlaceholder(this.table.options.columnDefaults.headerFilterPlaceholder);
@@ -22266,7 +22340,7 @@ class Localize extends Module{
22266
22340
  this.locale = desiredLocale;
22267
22341
 
22268
22342
  //load default lang template
22269
- this.lang = Helpers$1.deepClone(this.langList.default || {});
22343
+ this.lang = Helpers.deepClone(this.langList.default || {});
22270
22344
 
22271
22345
  if(desiredLocale != "default"){
22272
22346
  traverseLang(this.langList[desiredLocale], this.lang);
@@ -22501,10 +22575,11 @@ class Tabulator {
22501
22575
  this.interactionMonitor = false; //track user interaction
22502
22576
  this.browser = ""; //hold current browser type
22503
22577
  this.browserSlow = false; //handle reduced functionality for slower browsers
22504
- this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence
22578
+ this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance
22505
22579
  this.rtl = false; //check if the table is in RTL mode
22580
+ this.originalElement = null; //hold original table element if it has been replaced
22506
22581
 
22507
- this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions
22582
+ this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions
22508
22583
  this.dataLoader = false; //bind component functions
22509
22584
 
22510
22585
  this.modules = {}; //hold all modules bound to this table
@@ -22519,13 +22594,13 @@ class Tabulator {
22519
22594
 
22520
22595
  this.initialzeCoreSystems(options);
22521
22596
 
22522
- //delay table creation to allow event bindings immediatly after the constructor
22597
+ //delay table creation to allow event bindings immediately after the constructor
22523
22598
  setTimeout(() => {
22524
22599
  this._create();
22525
22600
  });
22526
22601
  }
22527
22602
 
22528
- TableRegistry.register(this); //register table for inderdevice communication
22603
+ TableRegistry.register(this); //register table for inter-device communication
22529
22604
  }
22530
22605
 
22531
22606
  initializeElement(element){
@@ -22559,7 +22634,7 @@ class Tabulator {
22559
22634
 
22560
22635
  this._clearObjectPointers();
22561
22636
 
22562
- this._mapDepricatedFunctionality();
22637
+ this._mapDeprecatedFunctionality();
22563
22638
 
22564
22639
  this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);
22565
22640
  this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
@@ -22572,29 +22647,8 @@ class Tabulator {
22572
22647
  this.footerManager.initialize();
22573
22648
  }
22574
22649
 
22575
- rtlCheck(){
22576
- var style = window.getComputedStyle(this.element);
22577
-
22578
- switch(this.options.textDirection){
22579
- case"auto":
22580
- if(style.direction !== "rtl"){
22581
- break;
22582
- }
22583
- case "rtl":
22584
- this.element.classList.add("tabulator-rtl");
22585
- this.rtl = true;
22586
- break;
22587
-
22588
- case "ltr":
22589
- this.element.classList.add("tabulator-ltr");
22590
-
22591
- default:
22592
- this.rtl = false;
22593
- }
22594
- }
22595
-
22596
- //convert depricated functionality to new functions
22597
- _mapDepricatedFunctionality(){
22650
+ //convert deprecated functionality to new functions
22651
+ _mapDeprecatedFunctionality(){
22598
22652
  //all previously deprecated functionality removed in the 5.0 release
22599
22653
  }
22600
22654
 
@@ -22615,15 +22669,17 @@ class Tabulator {
22615
22669
  this.element.classList.remove("tabulator-block-select");
22616
22670
  }
22617
22671
 
22618
- //concreate table
22672
+ //create table
22619
22673
  _create(){
22620
22674
  this.externalEvents.dispatch("tableBuilding");
22621
22675
  this.eventBus.dispatch("table-building");
22622
22676
 
22623
- this.rtlCheck();
22677
+ this._rtlCheck();
22624
22678
 
22625
22679
  this._buildElement();
22626
22680
 
22681
+ this._initializeTable();
22682
+
22627
22683
  this._loadInitialData();
22628
22684
 
22629
22685
  this.initialized = true;
@@ -22631,6 +22687,27 @@ class Tabulator {
22631
22687
  this.externalEvents.dispatch("tableBuilt");
22632
22688
  }
22633
22689
 
22690
+ _rtlCheck(){
22691
+ var style = window.getComputedStyle(this.element);
22692
+
22693
+ switch(this.options.textDirection){
22694
+ case"auto":
22695
+ if(style.direction !== "rtl"){
22696
+ break;
22697
+ }
22698
+ case "rtl":
22699
+ this.element.classList.add("tabulator-rtl");
22700
+ this.rtl = true;
22701
+ break;
22702
+
22703
+ case "ltr":
22704
+ this.element.classList.add("tabulator-ltr");
22705
+
22706
+ default:
22707
+ this.rtl = false;
22708
+ }
22709
+ }
22710
+
22634
22711
  //clear pointers to objects in default config object
22635
22712
  _clearObjectPointers(){
22636
22713
  this.options.columns = this.options.columns.slice(0);
@@ -22643,7 +22720,28 @@ class Tabulator {
22643
22720
  //build tabulator element
22644
22721
  _buildElement(){
22645
22722
  var element = this.element,
22646
- options = this.options;
22723
+ options = this.options,
22724
+ newElement;
22725
+
22726
+ if(element.tagName === "TABLE"){
22727
+ this.originalElement = this.element;
22728
+ newElement = document.createElement("div");
22729
+
22730
+ //transfer attributes to new element
22731
+ var attributes = element.attributes;
22732
+
22733
+ // loop through attributes and apply them on div
22734
+ for(var i in attributes){
22735
+ if(typeof attributes[i] == "object"){
22736
+ newElement.setAttribute(attributes[i].name, attributes[i].value);
22737
+ }
22738
+ }
22739
+
22740
+ // replace table with div element
22741
+ element.parentNode.replaceChild(newElement, element);
22742
+
22743
+ this.element = element = newElement;
22744
+ }
22647
22745
 
22648
22746
  element.classList.add("tabulator");
22649
22747
  element.setAttribute("role", "grid");
@@ -22668,6 +22766,14 @@ class Tabulator {
22668
22766
  options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";
22669
22767
  element.style.maxHeight = options.maxHeight;
22670
22768
  }
22769
+ }
22770
+
22771
+ //initialize core systems and modules
22772
+ _initializeTable(){
22773
+ var element = this.element,
22774
+ options = this.options;
22775
+
22776
+ this.interactionMonitor.initialize();
22671
22777
 
22672
22778
  this.columnManager.initialize();
22673
22779
  this.rowManager.initialize();
@@ -22683,7 +22789,6 @@ class Tabulator {
22683
22789
 
22684
22790
  //configure placeholder element
22685
22791
  if(typeof options.placeholder == "string"){
22686
-
22687
22792
  var el = document.createElement("div");
22688
22793
  el.classList.add("tabulator-placeholder");
22689
22794
 
@@ -22728,7 +22833,7 @@ class Tabulator {
22728
22833
  destroy(){
22729
22834
  var element = this.element;
22730
22835
 
22731
- TableRegistry.deregister(this); //deregister table from inderdevice communication
22836
+ TableRegistry.deregister(this); //deregister table from inter-device communication
22732
22837
 
22733
22838
  this.eventBus.dispatch("table-destroy");
22734
22839
 
@@ -22847,68 +22952,80 @@ class Tabulator {
22847
22952
 
22848
22953
  //replace data, keeping table in position with same sort
22849
22954
  replaceData(data, params, config){
22850
- return this.dataLoader.load(data, params, config, true, true);
22955
+ if(this.initialized){
22956
+ return this.dataLoader.load(data, params, config, true, true);
22957
+ }else {
22958
+ console.warn("replaceData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
22959
+ }
22851
22960
  }
22852
22961
 
22853
22962
  //update table data
22854
22963
  updateData(data){
22855
22964
  var responses = 0;
22856
22965
 
22857
- return new Promise((resolve, reject) => {
22858
- this.dataLoader.blockActiveLoad();
22966
+ if(this.initialized){
22967
+ return new Promise((resolve, reject) => {
22968
+ this.dataLoader.blockActiveLoad();
22859
22969
 
22860
- if(typeof data === "string"){
22861
- data = JSON.parse(data);
22862
- }
22970
+ if(typeof data === "string"){
22971
+ data = JSON.parse(data);
22972
+ }
22863
22973
 
22864
- if(data){
22865
- data.forEach((item) => {
22866
- var row = this.rowManager.findRow(item[this.options.index]);
22974
+ if(data){
22975
+ data.forEach((item) => {
22976
+ var row = this.rowManager.findRow(item[this.options.index]);
22867
22977
 
22868
- if(row){
22869
- responses++;
22978
+ if(row){
22979
+ responses++;
22870
22980
 
22871
- row.updateData(item)
22872
- .then(()=>{
22873
- responses--;
22981
+ row.updateData(item)
22982
+ .then(()=>{
22983
+ responses--;
22874
22984
 
22875
- if(!responses){
22876
- resolve();
22877
- }
22878
- });
22879
- }
22880
- });
22881
- }else {
22882
- console.warn("Update Error - No data provided");
22883
- reject("Update Error - No data provided");
22884
- }
22885
- });
22985
+ if(!responses){
22986
+ resolve();
22987
+ }
22988
+ });
22989
+ }
22990
+ });
22991
+ }else {
22992
+ console.warn("Update Error - No data provided");
22993
+ reject("Update Error - No data provided");
22994
+ }
22995
+ });
22996
+ }else {
22997
+ console.warn("updateData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
22998
+ }
22886
22999
  }
22887
23000
 
22888
23001
  addData(data, pos, index){
22889
- return new Promise((resolve, reject) => {
22890
- this.dataLoader.blockActiveLoad();
23002
+ if(this.initialized){
23003
+ return new Promise((resolve, reject) => {
23004
+ this.dataLoader.blockActiveLoad();
22891
23005
 
22892
- if(typeof data === "string"){
22893
- data = JSON.parse(data);
22894
- }
23006
+ if(typeof data === "string"){
23007
+ data = JSON.parse(data);
23008
+ }
22895
23009
 
22896
- if(data){
22897
- this.rowManager.addRows(data, pos, index)
22898
- .then((rows) => {
22899
- var output = [];
23010
+ if(data){
23011
+ this.rowManager.addRows(data, pos, index)
23012
+ .then((rows) => {
23013
+ var output = [];
22900
23014
 
22901
- rows.forEach(function(row){
22902
- output.push(row.getComponent());
22903
- });
23015
+ rows.forEach(function(row){
23016
+ output.push(row.getComponent());
23017
+ });
22904
23018
 
22905
- resolve(output);
22906
- });
22907
- }else {
22908
- console.warn("Update Error - No data provided");
22909
- reject("Update Error - No data provided");
22910
- }
22911
- });
23019
+ resolve(output);
23020
+ });
23021
+ }else {
23022
+ console.warn("Update Error - No data provided");
23023
+ reject("Update Error - No data provided");
23024
+ }
23025
+ });
23026
+ }else {
23027
+ console.warn("addData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
23028
+ }
22912
23029
  }
22913
23030
 
22914
23031
  //update table data
@@ -22916,46 +23033,50 @@ class Tabulator {
22916
23033
  var rows = [],
22917
23034
  responses = 0;
22918
23035
 
22919
- return new Promise((resolve, reject) => {
22920
- this.dataLoader.blockActiveLoad();
23036
+ if(this.initialized){
23037
+ return new Promise((resolve, reject) => {
23038
+ this.dataLoader.blockActiveLoad();
22921
23039
 
22922
- if(typeof data === "string"){
22923
- data = JSON.parse(data);
22924
- }
23040
+ if(typeof data === "string"){
23041
+ data = JSON.parse(data);
23042
+ }
22925
23043
 
22926
- if(data){
22927
- data.forEach((item) => {
22928
- var row = this.rowManager.findRow(item[this.options.index]);
23044
+ if(data){
23045
+ data.forEach((item) => {
23046
+ var row = this.rowManager.findRow(item[this.options.index]);
22929
23047
 
22930
- responses++;
23048
+ responses++;
22931
23049
 
22932
- if(row){
22933
- row.updateData(item)
22934
- .then(()=>{
22935
- responses--;
22936
- rows.push(row.getComponent());
23050
+ if(row){
23051
+ row.updateData(item)
23052
+ .then(()=>{
23053
+ responses--;
23054
+ rows.push(row.getComponent());
22937
23055
 
22938
- if(!responses){
22939
- resolve(rows);
22940
- }
22941
- });
22942
- }else {
22943
- this.rowManager.addRows(item)
22944
- .then((newRows)=>{
22945
- responses--;
22946
- rows.push(newRows[0].getComponent());
23056
+ if(!responses){
23057
+ resolve(rows);
23058
+ }
23059
+ });
23060
+ }else {
23061
+ this.rowManager.addRows(item)
23062
+ .then((newRows)=>{
23063
+ responses--;
23064
+ rows.push(newRows[0].getComponent());
22947
23065
 
22948
- if(!responses){
22949
- resolve(rows);
22950
- }
22951
- });
22952
- }
22953
- });
22954
- }else {
22955
- console.warn("Update Error - No data provided");
22956
- reject("Update Error - No data provided");
22957
- }
22958
- });
23066
+ if(!responses){
23067
+ resolve(rows);
23068
+ }
23069
+ });
23070
+ }
23071
+ });
23072
+ }else {
23073
+ console.warn("Update Error - No data provided");
23074
+ reject("Update Error - No data provided");
23075
+ }
23076
+ });
23077
+ }else {
23078
+ console.warn("updateOrAddData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
23079
+ }
22959
23080
  }
22960
23081
 
22961
23082
  //get row object
@@ -23019,14 +23140,18 @@ class Tabulator {
23019
23140
 
23020
23141
  //add row to table
23021
23142
  addRow(data, pos, index){
23022
- if(typeof data === "string"){
23023
- data = JSON.parse(data);
23024
- }
23143
+ if(this.initialized){
23144
+ if(typeof data === "string"){
23145
+ data = JSON.parse(data);
23146
+ }
23025
23147
 
23026
- return this.rowManager.addRows(data, pos, index)
23027
- .then((rows)=>{
23028
- return rows[0].getComponent();
23029
- });
23148
+ return this.rowManager.addRows(data, pos, index)
23149
+ .then((rows)=>{
23150
+ return rows[0].getComponent();
23151
+ });
23152
+ }else {
23153
+ console.warn("addRow failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
23154
+ }
23030
23155
  }
23031
23156
 
23032
23157
  //update a row if it exitsts otherwise create it
@@ -23061,7 +23186,7 @@ class Tabulator {
23061
23186
  if(row){
23062
23187
  return row.updateData(data)
23063
23188
  .then(()=>{
23064
- resolve(row.getComponent());
23189
+ return Promise.resolve(row.getComponent());
23065
23190
  })
23066
23191
  }else {
23067
23192
  console.warn("Update Error - No matching row found:", index);
@@ -23235,8 +23360,12 @@ class Tabulator {
23235
23360
  //////////// General Public Functions ////////////
23236
23361
  //redraw list without updating data
23237
23362
  redraw(force){
23238
- this.columnManager.redraw(force);
23239
- this.rowManager.redraw(force);
23363
+ if(this.initialized){
23364
+ this.columnManager.redraw(force);
23365
+ this.rowManager.redraw(force);
23366
+ }else {
23367
+ console.warn("redraw failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
23368
+ }
23240
23369
  }
23241
23370
 
23242
23371
  setHeight(height){
@@ -23287,7 +23416,7 @@ class Tabulator {
23287
23416
  }
23288
23417
 
23289
23418
  //default setup options
23290
- Tabulator.defaultOptions = defaultOptions$1;
23419
+ Tabulator.defaultOptions = defaultOptions;
23291
23420
 
23292
23421
  //bind modules and static functionality
23293
23422
  new ModuleBinder(Tabulator);