tabulator-tables 5.0.10 → 5.1.0

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 (100) hide show
  1. package/.editorconfig +6 -0
  2. package/LICENSE +1 -1
  3. package/bower.json +1 -1
  4. package/build/rollup.js +1 -1
  5. package/dist/css/tabulator.css +15 -6
  6. package/dist/css/tabulator.css.map +1 -1
  7. package/dist/css/tabulator.min.css +1 -1
  8. package/dist/css/tabulator.min.css.map +1 -1
  9. package/dist/css/tabulator_bootstrap3.css +15 -6
  10. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  11. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  12. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  13. package/dist/css/tabulator_bootstrap4.css +15 -6
  14. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  15. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  16. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  17. package/dist/css/tabulator_bulma.css +15 -6
  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 +22 -10
  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 +19 -6
  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 +15 -6
  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 +15 -6
  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 +15 -6
  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 +19 -6
  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 +853 -390
  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 +1106 -656
  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 +7 -7
  55. package/src/js/core/Tabulator.js +0 -43
  56. package/src/js/core/cell/Cell.js +5 -1
  57. package/src/js/core/column/Column.js +19 -4
  58. package/src/js/core/column/ColumnComponent.js +4 -0
  59. package/src/js/core/column/defaults/options.js +1 -0
  60. package/src/js/core/defaults/options.js +2 -2
  61. package/src/js/core/modules/optional.js +1 -0
  62. package/src/js/core/rendering/renderers/BasicVertical.js +2 -1
  63. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +17 -8
  64. package/src/js/core/row/Row.js +2 -2
  65. package/src/js/core/tools/DataLoader.js +4 -4
  66. package/src/js/core/tools/InteractionMonitor.js +6 -2
  67. package/src/js/modules/Ajax/Ajax.js +62 -82
  68. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +1 -1
  69. package/src/js/modules/DataTree/DataTree.js +5 -0
  70. package/src/js/modules/Download/defaults/downloaders/json.js +1 -1
  71. package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
  72. package/src/js/modules/Download/defaults/downloaders.js +2 -0
  73. package/src/js/modules/Edit/Edit.js +23 -31
  74. package/src/js/modules/Filter/Filter.js +1 -1
  75. package/src/js/modules/Format/defaults/formatters/datetime.js +1 -1
  76. package/src/js/modules/Format/defaults/formatters/datetimediff.js +2 -1
  77. package/src/js/modules/FrozenRows/FrozenRows.js +9 -0
  78. package/src/js/modules/GroupRows/Group.js +2 -61
  79. package/src/js/modules/GroupRows/GroupRows.js +2 -2
  80. package/src/js/modules/Import/Import.js +197 -0
  81. package/src/js/modules/Import/defaults/importers/csv.js +63 -0
  82. package/src/js/modules/Import/defaults/importers/json.js +8 -0
  83. package/src/js/modules/Import/defaults/importers.js +7 -0
  84. package/src/js/modules/Interaction/Interaction.js +5 -0
  85. package/src/js/modules/Keybindings/Keybindings.js +9 -14
  86. package/src/js/modules/Keybindings/defaults/bindings.js +3 -3
  87. package/src/js/modules/Localize/defaults/langs.js +6 -0
  88. package/src/js/modules/Menu/Menu.js +200 -155
  89. package/src/js/modules/MoveRows/MoveRows.js +4 -0
  90. package/src/js/modules/Page/Page.js +271 -173
  91. package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
  92. package/src/js/modules/Page/defaults/pageCounters/rows.js +32 -0
  93. package/src/js/modules/Page/defaults/pageCounters.js +8 -0
  94. package/src/js/modules/ResizeRows/ResizeRows.js +1 -1
  95. package/src/js/modules/Sort/defaults/sorters/datetime.js +2 -2
  96. package/src/js/modules/Validate/Validate.js +7 -5
  97. package/src/scss/tabulator.scss +20 -6
  98. package/src/scss/themes/materialize/tabulator_materialize.scss +5 -4
  99. package/src/scss/themes/tabulator_midnight.scss +4 -0
  100. package/src/scss/themes/tabulator_site.scss +4 -0
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.0.10 (c) Oliver Folkerd 2021 */
1
+ /* Tabulator v5.1.0 (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) :
@@ -225,8 +225,6 @@
225
225
  //minimum height of tabulator
226
226
  maxHeight: false,
227
227
  //maximum height of tabulator
228
- columnMaxWidth: false,
229
- //minimum global width for a column
230
228
  columnHeaderVertAlign: "top",
231
229
  //vertical alignment of column headers
232
230
  columns: [],
@@ -267,6 +265,7 @@
267
265
  dataLoader: true,
268
266
  dataLoaderLoading: false,
269
267
  dataLoaderError: false,
268
+ dataLoaderErrorTimeout: 3000,
270
269
  dataSendParams: {},
271
270
  dataReceiveParams: {}
272
271
  };
@@ -472,6 +471,11 @@
472
471
  value: function getField() {
473
472
  return this._column.getField();
474
473
  }
474
+ }, {
475
+ key: "getTitleDownload",
476
+ value: function getTitleDownload() {
477
+ return this._column.getTitleDownload();
478
+ }
475
479
  }, {
476
480
  key: "getCells",
477
481
  value: function getCells() {
@@ -622,6 +626,7 @@
622
626
  "width": undefined,
623
627
  "minWidth": 40,
624
628
  "maxWidth": undefined,
629
+ "maxInitialWidth": undefined,
625
630
  "tooltip": undefined,
626
631
  "cssClass": undefined,
627
632
  "variableHeight": undefined,
@@ -935,6 +940,11 @@
935
940
  if (changed) {
936
941
  this.dispatch("cell-value-updated", this);
937
942
  this.cellRendered();
943
+
944
+ if (this.column.definition.cellEdited) {
945
+ this.column.definition.cellEdited.call(this.table, this.getComponent());
946
+ }
947
+
938
948
  this.dispatchExternal("cellEdited", this.getComponent());
939
949
 
940
950
  if (this.subscribedExternal("dataChanged")) {
@@ -947,7 +957,7 @@
947
957
  value: function setValueProcessData(value, mutate) {
948
958
  var changed = false;
949
959
 
950
- if (this.value != value) {
960
+ if (this.value !== value) {
951
961
  changed = true;
952
962
 
953
963
  if (mutate) {
@@ -1121,6 +1131,7 @@
1121
1131
  _this.fieldStructure = "";
1122
1132
  _this.getFieldValue = "";
1123
1133
  _this.setFieldValue = "";
1134
+ _this.titleDownload = null;
1124
1135
  _this.titleFormatterRendered = false;
1125
1136
 
1126
1137
  _this.mapDefinitions();
@@ -1137,6 +1148,7 @@
1137
1148
 
1138
1149
  _this.maxWidthStyled = ""; //column maximum prestyled to improve render efficiency
1139
1150
 
1151
+ _this.maxInitialWidth = null;
1140
1152
  _this.minWidth = null; //column minimum width
1141
1153
 
1142
1154
  _this.minWidthStyled = ""; //column minimum prestyled to improve render efficiency
@@ -1429,6 +1441,10 @@
1429
1441
 
1430
1442
  this.setMinWidth(parseInt(def.minWidth));
1431
1443
 
1444
+ if (def.maxInitialWidth) {
1445
+ this.maxInitialWidth = parseInt(def.maxInitialWidth);
1446
+ }
1447
+
1432
1448
  if (def.maxWidth) {
1433
1449
  this.setMaxWidth(parseInt(def.maxWidth));
1434
1450
  }
@@ -1678,6 +1694,11 @@
1678
1694
  key: "getField",
1679
1695
  value: function getField() {
1680
1696
  return this.field;
1697
+ }
1698
+ }, {
1699
+ key: "getTitleDownload",
1700
+ value: function getTitleDownload() {
1701
+ return this.titleDownload;
1681
1702
  } //return the first column in a group
1682
1703
 
1683
1704
  }, {
@@ -1936,7 +1957,7 @@
1936
1957
  }, {
1937
1958
  key: "getHeight",
1938
1959
  value: function getHeight() {
1939
- return this.element.offsetHeight;
1960
+ return Math.ceil(this.element.getBoundingClientRect().height);
1940
1961
  }
1941
1962
  }, {
1942
1963
  key: "setMinWidth",
@@ -2045,17 +2066,18 @@
2045
2066
  this.widthFixed = false; //set width if present
2046
2067
 
2047
2068
  if (typeof this.definition.width !== "undefined" && !force) {
2069
+ // maxInitialWidth ignored here as width specified
2048
2070
  this.setWidth(this.definition.width);
2049
2071
  }
2050
2072
 
2051
2073
  this.dispatch("column-width-fit-before", this);
2052
- this.fitToData();
2074
+ this.fitToData(force);
2053
2075
  this.dispatch("column-width-fit-after", this);
2054
2076
  } //set column width to maximum cell width for non group columns
2055
2077
 
2056
2078
  }, {
2057
2079
  key: "fitToData",
2058
- value: function fitToData() {
2080
+ value: function fitToData(force) {
2059
2081
  if (this.isGroup) {
2060
2082
  return;
2061
2083
  }
@@ -2079,7 +2101,13 @@
2079
2101
  });
2080
2102
 
2081
2103
  if (maxWidth) {
2082
- this.setWidthActual(maxWidth + 1);
2104
+ var setTo = maxWidth + 1;
2105
+
2106
+ if (this.maxInitialWidth && !force) {
2107
+ setTo = Math.min(setTo, this.maxInitialWidth);
2108
+ }
2109
+
2110
+ this.setWidthActual(setTo);
2083
2111
  }
2084
2112
  }
2085
2113
  }
@@ -2525,11 +2553,11 @@
2525
2553
  _createClass(VirtualDomHorizontal, [{
2526
2554
  key: "initialize",
2527
2555
  value: function initialize() {
2528
- this.compatabilityCheck();
2556
+ this.compatibilityCheck();
2529
2557
  }
2530
2558
  }, {
2531
- key: "compatabilityCheck",
2532
- value: function compatabilityCheck() {
2559
+ key: "compatibilityCheck",
2560
+ value: function compatibilityCheck() {
2533
2561
  var columns = this.options("columns"),
2534
2562
  frozen = false,
2535
2563
  ok = true;
@@ -2611,7 +2639,7 @@
2611
2639
  config.width = width;
2612
2640
 
2613
2641
  if (_this2.options("layout") === "fitData") {
2614
- config.fitDataCheck = true;
2642
+ config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
2615
2643
  }
2616
2644
 
2617
2645
  if (colPos + width > _this2.vDomScrollPosLeft && colPos < _this2.vDomScrollPosRight) {
@@ -2822,7 +2850,7 @@
2822
2850
  }
2823
2851
  });
2824
2852
  this.fitDataColActualWidthCheck(column);
2825
- this.rightCol++;
2853
+ this.rightCol++; // Don't move this below the >= check below
2826
2854
 
2827
2855
  if (this.rightCol >= this.columns.length - 1) {
2828
2856
  this.vDomPadRight = 0;
@@ -2850,15 +2878,16 @@
2850
2878
  }
2851
2879
  });
2852
2880
  this.fitDataColActualWidthCheck(column);
2881
+ this.leftCol--; // don't move this below the <= check below
2853
2882
 
2854
- if (!this.leftCol) {
2883
+ if (this.leftCol <= 0) {
2884
+ // replicating logic in addColRight
2855
2885
  this.vDomPadLeft = 0;
2856
2886
  } else {
2857
2887
  this.vDomPadLeft -= column.getWidth();
2858
2888
  }
2859
2889
 
2860
2890
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
2861
- this.leftCol--;
2862
2891
  this.addColLeft();
2863
2892
  }
2864
2893
  }
@@ -2874,7 +2903,12 @@
2874
2903
  rows.forEach(function (row) {
2875
2904
  if (row.type !== "group") {
2876
2905
  var cell = row.getCell(column);
2877
- row.getElement().removeChild(cell.getElement());
2906
+
2907
+ try {
2908
+ row.getElement().removeChild(cell.getElement());
2909
+ } catch (ex) {
2910
+ console.warn("Could not removeColRight", ex.message);
2911
+ }
2878
2912
  }
2879
2913
  });
2880
2914
  this.vDomPadRight += column.getWidth();
@@ -2901,7 +2935,11 @@
2901
2935
  el = cell.getElement();
2902
2936
 
2903
2937
  if (el.parentNode) {
2904
- row.getElement().removeChild(el);
2938
+ try {
2939
+ row.getElement().removeChild(el);
2940
+ } catch (ex) {
2941
+ console.warn("Could not removeColLeft", ex.message);
2942
+ }
2905
2943
  }
2906
2944
  }
2907
2945
  }
@@ -3854,12 +3892,12 @@
3854
3892
  }
3855
3893
 
3856
3894
  this.dispatch("row-layout", this);
3895
+ this.initialized = true;
3857
3896
 
3858
3897
  if (this.table.options.rowFormatter) {
3859
3898
  this.table.options.rowFormatter(this.getComponent());
3860
3899
  }
3861
3900
 
3862
- this.initialized = true;
3863
3901
  this.dispatch("row-layout-after", this);
3864
3902
  } else {
3865
3903
  this.table.columnManager.renderer.rerenderRowCells(this);
@@ -4269,7 +4307,8 @@
4269
4307
  }, {
4270
4308
  key: "rerenderRows",
4271
4309
  value: function rerenderRows(callback) {
4272
- this.render();
4310
+ this.clearRows();
4311
+ this.renderRows();
4273
4312
 
4274
4313
  if (callback) {
4275
4314
  callback();
@@ -4926,7 +4965,7 @@
4926
4965
 
4927
4966
  _this.rows = []; //hold row data objects
4928
4967
 
4929
- _this.activeRowsPipeline = []; //hold caluclation of active rows
4968
+ _this.activeRowsPipeline = []; //hold calculation of active rows
4930
4969
 
4931
4970
  _this.activeRows = []; //rows currently available to on display in the table
4932
4971
 
@@ -4940,11 +4979,11 @@
4940
4979
  _this.scrollLeft = 0;
4941
4980
  _this.rowNumColumn = false; //hold column component for row number column
4942
4981
 
4943
- _this.redrawBlock = false; //prevent redraws to allow multiple data manipulations becore continuing
4982
+ _this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing
4944
4983
 
4945
4984
  _this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed
4946
4985
 
4947
- _this.redrawBlockRederInPosition = false; //store latest redraw function calls for when redraw is needed
4986
+ _this.redrawBlockRenderInPosition = false; //store latest redraw function calls for when redraw is needed
4948
4987
 
4949
4988
  _this.dataPipeline = []; //hold data pipeline tasks
4950
4989
 
@@ -5625,7 +5664,7 @@
5625
5664
  }
5626
5665
  }
5627
5666
 
5628
- this.dispatch("data-refeshed");
5667
+ this.dispatch("data-refreshed");
5629
5668
  }
5630
5669
  } //regenerate row numbers for row number formatter if in use
5631
5670
 
@@ -5745,7 +5784,7 @@
5745
5784
  if (callback) {
5746
5785
  callback();
5747
5786
  } else {
5748
- this.redrawBlockRederInPosition = true;
5787
+ this.redrawBlockRenderInPosition = true;
5749
5788
  }
5750
5789
  } else {
5751
5790
  this.renderer.rerenderRows(callback);
@@ -5929,12 +5968,12 @@
5929
5968
  this.refreshActiveData(this.redrawBlockRestoreConfig.handler, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition);
5930
5969
  this.redrawBlockRestoreConfig = false;
5931
5970
  } else {
5932
- if (this.redrawBlockRederInPosition) {
5971
+ if (this.redrawBlockRenderInPosition) {
5933
5972
  this.reRenderInPosition();
5934
5973
  }
5935
5974
  }
5936
5975
 
5937
- this.redrawBlockRederInPosition = false;
5976
+ this.redrawBlockRenderInPosition = false;
5938
5977
  } //redraw table
5939
5978
 
5940
5979
  }, {
@@ -6372,7 +6411,7 @@
6372
6411
  switch (key) {
6373
6412
  case "row":
6374
6413
  case "group":
6375
- if (listener.components.includes("row") || listener.components.includes("cell")) {
6414
+ if (listener.components.includes("row") || listener.components.includes("cell") || listener.components.includes("group")) {
6376
6415
  var rows = _this5.table.rowManager.getVisibleRows(true);
6377
6416
 
6378
6417
  component = rows.find(function (row) {
@@ -6391,7 +6430,11 @@
6391
6430
 
6392
6431
  case "cell":
6393
6432
  if (listener.components.includes("cell")) {
6394
- component = targets["row"].findCell(target);
6433
+ if (targets["row"]) {
6434
+ component = targets["row"].findCell(target);
6435
+ } else {
6436
+ console.warn("Event Target Lookup Error - The row this cell is attached to cannot be found, has the table been reinitialized without being destroyed first?");
6437
+ }
6395
6438
  }
6396
6439
 
6397
6440
  break;
@@ -6570,7 +6613,7 @@
6570
6613
 
6571
6614
  params = this.chain("data-params", [data, config, silent], params || {}, params || {});
6572
6615
  params = this.mapParams(params, this.table.options.dataSendParams);
6573
- var result = this.chain("data-load", [data, params, config, silent], Promise.resolve([]));
6616
+ var result = this.chain("data-load", [data, params, config, silent], false, Promise.resolve([]));
6574
6617
  return result.then(function (response) {
6575
6618
  if (!Array.isArray(response) && _typeof(response) == "object") {
6576
6619
  response = _this2.mapParams(response, _this2.objectInvert(_this2.table.options.dataReceiveParams));
@@ -6600,7 +6643,7 @@
6600
6643
 
6601
6644
  setTimeout(function () {
6602
6645
  _this2.hideLoader();
6603
- }, 3000);
6646
+ }, _this2.table.options.dataLoaderErrorTimeout);
6604
6647
  })["finally"](function () {
6605
6648
  _this2.loading = false;
6606
6649
  });
@@ -7480,7 +7523,13 @@
7480
7523
  "prev_title": "Prev Page",
7481
7524
  "next": "Next",
7482
7525
  "next_title": "Next Page",
7483
- "all": "All"
7526
+ "all": "All",
7527
+ "counter": {
7528
+ "showing": "Showing",
7529
+ "of": "of",
7530
+ "rows": "rows",
7531
+ "pages": "pages"
7532
+ }
7484
7533
  },
7485
7534
  "headerFilters": {
7486
7535
  "default": "filter column...",
@@ -8196,46 +8245,6 @@
8196
8245
  key: "restoreRedraw",
8197
8246
  value: function restoreRedraw() {
8198
8247
  return this.rowManager.restoreRedraw();
8199
- } //local data from local file
8200
-
8201
- }, {
8202
- key: "setDataFromLocalFile",
8203
- value: function setDataFromLocalFile(extensions) {
8204
- var _this2 = this;
8205
-
8206
- return new Promise(function (resolve, reject) {
8207
- var input = document.createElement("input");
8208
- input.type = "file";
8209
- input.accept = extensions || ".json,application/json";
8210
- input.addEventListener("change", function (e) {
8211
- var file = input.files[0],
8212
- reader = new FileReader(),
8213
- data;
8214
- reader.readAsText(file);
8215
-
8216
- reader.onload = function (e) {
8217
- try {
8218
- data = JSON.parse(reader.result);
8219
- } catch (e) {
8220
- console.warn("File Load Error - File contents is invalid JSON", e);
8221
- reject(e);
8222
- return;
8223
- }
8224
-
8225
- _this2.setData(data).then(function (data) {
8226
- resolve(data);
8227
- })["catch"](function (err) {
8228
- resolve(err);
8229
- });
8230
- };
8231
-
8232
- reader.onerror = function (e) {
8233
- console.warn("File Load Error - Unable to read file");
8234
- reject();
8235
- };
8236
- });
8237
- input.click();
8238
- });
8239
8248
  } //load data
8240
8249
 
8241
8250
  }, {
@@ -8280,13 +8289,13 @@
8280
8289
  }, {
8281
8290
  key: "updateData",
8282
8291
  value: function updateData(data) {
8283
- var _this3 = this;
8292
+ var _this2 = this;
8284
8293
 
8285
8294
  var responses = 0;
8286
8295
 
8287
8296
  if (this.initialized) {
8288
8297
  return new Promise(function (resolve, reject) {
8289
- _this3.dataLoader.blockActiveLoad();
8298
+ _this2.dataLoader.blockActiveLoad();
8290
8299
 
8291
8300
  if (typeof data === "string") {
8292
8301
  data = JSON.parse(data);
@@ -8294,7 +8303,7 @@
8294
8303
 
8295
8304
  if (data) {
8296
8305
  data.forEach(function (item) {
8297
- var row = _this3.rowManager.findRow(item[_this3.options.index]);
8306
+ var row = _this2.rowManager.findRow(item[_this2.options.index]);
8298
8307
 
8299
8308
  if (row) {
8300
8309
  responses++;
@@ -8319,18 +8328,18 @@
8319
8328
  }, {
8320
8329
  key: "addData",
8321
8330
  value: function addData(data, pos, index) {
8322
- var _this4 = this;
8331
+ var _this3 = this;
8323
8332
 
8324
8333
  if (this.initialized) {
8325
8334
  return new Promise(function (resolve, reject) {
8326
- _this4.dataLoader.blockActiveLoad();
8335
+ _this3.dataLoader.blockActiveLoad();
8327
8336
 
8328
8337
  if (typeof data === "string") {
8329
8338
  data = JSON.parse(data);
8330
8339
  }
8331
8340
 
8332
8341
  if (data) {
8333
- _this4.rowManager.addRows(data, pos, index).then(function (rows) {
8342
+ _this3.rowManager.addRows(data, pos, index).then(function (rows) {
8334
8343
  var output = [];
8335
8344
  rows.forEach(function (row) {
8336
8345
  output.push(row.getComponent());
@@ -8350,14 +8359,14 @@
8350
8359
  }, {
8351
8360
  key: "updateOrAddData",
8352
8361
  value: function updateOrAddData(data) {
8353
- var _this5 = this;
8362
+ var _this4 = this;
8354
8363
 
8355
8364
  var rows = [],
8356
8365
  responses = 0;
8357
8366
 
8358
8367
  if (this.initialized) {
8359
8368
  return new Promise(function (resolve, reject) {
8360
- _this5.dataLoader.blockActiveLoad();
8369
+ _this4.dataLoader.blockActiveLoad();
8361
8370
 
8362
8371
  if (typeof data === "string") {
8363
8372
  data = JSON.parse(data);
@@ -8365,7 +8374,7 @@
8365
8374
 
8366
8375
  if (data) {
8367
8376
  data.forEach(function (item) {
8368
- var row = _this5.rowManager.findRow(item[_this5.options.index]);
8377
+ var row = _this4.rowManager.findRow(item[_this4.options.index]);
8369
8378
 
8370
8379
  responses++;
8371
8380
 
@@ -8379,7 +8388,7 @@
8379
8388
  }
8380
8389
  });
8381
8390
  } else {
8382
- _this5.rowManager.addRows(item).then(function (newRows) {
8391
+ _this4.rowManager.addRows(item).then(function (newRows) {
8383
8392
  responses--;
8384
8393
  rows.push(newRows[0].getComponent());
8385
8394
 
@@ -8428,7 +8437,7 @@
8428
8437
  }, {
8429
8438
  key: "deleteRow",
8430
8439
  value: function deleteRow(index) {
8431
- var _this6 = this;
8440
+ var _this5 = this;
8432
8441
 
8433
8442
  var foundRows = [];
8434
8443
 
@@ -8461,7 +8470,7 @@
8461
8470
  }
8462
8471
 
8463
8472
  foundRows.sort(function (a, b) {
8464
- return _this6.rowManager.rows.indexOf(a) > _this6.rowManager.rows.indexOf(b) ? 1 : -1;
8473
+ return _this5.rowManager.rows.indexOf(a) > _this5.rowManager.rows.indexOf(b) ? 1 : -1;
8465
8474
  }); //delete rows
8466
8475
 
8467
8476
  foundRows.forEach(function (row) {
@@ -8691,13 +8700,13 @@
8691
8700
  }, {
8692
8701
  key: "scrollToColumn",
8693
8702
  value: function scrollToColumn(field, position, ifVisible) {
8694
- var _this7 = this;
8703
+ var _this6 = this;
8695
8704
 
8696
8705
  return new Promise(function (resolve, reject) {
8697
- var column = _this7.columnManager.findColumn(field);
8706
+ var column = _this6.columnManager.findColumn(field);
8698
8707
 
8699
8708
  if (column) {
8700
- return _this7.columnManager.scrollToColumn(column, position, ifVisible);
8709
+ return _this6.columnManager.scrollToColumn(column, position, ifVisible);
8701
8710
  } else {
8702
8711
  console.warn("Scroll Error - No matching column found:", field);
8703
8712
  return Promise.reject("Scroll Error - No matching column found");
@@ -9102,7 +9111,7 @@
9102
9111
  _classCallCheck(this, Ajax);
9103
9112
 
9104
9113
  _this = _super.call(this, table);
9105
- _this.config = false; //hold config object for ajax request
9114
+ _this.config = {}; //hold config object for ajax request
9106
9115
 
9107
9116
  _this.url = ""; //request URL
9108
9117
 
@@ -9143,22 +9152,31 @@
9143
9152
  this.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise;
9144
9153
  this.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator;
9145
9154
 
9146
- if (this.table.options.ajaxParams) {
9147
- this.setParams(this.table.options.ajaxParams);
9148
- }
9149
-
9150
- if (this.table.options.ajaxConfig) {
9151
- this.setConfig(this.table.options.ajaxConfig);
9152
- }
9153
-
9154
9155
  if (this.table.options.ajaxURL) {
9155
9156
  this.setUrl(this.table.options.ajaxURL);
9156
9157
  }
9157
9158
 
9159
+ this.setDefaultConfig(this.table.options.ajaxConfig);
9158
9160
  this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this));
9159
9161
  this.subscribe("data-loading", this.requestDataCheck.bind(this));
9162
+ this.subscribe("data-params", this.requestParams.bind(this));
9160
9163
  this.subscribe("data-load", this.requestData.bind(this));
9161
9164
  }
9165
+ }, {
9166
+ key: "requestParams",
9167
+ value: function requestParams(data, config, silent, params) {
9168
+ var ajaxParams = this.table.options.ajaxParams;
9169
+
9170
+ if (ajaxParams) {
9171
+ if (typeof ajaxParams === "function") {
9172
+ ajaxParams = ajaxParams.call(this.table);
9173
+ }
9174
+
9175
+ params = Object.assign(params, ajaxParams);
9176
+ }
9177
+
9178
+ return params;
9179
+ }
9162
9180
  }, {
9163
9181
  key: "requestDataCheck",
9164
9182
  value: function requestDataCheck(data, params, config, silent) {
@@ -9166,69 +9184,46 @@
9166
9184
  }
9167
9185
  }, {
9168
9186
  key: "requestData",
9169
- value: function requestData(data, params, config, silent, previousData) {
9170
- if (this.requestDataCheck(data)) {
9171
- if (data) {
9172
- this.setUrl(data);
9173
- }
9174
-
9175
- if (params) {
9176
- this.setParams(params, true);
9177
- }
9187
+ value: function requestData(url, params, config, silent, previousData) {
9188
+ var ajaxConfig;
9178
9189
 
9179
- if (config) {
9180
- this.setConfig(config);
9190
+ if (!previousData && this.requestDataCheck(url)) {
9191
+ if (url) {
9192
+ this.setUrl(url);
9181
9193
  }
9182
9194
 
9183
- return this.sendRequest();
9195
+ ajaxConfig = this.generateConfig(config);
9196
+ return this.sendRequest(this.url, params, ajaxConfig);
9184
9197
  } else {
9185
9198
  return previousData;
9186
9199
  }
9187
- } //set ajax params
9188
-
9200
+ }
9189
9201
  }, {
9190
- key: "setParams",
9191
- value: function setParams(params, update) {
9192
- if (update) {
9193
- this.params = this.params || {};
9202
+ key: "setDefaultConfig",
9203
+ value: function setDefaultConfig() {
9204
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9205
+ this.config = Object.assign({}, Ajax.defaultConfig);
9194
9206
 
9195
- for (var key in params) {
9196
- this.params[key] = params[key];
9197
- }
9207
+ if (typeof config == "string") {
9208
+ this.config.method = config;
9198
9209
  } else {
9199
- this.params = params;
9210
+ Object.assign(this.config, config);
9200
9211
  }
9201
- }
9202
- }, {
9203
- key: "getParams",
9204
- value: function getParams() {
9205
- return this.params || {};
9206
9212
  } //load config object
9207
9213
 
9208
9214
  }, {
9209
- key: "setConfig",
9210
- value: function setConfig(config) {
9211
- this._loadDefaultConfig();
9215
+ key: "generateConfig",
9216
+ value: function generateConfig() {
9217
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9218
+ var ajaxConfig = Object.assign({}, this.config);
9212
9219
 
9213
9220
  if (typeof config == "string") {
9214
- this.config.method = config;
9221
+ ajaxConfig.method = config;
9215
9222
  } else {
9216
- for (var key in config) {
9217
- this.config[key] = config[key];
9218
- }
9223
+ Object.assign(ajaxConfig, config);
9219
9224
  }
9220
- } //create config object from default
9221
-
9222
- }, {
9223
- key: "_loadDefaultConfig",
9224
- value: function _loadDefaultConfig(force) {
9225
- if (!this.config || force) {
9226
- this.config = {}; //load base config from defaults
9227
9225
 
9228
- for (var key in Ajax.defaultConfig) {
9229
- this.config[key] = Ajax.defaultConfig[key];
9230
- }
9231
- }
9226
+ return ajaxConfig;
9232
9227
  } //set request url
9233
9228
 
9234
9229
  }, {
@@ -9245,17 +9240,13 @@
9245
9240
 
9246
9241
  }, {
9247
9242
  key: "sendRequest",
9248
- value: function sendRequest(silent) {
9243
+ value: function sendRequest(url, params, config) {
9249
9244
  var _this2 = this;
9250
9245
 
9251
- var url = this.url;
9252
-
9253
- this._loadDefaultConfig();
9254
-
9255
- if (this.table.options.ajaxRequesting.call(this.table, this.url, this.params) !== false) {
9256
- return this.loaderPromise(url, this.config, this.params).then(function (data) {
9246
+ if (this.table.options.ajaxRequesting.call(this.table, url, params) !== false) {
9247
+ return this.loaderPromise(url, config, params).then(function (data) {
9257
9248
  if (_this2.table.options.ajaxResponse) {
9258
- data = _this2.table.options.ajaxResponse.call(_this2.table, _this2.url, _this2.params, data);
9249
+ data = _this2.table.options.ajaxResponse.call(_this2.table, url, params, data);
9259
9250
  }
9260
9251
 
9261
9252
  return data;
@@ -9861,7 +9852,7 @@
9861
9852
  this.subscribe("row-added", this.rowsUpdated.bind(this));
9862
9853
  this.subscribe("column-moved", this.recalcActiveRows.bind(this));
9863
9854
  this.subscribe("column-add", this.recalcActiveRows.bind(this));
9864
- this.subscribe("data-refeshed", this.recalcActiveRows.bind(this));
9855
+ this.subscribe("data-refreshed", this.recalcActiveRows.bind(this));
9865
9856
  this.subscribe("table-redraw", this.tableRedraw.bind(this));
9866
9857
  this.subscribe("rows-visible", this.visibleRows.bind(this));
9867
9858
  this.registerTableFunction("getCalcResults", this.getResults.bind(this));
@@ -10410,6 +10401,8 @@
10410
10401
 
10411
10402
  _this.registerComponentFunction("row", "addTreeChild", _this.addTreeChildRow.bind(_assertThisInitialized(_this)));
10412
10403
 
10404
+ _this.registerComponentFunction("row", "isTreeExpanded", _this.isRowExpanded.bind(_assertThisInitialized(_this)));
10405
+
10413
10406
  return _this;
10414
10407
  }
10415
10408
 
@@ -10790,6 +10783,11 @@
10790
10783
  }
10791
10784
  }
10792
10785
  }
10786
+ }, {
10787
+ key: "isRowExpanded",
10788
+ value: function isRowExpanded(row) {
10789
+ return row.modules.dataTree.open;
10790
+ }
10793
10791
  }, {
10794
10792
  key: "getTreeParent",
10795
10793
  value: function getTreeParent(row) {
@@ -11049,7 +11047,7 @@
11049
11047
  case "row":
11050
11048
  row.columns.forEach(function (col) {
11051
11049
  if (col) {
11052
- item[col.component.getField()] = col.value;
11050
+ item[col.component.getTitleDownload() || col.component.getField()] = col.value;
11053
11051
  }
11054
11052
  });
11055
11053
  fileContents.push(item);
@@ -11292,9 +11290,40 @@
11292
11290
  }
11293
11291
  }
11294
11292
 
11293
+ function jsonLines (list, options, setFileContents) {
11294
+ var fileContents = [];
11295
+ list.forEach(function (row) {
11296
+ var item = {};
11297
+
11298
+ switch (row.type) {
11299
+ case "header":
11300
+ break;
11301
+
11302
+ case "group":
11303
+ console.warn("Download Warning - JSON downloader cannot process row groups");
11304
+ break;
11305
+
11306
+ case "calc":
11307
+ console.warn("Download Warning - JSON downloader cannot process column calculations");
11308
+ break;
11309
+
11310
+ case "row":
11311
+ row.columns.forEach(function (col) {
11312
+ if (col) {
11313
+ item[col.component.getTitleDownload() || col.component.getField()] = col.value;
11314
+ }
11315
+ });
11316
+ fileContents.push(JSON.stringify(item));
11317
+ break;
11318
+ }
11319
+ });
11320
+ setFileContents(fileContents.join("\n"), "application/x-ndjson");
11321
+ }
11322
+
11295
11323
  var defaultDownloaders = {
11296
11324
  csv: csv,
11297
11325
  json: json,
11326
+ jsonLines: jsonLines,
11298
11327
  pdf: pdf,
11299
11328
  xlsx: xlsx,
11300
11329
  html: html
@@ -13308,12 +13337,12 @@
13308
13337
  this.subscribe("column-delete", this.columnDeleteCheck.bind(this));
13309
13338
  this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));
13310
13339
  this.subscribe("data-refeshing", this.cancelEdit.bind(this));
13311
- this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this));
13340
+ this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));
13312
13341
  this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));
13313
- this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this));
13314
- this.subscribe("keybinding-nav-right", this.navigateRight.bind(this));
13315
- this.subscribe("keybinding-nav-up", this.navigateUp.bind(this));
13316
- this.subscribe("keybinding-nav-down", this.navigateDown.bind(this));
13342
+ this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined));
13343
+ this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined));
13344
+ this.subscribe("keybinding-nav-up", this.navigateUp.bind(this, undefined));
13345
+ this.subscribe("keybinding-nav-down", this.navigateDown.bind(this, undefined));
13317
13346
  } ///////////////////////////////////
13318
13347
  ////// Keybinding Functions ///////
13319
13348
  ///////////////////////////////////
@@ -13325,10 +13354,9 @@
13325
13354
  newRow = this.options("tabEndNewRow");
13326
13355
 
13327
13356
  if (cell) {
13328
- if (!this.navigateNext(e)) {
13357
+ if (!this.navigateNext(cell, e)) {
13329
13358
  if (newRow) {
13330
- cell.getElement().firstChild.blur();
13331
-
13359
+ // cell.getElement().firstChild.blur();
13332
13360
  if (newRow === true) {
13333
13361
  newRow = this.table.addRow({});
13334
13362
  } else {
@@ -13341,7 +13369,7 @@
13341
13369
 
13342
13370
  newRow.then(function () {
13343
13371
  setTimeout(function () {
13344
- nav.next();
13372
+ cell.getComponent().navigateNext();
13345
13373
  });
13346
13374
  });
13347
13375
  }
@@ -13374,7 +13402,7 @@
13374
13402
  var _this2 = this;
13375
13403
 
13376
13404
  if (!cells) {
13377
- cells = this.modules.edit.getEditedCells();
13405
+ cells = this.table.modules.edit.getEditedCells();
13378
13406
  }
13379
13407
 
13380
13408
  if (!Array.isArray(cells)) {
@@ -13382,15 +13410,15 @@
13382
13410
  }
13383
13411
 
13384
13412
  cells.forEach(function (cell) {
13385
- _this2.modules.edit.clearEdited(cell._getSelf());
13413
+ _this2.table.modules.edit.clearEdited(cell._getSelf());
13386
13414
  });
13387
13415
  }
13388
13416
  }, {
13389
13417
  key: "navigatePrev",
13390
- value: function navigatePrev(e) {
13391
- var cell = this.currentCell,
13392
- nextCell,
13393
- prevRow;
13418
+ value: function navigatePrev() {
13419
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13420
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13421
+ var nextCell, prevRow;
13394
13422
 
13395
13423
  if (cell) {
13396
13424
  if (e) {
@@ -13419,10 +13447,10 @@
13419
13447
  }
13420
13448
  }, {
13421
13449
  key: "navigateNext",
13422
- value: function navigateNext(e) {
13423
- var cell = this.currentCell,
13424
- nextCell,
13425
- nextRow;
13450
+ value: function navigateNext() {
13451
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13452
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13453
+ var nextCell, nextRow;
13426
13454
 
13427
13455
  if (cell) {
13428
13456
  if (e) {
@@ -13451,10 +13479,10 @@
13451
13479
  }
13452
13480
  }, {
13453
13481
  key: "navigateLeft",
13454
- value: function navigateLeft(e) {
13455
- var cell = this.currentCell,
13456
- index,
13457
- nextCell;
13482
+ value: function navigateLeft() {
13483
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13484
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13485
+ var index, nextCell;
13458
13486
 
13459
13487
  if (cell) {
13460
13488
  if (e) {
@@ -13474,10 +13502,10 @@
13474
13502
  }
13475
13503
  }, {
13476
13504
  key: "navigateRight",
13477
- value: function navigateRight(e) {
13478
- var cell = this.currentCell,
13479
- index,
13480
- nextCell;
13505
+ value: function navigateRight() {
13506
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13507
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13508
+ var index, nextCell;
13481
13509
 
13482
13510
  if (cell) {
13483
13511
  if (e) {
@@ -13497,10 +13525,10 @@
13497
13525
  }
13498
13526
  }, {
13499
13527
  key: "navigateUp",
13500
- value: function navigateUp(e) {
13501
- var cell = this.currentCell,
13502
- index,
13503
- nextRow;
13528
+ value: function navigateUp() {
13529
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13530
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13531
+ var index, nextRow;
13504
13532
 
13505
13533
  if (cell) {
13506
13534
  if (e) {
@@ -13520,10 +13548,10 @@
13520
13548
  }
13521
13549
  }, {
13522
13550
  key: "navigateDown",
13523
- value: function navigateDown(e) {
13524
- var cell = this.currentCell,
13525
- index,
13526
- nextRow;
13551
+ value: function navigateDown() {
13552
+ var cell = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.currentCell;
13553
+ var e = arguments.length > 1 ? arguments[1] : undefined;
13554
+ var index, nextRow;
13527
13555
 
13528
13556
  if (cell) {
13529
13557
  if (e) {
@@ -13672,7 +13700,6 @@
13672
13700
  var cell = this.currentCell,
13673
13701
  cellEl;
13674
13702
  this.invalidEdit = false;
13675
- console.log("clear", cancel, cell, cell.validate);
13676
13703
 
13677
13704
  if (cell) {
13678
13705
  this.currentCell = false;
@@ -15141,7 +15168,7 @@
15141
15168
  }
15142
15169
  };
15143
15170
  params = column.definition.headerFilterParams || {};
15144
- params = typeof params === "function" ? params.call(self.table) : params;
15171
+ params = typeof params === "function" ? params.call(self.table, cellWrapper) : params;
15145
15172
  editorElement = editor.call(this.table.modules.edit, cellWrapper, function () {}, success, cancel, params);
15146
15173
 
15147
15174
  if (!editorElement) {
@@ -15856,7 +15883,7 @@
15856
15883
  var value = cell.getValue();
15857
15884
 
15858
15885
  if (typeof DT != "undefined") {
15859
- var newDatetime = DT.fromFormat(String(value), inputFormat);
15886
+ var newDatetime = inputFormat === "iso" ? DT.fromISO(String(value)) : DT.fromFormat(String(value), inputFormat);
15860
15887
 
15861
15888
  if (newDatetime.isValid) {
15862
15889
  if (formatterParams.timezone) {
@@ -15889,7 +15916,7 @@
15889
15916
  var value = cell.getValue();
15890
15917
 
15891
15918
  if (typeof DT != "undefined") {
15892
- var newDatetime = DT.fromFormat(String(value), inputFormat);
15919
+ var newDatetime = inputFormat === "iso" ? DT.fromISO(String(value)) : DT.fromFormat(String(value), inputFormat);
15893
15920
 
15894
15921
  if (newDatetime.isValid) {
15895
15922
  if (humanize) ; else {
@@ -16820,6 +16847,7 @@
16820
16847
 
16821
16848
  this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
16822
16849
  this.subscribe("row-deleting", this.detachRow.bind(this));
16850
+ this.subscribe("rows-visible", this.visibleRows.bind(this));
16823
16851
  this.registerDisplayHandler(this.getRows.bind(this), 10);
16824
16852
  }
16825
16853
  }, {
@@ -16832,6 +16860,14 @@
16832
16860
  key: "isFrozen",
16833
16861
  value: function isFrozen() {
16834
16862
  return !!this.rows.length;
16863
+ }
16864
+ }, {
16865
+ key: "visibleRows",
16866
+ value: function visibleRows(viewable, rows) {
16867
+ this.rows.forEach(function (row) {
16868
+ rows.push(row);
16869
+ });
16870
+ return rows;
16835
16871
  } //filter frozen rows out of display data
16836
16872
 
16837
16873
  }, {
@@ -17013,6 +17049,7 @@
17013
17049
  this.groups = [];
17014
17050
  this.groupList = [];
17015
17051
  this.generator = generator;
17052
+ this.element = false;
17016
17053
  this.elementContents = false;
17017
17054
  this.height = 0;
17018
17055
  this.outerHeight = 0;
@@ -17083,64 +17120,7 @@
17083
17120
  value: function addBindings() {
17084
17121
  var _this2 = this;
17085
17122
 
17086
- var dblTap, tapHold, tap, toggleElement;
17087
-
17088
- if ((this.groupManager.table.options.groupContextMenu || this.groupManager.table.options.groupClickMenu) && this.groupManager.table.modExists("menu")) {
17089
- this.groupManager.table.modules.menu.initializeGroup.call(this.groupManager.table.modules.menu, this);
17090
- }
17091
-
17092
- if (this.groupManager.table.options.groupTap) {
17093
- tap = false;
17094
- this.element.addEventListener("touchstart", function (e) {
17095
- tap = true;
17096
- }, {
17097
- passive: true
17098
- });
17099
- this.element.addEventListener("touchend", function (e) {
17100
- if (tap) {
17101
- _this2.groupManager.table.options.groupTap(e, _this2.getComponent());
17102
- }
17103
-
17104
- tap = false;
17105
- });
17106
- }
17107
-
17108
- if (this.groupManager.table.options.groupDblTap) {
17109
- dblTap = null;
17110
- this.element.addEventListener("touchend", function (e) {
17111
- if (dblTap) {
17112
- clearTimeout(dblTap);
17113
- dblTap = null;
17114
-
17115
- _this2.groupManager.table.options.groupDblTap(e, _this2.getComponent());
17116
- } else {
17117
- dblTap = setTimeout(function () {
17118
- clearTimeout(dblTap);
17119
- dblTap = null;
17120
- }, 300);
17121
- }
17122
- });
17123
- }
17124
-
17125
- if (this.groupManager.table.options.groupTapHold) {
17126
- tapHold = null;
17127
- this.element.addEventListener("touchstart", function (e) {
17128
- clearTimeout(tapHold);
17129
- tapHold = setTimeout(function () {
17130
- clearTimeout(tapHold);
17131
- tapHold = null;
17132
- tap = false;
17133
-
17134
- _this2.groupManager.table.options.groupTapHold(e, _this2.getComponent());
17135
- }, 1000);
17136
- }, {
17137
- passive: true
17138
- });
17139
- this.element.addEventListener("touchend", function (e) {
17140
- clearTimeout(tapHold);
17141
- tapHold = null;
17142
- });
17143
- }
17123
+ var toggleElement;
17144
17124
 
17145
17125
  if (this.groupManager.table.options.groupToggleElement) {
17146
17126
  toggleElement = this.groupManager.table.options.groupToggleElement == "arrow" ? this.arrowElement : this.element;
@@ -17742,13 +17722,12 @@
17742
17722
  key: "initialize",
17743
17723
  value: function initialize() {
17744
17724
  if (this.table.options.groupBy) {
17745
- this.configureGroupSetup();
17746
-
17747
17725
  if (this.table.options.groupUpdateOnCellEdit) {
17748
17726
  this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
17749
17727
  this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);
17750
17728
  }
17751
17729
 
17730
+ this.subscribe("table-built", this.configureGroupSetup.bind(this));
17752
17731
  this.subscribe("row-deleting", this.rowDeleting.bind(this));
17753
17732
  this.subscribe("row-deleted", this.rowsUpdated.bind(this));
17754
17733
  this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));
@@ -18700,6 +18679,280 @@
18700
18679
 
18701
18680
  HtmlTableImport.moduleName = "htmlTableImport";
18702
18681
 
18682
+ function csvImporter(input) {
18683
+ var data = [],
18684
+ row = 0,
18685
+ col = 0,
18686
+ inQuote = false; //Iterate over each character
18687
+
18688
+ for (var index = 0; index < input.length; index++) {
18689
+ var _char = input[index],
18690
+ nextChar = input[index + 1]; //Initialize empty row
18691
+
18692
+ if (!data[row]) {
18693
+ data[row] = [];
18694
+ } //Initialize empty column
18695
+
18696
+
18697
+ if (!data[row][col]) {
18698
+ data[row][col] = "";
18699
+ } //Handle quotation mark inside string
18700
+
18701
+
18702
+ if (_char == '"' && inQuote && nextChar == '"') {
18703
+ data[row][col] += _char;
18704
+ index++;
18705
+ continue;
18706
+ } //Begin / End Quote
18707
+
18708
+
18709
+ if (_char == '"') {
18710
+ inQuote = !inQuote;
18711
+ continue;
18712
+ } //Next column (if not in quote)
18713
+
18714
+
18715
+ if (_char == ',' && !inQuote) {
18716
+ col++;
18717
+ continue;
18718
+ } //New row if new line and not in quote (CRLF)
18719
+
18720
+
18721
+ if (_char == '\r' && nextChar == '\n' && !inQuote) {
18722
+ col = 0;
18723
+ row++;
18724
+ index++;
18725
+ continue;
18726
+ } //New row if new line and not in quote (CR or LF)
18727
+
18728
+
18729
+ if ((_char == '\r' || _char == '\n') && !inQuote) {
18730
+ col = 0;
18731
+ row++;
18732
+ continue;
18733
+ } //Normal Character, append to column
18734
+
18735
+
18736
+ data[row][col] += _char;
18737
+ }
18738
+
18739
+ return data;
18740
+ }
18741
+
18742
+ function json$1 (input) {
18743
+ try {
18744
+ return JSON.parse(input);
18745
+ } catch (e) {
18746
+ console.warn("JSON Import Error - File contents is invalid JSON", e);
18747
+ return Promise.reject();
18748
+ }
18749
+ }
18750
+
18751
+ var defaultImporters = {
18752
+ csv: csvImporter,
18753
+ json: json$1
18754
+ };
18755
+
18756
+ var Import = /*#__PURE__*/function (_Module) {
18757
+ _inherits(Import, _Module);
18758
+
18759
+ var _super = _createSuper(Import);
18760
+
18761
+ function Import(table) {
18762
+ var _this;
18763
+
18764
+ _classCallCheck(this, Import);
18765
+
18766
+ _this = _super.call(this, table);
18767
+
18768
+ _this.registerTableOption("importFormat");
18769
+
18770
+ _this.registerTableOption("importReader", "text");
18771
+
18772
+ return _this;
18773
+ }
18774
+
18775
+ _createClass(Import, [{
18776
+ key: "initialize",
18777
+ value: function initialize() {
18778
+ this.registerTableFunction("import", this.importFromFile.bind(this));
18779
+
18780
+ if (this.table.options.importFormat) {
18781
+ this.subscribe("data-loading", this.loadDataCheck.bind(this), 10);
18782
+ this.subscribe("data-load", this.loadData.bind(this), 10);
18783
+ }
18784
+ }
18785
+ }, {
18786
+ key: "loadDataCheck",
18787
+ value: function loadDataCheck(data) {
18788
+ return typeof data === "string";
18789
+ }
18790
+ }, {
18791
+ key: "loadData",
18792
+ value: function loadData(data, params, config, silent, previousData) {
18793
+ return this.importData(this.lookupImporter(), data).then(this.structureData.bind(this))["catch"](function (err) {
18794
+ console.error("Import Error:", err || "Unable to import data");
18795
+ return Promise.reject(err);
18796
+ });
18797
+ }
18798
+ }, {
18799
+ key: "lookupImporter",
18800
+ value: function lookupImporter(importFormat) {
18801
+ var importer;
18802
+
18803
+ if (!importFormat) {
18804
+ importFormat = this.table.options.importFormat;
18805
+ }
18806
+
18807
+ if (typeof importFormat === "string") {
18808
+ importer = Import.importers[importFormat];
18809
+ } else {
18810
+ importer = importFormat;
18811
+ }
18812
+
18813
+ if (!importer) {
18814
+ console.error("Import Error - Importer not found:", importFormat);
18815
+ }
18816
+
18817
+ return importer;
18818
+ }
18819
+ }, {
18820
+ key: "importFromFile",
18821
+ value: function importFromFile(importFormat, extension) {
18822
+ var importer = this.lookupImporter(importFormat);
18823
+
18824
+ if (importer) {
18825
+ return this.pickFile(extension).then(this.importData.bind(this, importer)).then(this.structureData.bind(this)).then(this.setData.bind(this))["catch"](function (err) {
18826
+ console.error("Import Error:", err || "Unable to import file");
18827
+ return Promise.reject(err);
18828
+ });
18829
+ }
18830
+ }
18831
+ }, {
18832
+ key: "pickFile",
18833
+ value: function pickFile(extensions) {
18834
+ var _this2 = this;
18835
+
18836
+ return new Promise(function (resolve, reject) {
18837
+ var input = document.createElement("input");
18838
+ input.type = "file";
18839
+ input.accept = extensions;
18840
+ input.addEventListener("change", function (e) {
18841
+ var file = input.files[0],
18842
+ reader = new FileReader();
18843
+
18844
+ switch (_this2.table.options.importReader) {
18845
+ case "buffer":
18846
+ reader.readAsArrayBuffer(file);
18847
+ break;
18848
+
18849
+ case "binary":
18850
+ reader.readAsBinaryString(file);
18851
+ break;
18852
+
18853
+ case "url":
18854
+ reader.readAsDataURL(file);
18855
+ break;
18856
+
18857
+ case "text":
18858
+ default:
18859
+ reader.readAsText(file);
18860
+ }
18861
+
18862
+ reader.onload = function (e) {
18863
+ resolve(reader.result);
18864
+ };
18865
+
18866
+ reader.onerror = function (e) {
18867
+ console.warn("File Load Error - Unable to read file");
18868
+ reject();
18869
+ };
18870
+ });
18871
+ input.click();
18872
+ });
18873
+ }
18874
+ }, {
18875
+ key: "importData",
18876
+ value: function importData(importer, fileContents) {
18877
+ var data = importer.call(this.table, fileContents);
18878
+
18879
+ if (data instanceof Promise) {
18880
+ return data;
18881
+ } else {
18882
+ return data ? Promise.resolve(data) : Promise.reject();
18883
+ }
18884
+ }
18885
+ }, {
18886
+ key: "structureData",
18887
+ value: function structureData(parsedData) {
18888
+ var data = [];
18889
+ console.log("structure", parsedData);
18890
+
18891
+ if (Array.isArray(parsedData) && parsedData.length && Array.isArray(parsedData[0])) {
18892
+ if (this.table.options.autoColumns) {
18893
+ data = this.structureArrayToObject(parsedData);
18894
+ } else {
18895
+ data = this.structureArrayToColumns(parsedData);
18896
+ }
18897
+
18898
+ return data;
18899
+ } else {
18900
+ return parsedData;
18901
+ }
18902
+ }
18903
+ }, {
18904
+ key: "structureArrayToObject",
18905
+ value: function structureArrayToObject(parsedData) {
18906
+ var columns = parsedData.shift();
18907
+ var data = parsedData.map(function (values) {
18908
+ var row = {};
18909
+ columns.forEach(function (key, i) {
18910
+ row[key] = values[i];
18911
+ });
18912
+ return row;
18913
+ });
18914
+ return data;
18915
+ }
18916
+ }, {
18917
+ key: "structureArrayToColumns",
18918
+ value: function structureArrayToColumns(parsedData) {
18919
+ var data = [],
18920
+ columns = this.table.getColumns(); //remove first row if it is the column names
18921
+
18922
+ if (columns[0] && parsedData[0][0]) {
18923
+ if (columns[0].getDefinition().title === parsedData[0][0]) {
18924
+ parsedData.shift();
18925
+ }
18926
+ } //convert row arrays to objects
18927
+
18928
+
18929
+ parsedData.forEach(function (rowData) {
18930
+ var row = {};
18931
+ rowData.forEach(function (value, index) {
18932
+ var column = columns[index];
18933
+
18934
+ if (column) {
18935
+ row[column.getField()] = value;
18936
+ }
18937
+ });
18938
+ data.push(row);
18939
+ });
18940
+ return data;
18941
+ }
18942
+ }, {
18943
+ key: "setData",
18944
+ value: function setData(data) {
18945
+ return this.table.setData(data);
18946
+ }
18947
+ }]);
18948
+
18949
+ return Import;
18950
+ }(Module);
18951
+
18952
+ Import.moduleName = "import"; //load defaults
18953
+
18954
+ Import.importers = defaultImporters;
18955
+
18703
18956
  var Interaction = /*#__PURE__*/function (_Module) {
18704
18957
  _inherits(Interaction, _Module);
18705
18958
 
@@ -18779,6 +19032,11 @@
18779
19032
  tap: null,
18780
19033
  tapDbl: null,
18781
19034
  tapHold: null
19035
+ },
19036
+ group: {
19037
+ tap: null,
19038
+ tapDbl: null,
19039
+ tapHold: null
18782
19040
  }
18783
19041
  };
18784
19042
 
@@ -19037,9 +19295,9 @@
19037
19295
  scrollPageDown: 34,
19038
19296
  scrollToStart: 36,
19039
19297
  scrollToEnd: 35,
19040
- undo: "ctrl + 90",
19041
- redo: "ctrl + 89",
19042
- copyToClipboard: "ctrl + 67"
19298
+ undo: ["ctrl + 90", "meta + 90"],
19299
+ redo: ["ctrl + 89", "meta + 89"],
19300
+ copyToClipboard: ["ctrl + 67", "meta + 89"]
19043
19301
  };
19044
19302
 
19045
19303
  var defaultActions = {
@@ -19166,7 +19424,7 @@
19166
19424
  _this.keyupBinding = false;
19167
19425
  _this.keydownBinding = false;
19168
19426
 
19169
- _this.registerTableOption("keybindings", []); //array for keybindings
19427
+ _this.registerTableOption("keybindings", {}); //array for keybindings
19170
19428
 
19171
19429
 
19172
19430
  _this.registerTableOption("tabEndNewRow", false); //create new row when tab to end of table
@@ -19184,16 +19442,8 @@
19184
19442
  this.pressedKeys = [];
19185
19443
 
19186
19444
  if (bindings !== false) {
19187
- for (var key in Keybindings.bindings) {
19188
- mergedBindings[key] = Keybindings.bindings[key];
19189
- }
19190
-
19191
- if (Object.keys(bindings).length) {
19192
- for (var _key in bindings) {
19193
- mergedBindings[_key] = bindings[_key];
19194
- }
19195
- }
19196
-
19445
+ Object.assign(mergedBindings, Keybindings.bindings);
19446
+ Object.assign(mergedBindings, bindings);
19197
19447
  this.mapBindings(mergedBindings);
19198
19448
  this.bindEvents();
19199
19449
  }
@@ -19213,7 +19463,10 @@
19213
19463
  }
19214
19464
 
19215
19465
  bindings[key].forEach(function (binding) {
19216
- _this2.mapBinding(key, binding);
19466
+ var bindingList = Array.isArray(binding) ? binding : [binding];
19467
+ bindingList.forEach(function (item) {
19468
+ _this2.mapBinding(key, item);
19469
+ });
19217
19470
  });
19218
19471
  }
19219
19472
  } else {
@@ -19253,7 +19506,7 @@
19253
19506
  break;
19254
19507
 
19255
19508
  default:
19256
- symbol = parseInt(symbol);
19509
+ symbol = isNaN(symbol) ? symbol.toUpperCase().charCodeAt(0) : parseInt(symbol);
19257
19510
  binding.keys.push(symbol);
19258
19511
 
19259
19512
  if (!_this3.watchKeys[symbol]) {
@@ -19355,11 +19608,14 @@
19355
19608
  _classCallCheck(this, Menu);
19356
19609
 
19357
19610
  _this = _super.call(this, table);
19611
+ _this.menuContainer = null;
19358
19612
  _this.menuElements = [];
19359
19613
  _this.blurEvent = _this.hideMenu.bind(_assertThisInitialized(_this));
19360
19614
  _this.escEvent = _this.escMenu.bind(_assertThisInitialized(_this));
19361
19615
  _this.nestedMenuBlock = false;
19362
19616
  _this.positionReversedX = false;
19617
+ _this.currentComponent = null;
19618
+ _this.columnSubscribers = {};
19363
19619
 
19364
19620
  _this.registerTableOption("rowContextMenu", false);
19365
19621
 
@@ -19369,8 +19625,12 @@
19369
19625
 
19370
19626
  _this.registerTableOption("groupClickMenu", false);
19371
19627
 
19628
+ _this.registerTableOption("menuContainer", false);
19629
+
19372
19630
  _this.registerColumnOption("headerContextMenu");
19373
19631
 
19632
+ _this.registerColumnOption("headerClickMenu");
19633
+
19374
19634
  _this.registerColumnOption("headerMenu");
19375
19635
 
19376
19636
  _this.registerColumnOption("contextMenu");
@@ -19383,133 +19643,157 @@
19383
19643
  _createClass(Menu, [{
19384
19644
  key: "initialize",
19385
19645
  value: function initialize() {
19386
- this.subscribe("cell-layout", this.layoutCell.bind(this));
19646
+ this.lookupMenuContainer();
19647
+ this.initializeRowWatchers();
19648
+ this.initializeGroupWatchers();
19387
19649
  this.subscribe("column-init", this.initializeColumn.bind(this));
19388
- this.subscribe("row-init", this.initializeRow.bind(this));
19389
19650
  }
19390
19651
  }, {
19391
- key: "layoutCell",
19392
- value: function layoutCell(cell) {
19393
- if (cell.column.definition.contextMenu || cell.column.definition.clickMenu) {
19394
- this.initializeCell(cell);
19652
+ key: "lookupMenuContainer",
19653
+ value: function lookupMenuContainer() {
19654
+ this.menuContainer = this.table.options.menuContainer;
19655
+
19656
+ if (typeof this.menuContainer === "string") {
19657
+ this.menuContainer = document.querySelector(this.menuContainer);
19658
+
19659
+ if (!this.menuContainer) {
19660
+ console.warn("Menu Error - no container element found matching selector:", this.table.options.menuContainer, "(defaulting to document body)");
19661
+ }
19662
+ } else if (this.menuContainer === true) {
19663
+ this.menuContainer = this.table.element;
19664
+ }
19665
+
19666
+ if (this.menuContainer && !this.checkMenuContainerIsParent(this.menuContainer)) {
19667
+ this.menuContainer = false;
19668
+ console.warn("Menu Error - container element does not contain this table:", this.table.options.menuContainer, "(defaulting to document body)");
19669
+ }
19670
+
19671
+ if (!this.menuContainer) {
19672
+ this.menuContainer = document.body;
19395
19673
  }
19396
19674
  }
19397
19675
  }, {
19398
- key: "initializeColumn",
19399
- value: function initializeColumn(column) {
19400
- var def = column.definition;
19676
+ key: "checkMenuContainerIsParent",
19677
+ value: function checkMenuContainerIsParent(container) {
19678
+ var element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.table.element;
19401
19679
 
19402
- if (def.headerContextMenu || def.headerClickMenu || def.headerMenu) {
19403
- this.initializeColumnHeader(column);
19680
+ if (container === element) {
19681
+ return true;
19682
+ } else {
19683
+ return element.parentNode ? this.checkMenuContainerIsParent(container, element.parentNode) : false;
19404
19684
  }
19405
19685
  }
19406
19686
  }, {
19407
- key: "initializeColumnHeader",
19408
- value: function initializeColumnHeader(column) {
19409
- var _this2 = this;
19687
+ key: "initializeRowWatchers",
19688
+ value: function initializeRowWatchers() {
19689
+ if (this.table.options.rowContextMenu) {
19690
+ this.subscribe("row-contextmenu", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));
19691
+ this.table.on("rowTapHold", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));
19692
+ }
19410
19693
 
19411
- var headerMenuEl;
19694
+ if (this.table.options.rowClickMenu) {
19695
+ this.subscribe("row-click", this.loadMenuEvent.bind(this, this.table.options.rowClickMenu));
19696
+ }
19697
+ }
19698
+ }, {
19699
+ key: "initializeGroupWatchers",
19700
+ value: function initializeGroupWatchers() {
19701
+ if (this.table.options.groupContextMenu) {
19702
+ this.subscribe("group-contextmenu", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));
19703
+ this.table.on("groupTapHold", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));
19704
+ }
19412
19705
 
19413
- if (column.definition.headerContextMenu) {
19414
- column.getElement().addEventListener("contextmenu", this.LoadMenuEvent.bind(this, column, column.definition.headerContextMenu));
19415
- this.tapHold(column, column.definition.headerContextMenu);
19416
- } // if(column.definition.headerClickMenu){
19417
- // column.getElement().addEventListener("click", this.LoadMenuEvent.bind(this, column, column.definition.headerClickMenu));
19418
- // }
19706
+ if (this.table.options.groupClickMenu) {
19707
+ this.subscribe("group-click", this.loadMenuEvent.bind(this, this.table.options.groupClickMenu));
19708
+ }
19709
+ }
19710
+ }, {
19711
+ key: "initializeColumn",
19712
+ value: function initializeColumn(column) {
19713
+ var def = column.definition; //handle column events
19419
19714
 
19715
+ if (def.headerContextMenu && !this.columnSubscribers.headerContextMenu) {
19716
+ this.columnSubscribers.headerContextMenu = this.loadMenuTableColumnEvent.bind(this, "headerContextMenu");
19717
+ this.subscribe("column-contextmenu", this.columnSubscribers.headerContextMenu);
19718
+ this.table.on("headerTapHold", this.loadMenuTableColumnEvent.bind(this, "headerContextMenu"));
19719
+ }
19420
19720
 
19421
- if (column.definition.headerMenu) {
19422
- headerMenuEl = document.createElement("span");
19423
- headerMenuEl.classList.add("tabulator-header-menu-button");
19424
- headerMenuEl.innerHTML = "&vellip;";
19425
- headerMenuEl.addEventListener("click", function (e) {
19426
- e.stopPropagation();
19427
- e.preventDefault();
19721
+ if (def.headerClickMenu && !this.columnSubscribers.headerClickMenu) {
19722
+ this.columnSubscribers.headerClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerClickMenu");
19723
+ this.subscribe("column-click", this.columnSubscribers.headerClickMenu);
19724
+ }
19428
19725
 
19429
- _this2.LoadMenuEvent(column, column.definition.headerMenu, e);
19430
- });
19431
- column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);
19726
+ if (def.headerMenu) {
19727
+ this.initializeColumnHeaderMenu(column);
19728
+ } //handle cell events
19729
+
19730
+
19731
+ if (def.contextMenu && !this.columnSubscribers.contextMenu) {
19732
+ this.columnSubscribers.contextMenu = this.loadMenuTableCellEvent.bind(this, "contextMenu");
19733
+ this.subscribe("cell-contextmenu", this.columnSubscribers.contextMenu);
19734
+ this.table.on("cellTapHold", this.loadMenuTableCellEvent.bind(this, "contextMenu"));
19432
19735
  }
19433
- }
19434
- }, {
19435
- key: "LoadMenuEvent",
19436
- value: function LoadMenuEvent(component, menu, e) {
19437
- menu = typeof menu == "function" ? menu.call(this.table, component.getComponent(), e) : menu; // if(component instanceof Cell){
19438
- // e.stopImmediatePropagation();
19439
- // }
19440
19736
 
19441
- this.loadMenu(e, component, menu);
19737
+ if (def.clickMenu && !this.columnSubscribers.clickMenu) {
19738
+ this.columnSubscribers.clickMenu = this.loadMenuTableCellEvent.bind(this, "clickMenu");
19739
+ this.subscribe("cell-click", this.columnSubscribers.clickMenu);
19740
+ }
19442
19741
  }
19443
19742
  }, {
19444
- key: "tapHold",
19445
- value: function tapHold(component, menu) {
19446
- var _this3 = this;
19447
-
19448
- var element = component.getElement(),
19449
- tapHold = null,
19450
- loaded = false;
19451
- element.addEventListener("touchstart", function (e) {
19452
- clearTimeout(tapHold);
19453
- loaded = false;
19454
- tapHold = setTimeout(function () {
19455
- clearTimeout(tapHold);
19456
- tapHold = null;
19457
- loaded = true;
19743
+ key: "initializeColumnHeaderMenu",
19744
+ value: function initializeColumnHeaderMenu(column) {
19745
+ var _this2 = this;
19458
19746
 
19459
- _this3.LoadMenuEvent(component, menu, e);
19460
- }, 1000);
19461
- }, {
19462
- passive: true
19463
- });
19464
- element.addEventListener("touchend", function (e) {
19465
- clearTimeout(tapHold);
19466
- tapHold = null;
19747
+ var headerMenuEl;
19748
+ headerMenuEl = document.createElement("span");
19749
+ headerMenuEl.classList.add("tabulator-header-menu-button");
19750
+ headerMenuEl.innerHTML = "&vellip;";
19751
+ headerMenuEl.addEventListener("click", function (e) {
19752
+ e.stopPropagation();
19753
+ e.preventDefault();
19467
19754
 
19468
- if (loaded) {
19469
- e.preventDefault();
19470
- }
19755
+ _this2.loadMenuEvent(column.definition.headerMenu, e, column);
19471
19756
  });
19757
+ column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);
19472
19758
  }
19473
19759
  }, {
19474
- key: "initializeCell",
19475
- value: function initializeCell(cell) {
19476
- if (cell.column.definition.contextMenu) {
19477
- cell.getElement(true).addEventListener("contextmenu", this.LoadMenuEvent.bind(this, cell, cell.column.definition.contextMenu));
19478
- this.tapHold(cell, cell.column.definition.contextMenu);
19760
+ key: "loadMenuTableCellEvent",
19761
+ value: function loadMenuTableCellEvent(option, e, cell) {
19762
+ if (cell._cell) {
19763
+ cell = cell._cell;
19479
19764
  }
19480
19765
 
19481
- if (cell.column.definition.clickMenu) {
19482
- cell.getElement(true).addEventListener("click", this.LoadMenuEvent.bind(this, cell, cell.column.definition.clickMenu));
19766
+ if (cell.column.definition[option]) {
19767
+ this.loadMenuEvent(cell.column.definition[option], e, cell);
19483
19768
  }
19484
19769
  }
19485
19770
  }, {
19486
- key: "initializeRow",
19487
- value: function initializeRow(row) {
19488
- if (this.table.options.rowContextMenu) {
19489
- row.getElement().addEventListener("contextmenu", this.LoadMenuEvent.bind(this, row, this.table.options.rowContextMenu));
19490
- this.tapHold(row, this.table.options.rowContextMenu);
19771
+ key: "loadMenuTableColumnEvent",
19772
+ value: function loadMenuTableColumnEvent(option, e, column) {
19773
+ if (column._column) {
19774
+ column = column._column;
19491
19775
  }
19492
19776
 
19493
- if (this.table.options.rowClickMenu) {
19494
- row.getElement().addEventListener("click", this.LoadMenuEvent.bind(this, row, this.table.options.rowClickMenu));
19777
+ if (column.definition[option]) {
19778
+ this.loadMenuEvent(column.definition[option], e, column);
19495
19779
  }
19496
19780
  }
19497
19781
  }, {
19498
- key: "initializeGroup",
19499
- value: function initializeGroup(group) {
19500
- if (this.table.options.groupContextMenu) {
19501
- group.getElement().addEventListener("contextmenu", this.LoadMenuEvent.bind(this, group, this.table.options.groupContextMenu));
19502
- this.tapHold(group, this.table.options.groupContextMenu);
19782
+ key: "loadMenuEvent",
19783
+ value: function loadMenuEvent(menu, e, component) {
19784
+ if (component._group) {
19785
+ component = component._group;
19786
+ } else if (component._row) {
19787
+ component = component._row;
19503
19788
  }
19504
19789
 
19505
- if (this.table.options.groupClickMenu) {
19506
- group.getElement().addEventListener("click", this.LoadMenuEvent.bind(this, group, this.table.options.groupClickMenu));
19507
- }
19790
+ menu = typeof menu == "function" ? menu.call(this.table, component.getComponent(), e) : menu;
19791
+ this.loadMenu(e, component, menu);
19508
19792
  }
19509
19793
  }, {
19510
19794
  key: "loadMenu",
19511
19795
  value: function loadMenu(e, component, menu, parentEl) {
19512
- var _this4 = this;
19796
+ var _this3 = this;
19513
19797
 
19514
19798
  var touch = !(e instanceof MouseEvent);
19515
19799
  var menuEl = document.createElement("div");
@@ -19532,7 +19816,7 @@
19532
19816
  }
19533
19817
  } else {
19534
19818
  this.nestedMenuBlock = setTimeout(function () {
19535
- _this4.nestedMenuBlock = false;
19819
+ _this3.nestedMenuBlock = false;
19536
19820
  }, 100);
19537
19821
  }
19538
19822
 
@@ -19551,7 +19835,7 @@
19551
19835
  itemEl.classList.add("tabulator-menu-item");
19552
19836
 
19553
19837
  if (typeof label == "function") {
19554
- label = label.call(_this4.table, component.getComponent());
19838
+ label = label.call(_this3.table, component.getComponent());
19555
19839
  }
19556
19840
 
19557
19841
  if (label instanceof Node) {
@@ -19561,7 +19845,7 @@
19561
19845
  }
19562
19846
 
19563
19847
  if (typeof disabled == "function") {
19564
- disabled = disabled.call(_this4.table, component.getComponent());
19848
+ disabled = disabled.call(_this3.table, component.getComponent());
19565
19849
  }
19566
19850
 
19567
19851
  if (disabled) {
@@ -19574,9 +19858,9 @@
19574
19858
  itemEl.addEventListener("click", function (e) {
19575
19859
  e.stopPropagation();
19576
19860
 
19577
- _this4.hideOldSubMenus(menuEl);
19861
+ _this3.hideOldSubMenus(menuEl);
19578
19862
 
19579
- _this4.loadMenu(e, component, item.menu, itemEl);
19863
+ _this3.loadMenu(e, component, item.menu, itemEl);
19580
19864
  });
19581
19865
  } else {
19582
19866
  if (item.action) {
@@ -19595,10 +19879,12 @@
19595
19879
  menuEl.appendChild(itemEl);
19596
19880
  });
19597
19881
  menuEl.addEventListener("click", function (e) {
19598
- _this4.hideMenu();
19882
+ _this3.hideMenu();
19599
19883
  });
19600
19884
  this.menuElements.push(menuEl);
19601
19885
  this.positionMenu(menuEl, parentEl, touch, e);
19886
+ this.currentComponent = component;
19887
+ this.dispatchExternal("menuOpened", component.getComponent());
19602
19888
  }
19603
19889
  }, {
19604
19890
  key: "hideOldSubMenus",
@@ -19620,16 +19906,20 @@
19620
19906
  }, {
19621
19907
  key: "positionMenu",
19622
19908
  value: function positionMenu(element, parentEl, touch, e) {
19623
- var _this5 = this;
19909
+ var _this4 = this;
19624
19910
 
19625
- var docHeight = Math.max(document.body.offsetHeight, window.innerHeight),
19626
- x,
19627
- y,
19628
- parentOffset;
19911
+ var x, y, parentOffset;
19629
19912
 
19630
19913
  if (!parentEl) {
19631
19914
  x = touch ? e.touches[0].pageX : e.pageX;
19632
19915
  y = touch ? e.touches[0].pageY : e.pageY;
19916
+
19917
+ if (this.menuContainer !== document.body) {
19918
+ parentOffset = Helpers.elOffset(this.menuContainer);
19919
+ x -= parentOffset.left;
19920
+ y -= parentOffset.top;
19921
+ }
19922
+
19633
19923
  this.positionReversedX = false;
19634
19924
  } else {
19635
19925
  parentOffset = Helpers.elOffset(parentEl);
@@ -19640,36 +19930,36 @@
19640
19930
  element.style.top = y + "px";
19641
19931
  element.style.left = x + "px";
19642
19932
  setTimeout(function () {
19643
- _this5.table.rowManager.element.addEventListener("scroll", _this5.blurEvent);
19933
+ _this4.table.rowManager.element.addEventListener("scroll", _this4.blurEvent);
19644
19934
 
19645
- document.body.addEventListener("click", _this5.blurEvent);
19646
- document.body.addEventListener("contextmenu", _this5.blurEvent);
19647
- window.addEventListener("resize", _this5.blurEvent);
19648
- document.body.addEventListener("keydown", _this5.escEvent);
19935
+ document.body.addEventListener("click", _this4.blurEvent);
19936
+ document.body.addEventListener("contextmenu", _this4.blurEvent);
19937
+ window.addEventListener("resize", _this4.blurEvent);
19938
+ document.body.addEventListener("keydown", _this4.escEvent);
19649
19939
  }, 100);
19650
- document.body.appendChild(element); //move menu to start on bottom edge if it is too close to the edge of the screen
19940
+ this.menuContainer.appendChild(element); //move menu to start on right edge if it is too close to the edge of the screen
19651
19941
 
19652
- if (y + element.offsetHeight >= docHeight) {
19653
- element.style.top = "";
19942
+ if (x + element.offsetWidth >= this.menuContainer.offsetWidth || this.positionReversedX) {
19943
+ element.style.left = "";
19654
19944
 
19655
19945
  if (parentEl) {
19656
- element.style.bottom = docHeight - parentOffset.top - parentEl.offsetHeight - 1 + "px";
19946
+ element.style.right = this.menuContainer.offsetWidth - parentOffset.left + "px";
19657
19947
  } else {
19658
- element.style.bottom = docHeight - y + "px";
19948
+ element.style.right = this.menuContainer.offsetWidth - x + "px";
19659
19949
  }
19660
- } //move menu to start on right edge if it is too close to the edge of the screen
19661
19950
 
19951
+ this.positionReversedX = true;
19952
+ } //move menu to start on bottom edge if it is too close to the edge of the screen
19662
19953
 
19663
- if (x + element.offsetWidth >= document.body.offsetWidth || this.positionReversedX) {
19664
- element.style.left = "";
19954
+
19955
+ if (y + element.offsetHeight >= this.menuContainer.offsetHeight) {
19956
+ element.style.top = "";
19665
19957
 
19666
19958
  if (parentEl) {
19667
- element.style.right = document.documentElement.offsetWidth - parentOffset.left + "px";
19959
+ element.style.bottom = this.menuContainer.offsetHeight - parentOffset.top - parentEl.offsetHeight - 1 + "px";
19668
19960
  } else {
19669
- element.style.right = document.documentElement.offsetWidth - x + "px";
19961
+ element.style.bottom = this.menuContainer.offsetHeight - y + "px";
19670
19962
  }
19671
-
19672
- this.positionReversedX = true;
19673
19963
  }
19674
19964
  }
19675
19965
  }, {
@@ -19697,6 +19987,11 @@
19697
19987
  document.body.removeEventListener("contextmenu", this.blurEvent);
19698
19988
  window.removeEventListener("resize", this.blurEvent);
19699
19989
  this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);
19990
+
19991
+ if (this.currentComponent) {
19992
+ this.dispatchExternal("menuClosed", this.currentComponent.getComponent());
19993
+ this.currentComponent = null;
19994
+ }
19700
19995
  }
19701
19996
  }]);
19702
19997
 
@@ -20372,6 +20667,7 @@
20372
20667
 
20373
20668
  document.body.addEventListener("mousemove", this.moveHover);
20374
20669
  document.body.addEventListener("mouseup", this.endMove);
20670
+ this.dispatchExternal("rowMoving", row.getComponent());
20375
20671
  this.moveHover(e);
20376
20672
  }
20377
20673
  }, {
@@ -20407,6 +20703,8 @@
20407
20703
 
20408
20704
  if (this.toRow) {
20409
20705
  this.table.rowManager.moveRow(this.moving, this.toRow, this.toRowAfter);
20706
+ } else {
20707
+ this.dispatchExternal("rowMoveCancelled", this.moving.getComponent());
20410
20708
  }
20411
20709
 
20412
20710
  this.moving = false;
@@ -20838,6 +21136,63 @@
20838
21136
 
20839
21137
  Mutator.mutators = defaultMutators;
20840
21138
 
21139
+ function rows (pageSize, currentRow, currentPage, totalRows, totalPages) {
21140
+ var el = document.createElement("span"),
21141
+ showingEl = document.createElement("span"),
21142
+ valueEl = document.createElement("span"),
21143
+ ofEl = document.createElement("span"),
21144
+ totalEl = document.createElement("span"),
21145
+ rowsEl = document.createElement("span");
21146
+ this.table.modules.localize.langBind("pagination|counter|showing", function (value) {
21147
+ showingEl.innerHTML = value;
21148
+ });
21149
+ valueEl.innerHTML = " " + currentRow + "-" + Math.min(currentRow + pageSize - 1, totalRows) + " ";
21150
+ this.table.modules.localize.langBind("pagination|counter|of", function (value) {
21151
+ ofEl.innerHTML = value;
21152
+ });
21153
+ totalEl.innerHTML = " " + totalRows + " ";
21154
+ this.table.modules.localize.langBind("pagination|counter|rows", function (value) {
21155
+ rowsEl.innerHTML = value;
21156
+ });
21157
+ el.appendChild(showingEl);
21158
+ el.appendChild(valueEl);
21159
+ el.appendChild(ofEl);
21160
+ el.appendChild(totalEl);
21161
+ el.appendChild(rowsEl);
21162
+ return el;
21163
+ }
21164
+
21165
+ function pages (pageSize, currentRow, currentPage, totalRows, totalPages) {
21166
+ var el = document.createElement("span"),
21167
+ showingEl = document.createElement("span"),
21168
+ valueEl = document.createElement("span"),
21169
+ ofEl = document.createElement("span"),
21170
+ totalEl = document.createElement("span"),
21171
+ rowsEl = document.createElement("span");
21172
+ this.table.modules.localize.langBind("pagination|counter|showing", function (value) {
21173
+ showingEl.innerHTML = value;
21174
+ });
21175
+ valueEl.innerHTML = " " + currentPage + " ";
21176
+ this.table.modules.localize.langBind("pagination|counter|of", function (value) {
21177
+ ofEl.innerHTML = value;
21178
+ });
21179
+ totalEl.innerHTML = " " + totalPages + " ";
21180
+ this.table.modules.localize.langBind("pagination|counter|pages", function (value) {
21181
+ rowsEl.innerHTML = value;
21182
+ });
21183
+ el.appendChild(showingEl);
21184
+ el.appendChild(valueEl);
21185
+ el.appendChild(ofEl);
21186
+ el.appendChild(totalEl);
21187
+ el.appendChild(rowsEl);
21188
+ return el;
21189
+ }
21190
+
21191
+ var defaultPageCounters = {
21192
+ rows: rows,
21193
+ pages: pages
21194
+ };
21195
+
20841
21196
  var Page = /*#__PURE__*/function (_Module) {
20842
21197
  _inherits(Page, _Module);
20843
21198
 
@@ -20851,10 +21206,14 @@
20851
21206
  _this = _super.call(this, table);
20852
21207
  _this.mode = "local";
20853
21208
  _this.progressiveLoad = false;
21209
+ _this.element = null;
21210
+ _this.pageCounterElement = null;
21211
+ _this.pageCounter = null;
20854
21212
  _this.size = 0;
20855
21213
  _this.page = 1;
20856
21214
  _this.count = 5;
20857
21215
  _this.max = 1;
21216
+ _this.remoteRowCountEstimate = null;
20858
21217
  _this.displayIndex = 0; //index in display pipeline
20859
21218
 
20860
21219
  _this.initialLoad = true;
@@ -20874,6 +21233,12 @@
20874
21233
  _this.registerTableOption("paginationInitialPage", 1); //initial page to show on load
20875
21234
 
20876
21235
 
21236
+ _this.registerTableOption("paginationCounter", false); // set pagination counter
21237
+
21238
+
21239
+ _this.registerTableOption("paginationCounterElement", false); // set pagination counter
21240
+
21241
+
20877
21242
  _this.registerTableOption("paginationButtonCount", 5); // set count of page button
20878
21243
 
20879
21244
 
@@ -20943,6 +21308,7 @@
20943
21308
  this.registerDisplayHandler(this.restOnRenderBefore.bind(this), 40);
20944
21309
  this.registerDisplayHandler(this.getRows.bind(this), 50);
20945
21310
  this.createElements();
21311
+ this.initializePageCounter();
20946
21312
  this.initializePaginator();
20947
21313
  } else if (this.table.options.progressiveLoad) {
20948
21314
  this.subscribe("data-params", this.remotePageParams.bind(this));
@@ -21166,14 +21532,36 @@
21166
21532
  });
21167
21533
  this.pageSizeSelect.value = this.size;
21168
21534
  }
21169
- } //setup pageination
21535
+ }
21536
+ }, {
21537
+ key: "initializePageCounter",
21538
+ value: function initializePageCounter() {
21539
+ var counter = this.table.options.paginationCounter,
21540
+ pageCounter = null;
21541
+
21542
+ if (counter) {
21543
+ if (typeof counter === "function") {
21544
+ pageCounter = counter;
21545
+ } else {
21546
+ pageCounter = Page.pageCounters[counter];
21547
+ }
21548
+
21549
+ if (pageCounter) {
21550
+ this.pageCounter = pageCounter;
21551
+ this.pageCounterElement = document.createElement("span");
21552
+ this.pageCounterElement.classList.add("tabulator-page-counter");
21553
+ } else {
21554
+ console.warn("Pagination Error - No such page counter found: ", counter);
21555
+ }
21556
+ }
21557
+ } //setup pagination
21170
21558
 
21171
21559
  }, {
21172
21560
  key: "initializePaginator",
21173
21561
  value: function initializePaginator(hidden) {
21174
21562
  var _this3 = this;
21175
21563
 
21176
- var pageSelectLabel;
21564
+ var pageSelectLabel, paginationCounterHolder;
21177
21565
 
21178
21566
  if (!hidden) {
21179
21567
  //build pagination element
@@ -21254,6 +21642,25 @@
21254
21642
  this.element.appendChild(this.lastBut);
21255
21643
 
21256
21644
  if (!this.table.options.paginationElement && !hidden) {
21645
+ if (this.table.options.paginationCounter) {
21646
+
21647
+ if (this.table.options.paginationCounterElement) {
21648
+ if (this.table.options.paginationCounterElement instanceof HTMLElement) {
21649
+ this.table.options.paginationCounterElement.appendChild(this.pageCounterElement);
21650
+ } else if (typeof this.table.options.paginationCounterElement === "string") {
21651
+ paginationCounterHolder = document.querySelector(this.table.options.paginationCounterElement);
21652
+
21653
+ if (paginationCounterHolder) {
21654
+ paginationCounterHolder.appendChild(this.pageCounterElement);
21655
+ } else {
21656
+ console.warn("Pagination Error - Unable to find element matching paginationCounterElement selector:", this.table.options.paginationCounterElement);
21657
+ }
21658
+ }
21659
+ } else {
21660
+ this.table.footerManager.append(this.pageCounterElement);
21661
+ }
21662
+ }
21663
+
21257
21664
  this.table.footerManager.append(this.element, this);
21258
21665
  }
21259
21666
 
@@ -21382,6 +21789,49 @@
21382
21789
  }
21383
21790
 
21384
21791
  this.trackChanges();
21792
+ }
21793
+ }, {
21794
+ key: "_setPageCounter",
21795
+ value: function _setPageCounter(totalRows) {
21796
+ var content, currentRow;
21797
+
21798
+ if (this.pageCounter) {
21799
+ currentRow = (this.page - 1) * this.size + 1;
21800
+
21801
+ if (this.mode === "remote") {
21802
+ totalRows = this.remoteRowCountEstimate;
21803
+ }
21804
+
21805
+ content = this.pageCounter.call(this, this.size, currentRow, this.page, totalRows, this.max);
21806
+
21807
+ switch (_typeof(content)) {
21808
+ case "object":
21809
+ if (content instanceof Node) {
21810
+ //clear previous cell contents
21811
+ while (this.pageCounterElement.firstChild) {
21812
+ this.pageCounterElement.removeChild(this.pageCounterElement.firstChild);
21813
+ }
21814
+
21815
+ this.pageCounterElement.appendChild(content);
21816
+ } else {
21817
+ this.pageCounterElement.innerHTML = "";
21818
+
21819
+ if (content != null) {
21820
+ console.warn("Page Counter Error - Page Counter has returned a type of object, the only valid page counter object return is an instance of Node, the page counter returned:", content);
21821
+ }
21822
+ }
21823
+
21824
+ break;
21825
+
21826
+ case "undefined":
21827
+ case "null":
21828
+ this.pageCounterElement.innerHTML = "";
21829
+ break;
21830
+
21831
+ default:
21832
+ this.pageCounterElement.innerHTML = content;
21833
+ }
21834
+ }
21385
21835
  } //setup the pagination buttons
21386
21836
 
21387
21837
  }, {
@@ -21522,10 +21972,14 @@
21522
21972
  }
21523
21973
  }
21524
21974
 
21975
+ this._setPageCounter(data.length);
21976
+
21525
21977
  return output;
21526
21978
  } else {
21527
21979
  this._setPageButtons();
21528
21980
 
21981
+ this._setPageCounter(data.length);
21982
+
21529
21983
  return data.slice(0);
21530
21984
  }
21531
21985
  }
@@ -21572,6 +22026,7 @@
21572
22026
 
21573
22027
  if (data.data) {
21574
22028
  this.max = parseInt(data.last_page) || 1;
22029
+ this.remoteRowCountEstimate = typeof data.last_row !== "undefined" ? data.last_row : data.last_page * this.size - (this.page == data.last_page ? this.size - data.data.length : 0);
21575
22030
 
21576
22031
  if (this.progressiveLoad) {
21577
22032
  switch (this.mode) {
@@ -21637,7 +22092,9 @@
21637
22092
  return Page;
21638
22093
  }(Module);
21639
22094
 
21640
- Page.moduleName = "page";
22095
+ Page.moduleName = "page"; //load defaults
22096
+
22097
+ Page.pageCounters = defaultPageCounters;
21641
22098
 
21642
22099
  // read peristence information from storage
21643
22100
  var defaultReaders = {
@@ -22913,7 +23370,7 @@
22913
23370
  handle.removeEventListener("touchmove", mouseMove);
22914
23371
  handle.removeEventListener("touchend", mouseUp);
22915
23372
  self.table.element.classList.remove("tabulator-block-select");
22916
- this.dispatchExternal("rowResized", row.getComponent());
23373
+ self.dispatchExternal("rowResized", row.getComponent());
22917
23374
  }
22918
23375
 
22919
23376
  e.stopPropagation(); //prevent resize from interfereing with movable columns
@@ -24010,8 +24467,8 @@
24010
24467
  emptyAlign = 0;
24011
24468
 
24012
24469
  if (typeof DT != "undefined") {
24013
- a = DT.fromFormat(String(a), format);
24014
- b = DT.fromFormat(String(b), format);
24470
+ a = format === "iso" ? DT.fromISO(String(a)) : DT.fromFormat(String(a), format);
24471
+ b = format === "iso" ? DT.fromISO(String(b)) : DT.fromFormat(String(b), format);
24015
24472
 
24016
24473
  if (!a.isValid) {
24017
24474
  emptyAlign = !b.isValid ? 0 : -1;
@@ -24815,9 +25272,11 @@
24815
25272
  }, {
24816
25273
  key: "columnValidate",
24817
25274
  value: function columnValidate(column) {
25275
+ var _this2 = this;
25276
+
24818
25277
  var invalid = [];
24819
25278
  column.cells.forEach(function (cell) {
24820
- if (!this.cellValidate(cell)) {
25279
+ if (!_this2.cellValidate(cell)) {
24821
25280
  invalid.push(cell.getComponent());
24822
25281
  }
24823
25282
  });
@@ -24829,9 +25288,11 @@
24829
25288
  }, {
24830
25289
  key: "rowValidate",
24831
25290
  value: function rowValidate(row) {
25291
+ var _this3 = this;
25292
+
24832
25293
  var invalid = [];
24833
25294
  row.cells.forEach(function (cell) {
24834
- if (!this.cellValidate(cell)) {
25295
+ if (!_this3.cellValidate(cell)) {
24835
25296
  invalid.push(cell.getComponent());
24836
25297
  }
24837
25298
  });
@@ -24843,7 +25304,7 @@
24843
25304
  }, {
24844
25305
  key: "userClearCellValidation",
24845
25306
  value: function userClearCellValidation(cells) {
24846
- var _this2 = this;
25307
+ var _this4 = this;
24847
25308
 
24848
25309
  if (!cells) {
24849
25310
  cells = this.getInvalidCells();
@@ -24854,7 +25315,7 @@
24854
25315
  }
24855
25316
 
24856
25317
  cells.forEach(function (cell) {
24857
- _this2.clearValidation(cell._getSelf());
25318
+ _this4.clearValidation(cell._getSelf());
24858
25319
  });
24859
25320
  }
24860
25321
  }, {
@@ -24863,6 +25324,7 @@
24863
25324
  var output = []; //clear row data
24864
25325
 
24865
25326
  this.table.rowManager.rows.forEach(function (row) {
25327
+ row = row.getComponent();
24866
25328
  var valid = row.validate();
24867
25329
 
24868
25330
  if (valid !== true) {
@@ -25045,6 +25507,7 @@
25045
25507
  GroupRowsModule: GroupRows,
25046
25508
  HistoryModule: History,
25047
25509
  HtmlTableImportModule: HtmlTableImport,
25510
+ ImportModule: Import,
25048
25511
  InteractionModule: Interaction,
25049
25512
  KeybindingsModule: Keybindings,
25050
25513
  MenuModule: Menu,