tabulator-rails 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f61db55512668e27d85d3e9471bcfcdd9f703d
4
- data.tar.gz: 1865a238e04136fd8fb435f698ebf1967dfe3578
3
+ metadata.gz: 6cd7dfd28a67c15af8ca59105893bbe550a6026e
4
+ data.tar.gz: fd6d5a86e4a28a5df65740f45fac9aec6d0cec86
5
5
  SHA512:
6
- metadata.gz: 5ec01aa6b62bfb37f28fb3e86bf808a3448de12fe449114d358ec05dbf4c7b6d0b0bef1ce83c28c451c93790af111a091a8c2e38d4a57d5e7b65073f4ac0d966
7
- data.tar.gz: 5a5d91cc037464a7a2410afeb25cc6d6733bd4aec30febbd53ade1584f87b24884a32c07c8ce4d24b31267523840c9e4b72908701b2e76f4fe1281b924ac0848
6
+ metadata.gz: 499b1d4e15b2a5d1f2108b35487a2c86c5cc74af0c30b249a595f05a6a9833b261d4c4ecfb3ab74b70e5d083e58eeaeee7165a3fbe226524c8f35d0d7955ad80
7
+ data.tar.gz: caae8c59ae227138670d63069afeca745681d5a6f1ed7cb942fd9f7c24840c010a54128e24a36addb898732d91293847cc6ef1d6c7dedc9ed35ec3605c7a519b
data/VERSIONS.md CHANGED
@@ -21,3 +21,4 @@
21
21
  | 1.0.3 | 4.0.3
22
22
  | 1.0.4 | 4.0.4
23
23
  | 1.0.5 | 4.0.5
24
+ | 1.1.0 | 4.1.0
@@ -1,5 +1,5 @@
1
1
  module Tabulator
2
2
  module Rails
3
- VERSION = "1.0.5"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2
2
 
3
- /* Tabulator v4.0.5 (c) Oliver Folkerd */
3
+ /* Tabulator v4.1.0 (c) Oliver Folkerd */
4
4
 
5
5
  ;(function (global, factory) {
6
6
  if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined') {
@@ -1177,7 +1177,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1177
1177
 
1178
1178
  this.field = field;
1179
1179
 
1180
- this.fieldStructure = field ? field.split(".") : [];
1180
+ this.fieldStructure = field ? this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field] : [];
1181
1181
 
1182
1182
  this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;
1183
1183
 
@@ -1266,7 +1266,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1266
1266
 
1267
1267
  while (self.element.firstChild) {
1268
1268
  self.element.removeChild(self.element.firstChild);
1269
- }self.contentElement = self._bindEvents();
1269
+ }if (def.headerVertical) {
1270
+
1271
+ self.element.classList.add("tabulator-col-vertical");
1272
+
1273
+ if (def.headerVertical === "flip") {
1274
+
1275
+ self.element.classList.add("tabulator-col-vertical-flip");
1276
+ }
1277
+ }
1278
+
1279
+ self.contentElement = self._bindEvents();
1270
1280
 
1271
1281
  self.contentElement = self._buildColumnHeaderContent();
1272
1282
 
@@ -1691,7 +1701,35 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1691
1701
 
1692
1702
  contents = formatter.call(this.table.modules.format, mockCell, params);
1693
1703
 
1694
- el.appendChild(contents);
1704
+ switch (typeof contents === 'undefined' ? 'undefined' : _typeof(contents)) {
1705
+
1706
+ case "object":
1707
+
1708
+ if (contents instanceof Node) {
1709
+
1710
+ this.element.appendChild(contents);
1711
+ } else {
1712
+
1713
+ this.element.innerHTML = "";
1714
+
1715
+ console.warn("Format Error - Title formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", contents);
1716
+ }
1717
+
1718
+ break;
1719
+
1720
+ case "undefined":
1721
+
1722
+ case "null":
1723
+
1724
+ this.element.innerHTML = "";
1725
+
1726
+ break;
1727
+
1728
+ default:
1729
+
1730
+ this.element.innerHTML = contents;
1731
+
1732
+ }
1695
1733
  } else {
1696
1734
 
1697
1735
  el.innerHTML = title;
@@ -2718,7 +2756,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
2718
2756
  self.rows.push(row);
2719
2757
  } else {
2720
2758
 
2721
- console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but receved:", def);
2759
+ console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);
2722
2760
  }
2723
2761
  });
2724
2762
 
@@ -2867,7 +2905,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
2867
2905
 
2868
2906
  RowManager.prototype.addRowActual = function (data, pos, index, blockRedraw) {
2869
2907
 
2870
- var row = new Row(data || {}, this),
2908
+ var row = data instanceof Row ? data : new Row(data || {}, this),
2871
2909
  top = this.findAddRowPos(pos),
2872
2910
  dispRows;
2873
2911
 
@@ -3487,6 +3525,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
3487
3525
  skipStage = false;
3488
3526
  }
3489
3527
 
3528
+ case "tree":
3529
+
3530
+ if (!skipStage) {
3531
+
3532
+ if (table.options.dataTree && table.modExists("dataTree")) {
3533
+
3534
+ if (!table.modules.dataTree.getDisplayIndex()) {
3535
+
3536
+ table.modules.dataTree.setDisplayIndex(this.getNextDisplayIndex());
3537
+ }
3538
+
3539
+ displayIndex = table.modules.dataTree.getDisplayIndex();
3540
+
3541
+ displayIndex = self.setDisplayRows(table.modules.dataTree.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);
3542
+
3543
+ if (displayIndex !== true) {
3544
+
3545
+ table.modules.dataTree.setDisplayIndex(displayIndex);
3546
+ }
3547
+ }
3548
+ } else {
3549
+
3550
+ skipStage = false;
3551
+ }
3552
+
3490
3553
  if (table.options.pagination && table.modExists("page") && !renderInPosition) {
3491
3554
 
3492
3555
  if (table.modules.page.getMode() == "local") {
@@ -4235,7 +4298,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4235
4298
 
4236
4299
  var rowEl = bottomRow.getElement();
4237
4300
 
4238
- rowEl.parentNode.removeChild(rowEl);
4301
+ if (rowEl.parentNode) {
4302
+
4303
+ rowEl.parentNode.removeChild(rowEl);
4304
+ }
4239
4305
 
4240
4306
  this.vDomBottomPad += bottomRowHeight;
4241
4307
 
@@ -4477,6 +4543,50 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4477
4543
  }
4478
4544
  };
4479
4545
 
4546
+ RowComponent.prototype.treeCollapse = function () {
4547
+
4548
+ if (this._row.table.modExists("dataTree", true)) {
4549
+
4550
+ this._row.table.modules.dataTree.collapseRow(this._row);
4551
+ }
4552
+ };
4553
+
4554
+ RowComponent.prototype.treeExpand = function () {
4555
+
4556
+ if (this._row.table.modExists("dataTree", true)) {
4557
+
4558
+ this._row.table.modules.dataTree.expandRow(this._row);
4559
+ }
4560
+ };
4561
+
4562
+ RowComponent.prototype.treeToggle = function () {
4563
+
4564
+ if (this._row.table.modExists("dataTree", true)) {
4565
+
4566
+ this._row.table.modules.dataTree.toggleRow(this._row);
4567
+ }
4568
+ };
4569
+
4570
+ RowComponent.prototype.getTreeParent = function () {
4571
+
4572
+ if (this._row.table.modExists("dataTree", true)) {
4573
+
4574
+ return this._row.table.modules.dataTree.getTreeParent(this._row);
4575
+ }
4576
+
4577
+ return false;
4578
+ };
4579
+
4580
+ RowComponent.prototype.getTreeChildren = function () {
4581
+
4582
+ if (this._row.table.modExists("dataTree", true)) {
4583
+
4584
+ return this._row.table.modules.dataTree.getTreeChildren(this._row);
4585
+ }
4586
+
4587
+ return false;
4588
+ };
4589
+
4480
4590
  RowComponent.prototype.reformat = function () {
4481
4591
 
4482
4592
  return this._row.reinitialize();
@@ -4492,6 +4602,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4492
4602
  return this._row.table;
4493
4603
  };
4494
4604
 
4605
+ RowComponent.prototype.getNextRow = function () {
4606
+
4607
+ return this._row.nextRow();
4608
+ };
4609
+
4610
+ RowComponent.prototype.getPrevRow = function () {
4611
+
4612
+ return this._row.prevRow();
4613
+ };
4614
+
4495
4615
  var Row = function Row(data, parent) {
4496
4616
 
4497
4617
  this.table = parent.table;
@@ -4559,6 +4679,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4559
4679
  self.table.modules.moveRow.initializeRow(this);
4560
4680
  }
4561
4681
 
4682
+ //setup data tree
4683
+
4684
+ if (self.table.options.dataTree !== false && self.table.modExists("dataTree")) {
4685
+
4686
+ self.table.modules.dataTree.initializeRow(this);
4687
+ }
4688
+
4562
4689
  //handle row click events
4563
4690
 
4564
4691
  if (self.table.options.rowClick) {
@@ -4699,6 +4826,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
4699
4826
 
4700
4827
  //setup movable rows
4701
4828
 
4829
+ if (self.table.options.dataTree && self.table.modExists("dataTree")) {
4830
+
4831
+ self.table.modules.dataTree.layoutRow(this);
4832
+ }
4833
+
4834
+ //setup movable rows
4835
+
4702
4836
  if (self.table.options.responsiveLayout === "collapse" && self.table.modExists("responsiveLayout")) {
4703
4837
 
4704
4838
  self.table.modules.responsiveLayout.layoutRow(this);
@@ -5043,6 +5177,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
5043
5177
  return this.cells;
5044
5178
  };
5045
5179
 
5180
+ Row.prototype.nextRow = function () {
5181
+
5182
+ var row = this.table.rowManager.nextDisplayRow(this, true);
5183
+
5184
+ return row ? row.getComponent() : false;
5185
+ };
5186
+
5187
+ Row.prototype.prevRow = function () {
5188
+
5189
+ var row = this.table.rowManager.prevDisplayRow(this, true);
5190
+
5191
+ return row ? row.getComponent() : false;
5192
+ };
5193
+
5046
5194
  ///////////////////// Actions /////////////////////
5047
5195
 
5048
5196
 
@@ -5077,13 +5225,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
5077
5225
 
5078
5226
  if (this.table.modExists("selectRow")) {
5079
5227
 
5080
- this.table.modules.selectRow._deselectRow(this.row, true);
5228
+ this.table.modules.selectRow._deselectRow(this, true);
5081
5229
  }
5082
5230
 
5231
+ // if(this.table.options.dataTree && this.table.modExists("dataTree")){
5232
+
5233
+ // this.table.modules.dataTree.collapseRow(this, true);
5234
+
5235
+ // }
5236
+
5237
+
5083
5238
  this.table.rowManager.deleteRow(this);
5084
5239
 
5085
5240
  this.deleteCells();
5086
5241
 
5242
+ this.initialized = false;
5243
+
5244
+ this.heightInitialized = false;
5245
+
5087
5246
  //remove from group
5088
5247
 
5089
5248
  if (this.modules.group) {
@@ -5516,7 +5675,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
5516
5675
 
5517
5676
  case "object":
5518
5677
 
5519
- this.element.appendChild(val);
5678
+ if (val instanceof Node) {
5679
+
5680
+ this.element.appendChild(val);
5681
+ } else {
5682
+
5683
+ this.element.innerHTML = "";
5684
+
5685
+ console.warn("Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", val);
5686
+ }
5520
5687
 
5521
5688
  break;
5522
5689
 
@@ -6091,6 +6258,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6091
6258
  data: [], //default starting data
6092
6259
 
6093
6260
 
6261
+ nestedFieldSeparator: ".", //seperatpr for nested data
6262
+
6263
+
6094
6264
  tooltips: false, //Tool tip value
6095
6265
 
6096
6266
  tooltipsHeader: false, //Tool tip for headers
@@ -6103,6 +6273,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6103
6273
  initialFilter: false, //initial filtering criteria
6104
6274
 
6105
6275
 
6276
+ columnHeaderSortMulti: true, //multiple or single column sorting
6277
+
6278
+
6279
+ sortOrderReverse: false, //reverse internal sort ordering
6280
+
6281
+
6106
6282
  footerElement: false, //hold footer element
6107
6283
 
6108
6284
 
@@ -6120,12 +6296,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6120
6296
 
6121
6297
  clipboardCopyFormatter: "table", //convert data to a clipboard string
6122
6298
 
6123
- clipboardCopyHeader: true, //include table headers in copt
6124
-
6125
6299
  clipboardPasteParser: "table", //convert pasted clipboard data to rows
6126
6300
 
6127
6301
  clipboardPasteAction: "insert", //how to insert pasted data into the table
6128
6302
 
6303
+ clipboardCopyConfig: false, //clipboard config
6304
+
6129
6305
 
6130
6306
  clipboardCopied: function clipboardCopied() {}, //data has been copied to the clipboard
6131
6307
 
@@ -6142,12 +6318,35 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6142
6318
 
6143
6319
  downloadComplete: false, //function to manipulate download data
6144
6320
 
6321
+ downloadConfig: false, //download config
6322
+
6323
+
6324
+ dataTree: false, //enable data tree
6325
+
6326
+ dataTreeBranchElement: true, //show data tree branch element
6327
+
6328
+ dataTreeChildIndent: 9, //data tree child indent in px
6329
+
6330
+ dataTreeChildField: "_children", //data tre column field to look for child rows
6331
+
6332
+ dataTreeCollapseElement: false, //data tree row collapse element
6333
+
6334
+ dataTreeExpandElement: false, //data tree row expand element
6335
+
6336
+ dataTreeStartExpanded: false,
6337
+
6338
+ dataTreeRowExpanded: function dataTreeRowExpanded() {}, //row has been expanded
6339
+
6340
+ dataTreeRowCollapsed: function dataTreeRowCollapsed() {}, //row has been collapsed
6341
+
6145
6342
 
6146
6343
  addRowPos: "bottom", //position to insert blank rows, top|bottom
6147
6344
 
6148
6345
 
6149
6346
  selectable: "highlight", //highlight rows on hover
6150
6347
 
6348
+ selectableRangeType: "drag", //highlight rows on hover
6349
+
6151
6350
  selectableRollingSelection: true, //roll selection once maximum number of selectable rows is reached
6152
6351
 
6153
6352
  selectablePersistence: true, // maintain selection when table view is updated
@@ -6213,6 +6412,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6213
6412
 
6214
6413
  ajaxConfig: "get", //ajax request type
6215
6414
 
6415
+ ajaxContentType: "form", //ajax request type
6416
+
6216
6417
  ajaxRequestFunc: false, //promise function
6217
6418
 
6218
6419
  ajaxLoader: true, //show loader
@@ -6236,6 +6437,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6236
6437
 
6237
6438
  groupStartOpen: true, //starting state of group
6238
6439
 
6440
+ groupValues: false,
6239
6441
 
6240
6442
  groupHeader: false, //header generation function
6241
6443
 
@@ -6608,6 +6810,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6608
6810
  this.footerManager.activate();
6609
6811
  }
6610
6812
 
6813
+ if (options.dataTree && this.modExists("dataTree", true)) {
6814
+
6815
+ mod.dataTree.initialize();
6816
+ }
6817
+
6611
6818
  if ((options.persistentLayout || options.persistentSort || options.persistentFilter) && this.modExists("persistence", true)) {
6612
6819
 
6613
6820
  mod.persistence.initialize(options.persistenceMode, options.persistenceID);
@@ -6941,6 +7148,26 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6941
7148
  return this.rowManager.getDataCount(active);
6942
7149
  };
6943
7150
 
7151
+ //search for specific row components
7152
+
7153
+ Tabulator.prototype.searchRows = function (field, type, value) {
7154
+
7155
+ if (this.modExists("filter", true)) {
7156
+
7157
+ return this.modules.filter.search("rows", field, type, value);
7158
+ }
7159
+ };
7160
+
7161
+ //search for specific data
7162
+
7163
+ Tabulator.prototype.searchData = function (field, type, value) {
7164
+
7165
+ if (this.modExists("filter", true)) {
7166
+
7167
+ return this.modules.filter.search("data", field, type, value);
7168
+ }
7169
+ };
7170
+
6944
7171
  //get table html
6945
7172
 
6946
7173
  Tabulator.prototype.getHtml = function (active) {
@@ -7899,13 +8126,23 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
7899
8126
 
7900
8127
  if (this.modExists("groupRows", true)) {
7901
8128
 
7902
- return this.modules.groupRows.getGroups();
8129
+ return this.modules.groupRows.getGroups(true);
7903
8130
  } else {
7904
8131
 
7905
8132
  return false;
7906
8133
  }
7907
8134
  };
7908
8135
 
8136
+ // get grouped table data in the same format as getData()
8137
+
8138
+ Tabulator.prototype.getGroupedData = function () {
8139
+
8140
+ if (this.modExists("groupRows", true)) {
8141
+
8142
+ return this.options.groupBy ? this.modules.groupRows.getGroupedData() : this.getData();
8143
+ }
8144
+ };
8145
+
7909
8146
  ///////////////// Column Calculation Functions ///////////////
7910
8147
 
7911
8148
  Tabulator.prototype.getCalcResults = function () {
@@ -8199,13 +8436,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
8199
8436
 
8200
8437
  deepClone: function deepClone(obj) {
8201
8438
 
8202
- var clone = {};
8439
+ var clone = Array.isArray(obj) ? [] : {};
8203
8440
 
8204
8441
  for (var i in obj) {
8205
8442
 
8206
8443
  if (obj[i] != null && _typeof(obj[i]) === "object") {
8207
8444
 
8208
- clone[i] = this.deepClone(obj[i]);
8445
+ if (obj[i] instanceof Date) {
8446
+
8447
+ clone[i] = new Date(obj[i]);
8448
+ } else {
8449
+
8450
+ clone[i] = this.deepClone(obj[i]);
8451
+ }
8209
8452
  } else {
8210
8453
 
8211
8454
  clone[i] = obj[i];
@@ -9245,17 +9488,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9245
9488
  return encoded.join("&");
9246
9489
  };
9247
9490
 
9248
- Ajax.prototype.formDataParams = function (params) {
9249
- var output = this.generateParamsList(params),
9250
- form = new FormData();
9251
-
9252
- output.forEach(function (item) {
9253
- form.append(item.key, item.value);
9254
- });
9255
-
9256
- return form;
9257
- };
9258
-
9259
9491
  //send ajax request
9260
9492
  Ajax.prototype.sendRequest = function (silent) {
9261
9493
  var _this17 = this;
@@ -9364,11 +9596,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9364
9596
  };
9365
9597
 
9366
9598
  Ajax.prototype.defaultURLGenerator = function (url, config, params) {
9367
- if (params) {
9599
+ if (params && Object.keys(params).length) {
9368
9600
  if (!config.method || config.method.toLowerCase() == "get") {
9601
+ config.method = "get";
9369
9602
  url += "?" + this.serializeParams(params);
9370
- } else {
9371
- config.body = this.formDataParams(params);
9372
9603
  }
9373
9604
  }
9374
9605
 
@@ -9376,14 +9607,55 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9376
9607
  };
9377
9608
 
9378
9609
  Ajax.prototype.defaultLoaderPromise = function (url, config, params) {
9379
- var self = this;
9610
+ var self = this,
9611
+ contentType;
9380
9612
 
9381
9613
  return new Promise(function (resolve, reject) {
9382
9614
 
9615
+ //set url
9383
9616
  url = self.urlGenerator(url, config, params);
9384
9617
 
9618
+ //set body content if not GET request
9619
+ if (config.method != "get") {
9620
+ contentType = _typeof(self.table.options.ajaxContentType) === "object" ? self.table.options.ajaxContentType : self.contentTypeFormatters[self.table.options.ajaxContentType];
9621
+ if (contentType) {
9622
+
9623
+ for (var key in contentType.headers) {
9624
+ if (!config.headers) {
9625
+ config.headers = {};
9626
+ }
9627
+
9628
+ if (typeof config.headers[key] === "undefined") {
9629
+ config.headers[key] = contentType.headers[key];
9630
+ }
9631
+ }
9632
+
9633
+ config.body = contentType.body.call(self, url, config, params);
9634
+ } else {
9635
+ console.warn("Ajax Error - Invalid ajaxContentType value:", self.table.options.ajaxContentType);
9636
+ }
9637
+ }
9638
+
9385
9639
  if (url) {
9386
9640
 
9641
+ //configure headers
9642
+ if (typeof config.credentials === "undefined") {
9643
+ config.credentials = 'include';
9644
+ }
9645
+
9646
+ if (typeof config.headers === "undefined") {
9647
+ config.headers = {};
9648
+ }
9649
+
9650
+ if (typeof config.headers.Accept === "undefined") {
9651
+ config.headers.Accept = "application/json";
9652
+ }
9653
+
9654
+ if (typeof config.headers["X-Requested-With"] === "undefined") {
9655
+ config.headers["X-Requested-With"] = "XMLHttpRequest";
9656
+ }
9657
+
9658
+ //send request
9387
9659
  fetch(url, config).then(function (response) {
9388
9660
  if (response.ok) {
9389
9661
  response.json().then(function (data) {
@@ -9406,6 +9678,30 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9406
9678
  });
9407
9679
  };
9408
9680
 
9681
+ Ajax.prototype.contentTypeFormatters = {
9682
+ "json": {
9683
+ headers: {
9684
+ 'Content-Type': 'application/json'
9685
+ },
9686
+ body: function body(url, config, params) {
9687
+ return JSON.stringify(params);
9688
+ }
9689
+ },
9690
+ "form": {
9691
+ headers: {},
9692
+ body: function body(url, config, params) {
9693
+ var output = this.generateParamsList(params),
9694
+ form = new FormData();
9695
+
9696
+ output.forEach(function (item) {
9697
+ form.append(item.key, item.value);
9698
+ });
9699
+
9700
+ return form;
9701
+ }
9702
+ }
9703
+ };
9704
+
9409
9705
  Tabulator.prototype.registerModule("ajax", Ajax);
9410
9706
  var ColumnCalcs = function ColumnCalcs(table) {
9411
9707
  this.table = table; //hold Tabulator object
@@ -9720,7 +10016,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9720
10016
  groups;
9721
10017
 
9722
10018
  if (this.table.options.groupBy && this.table.modExists("groupRows")) {
9723
- groups = this.table.modules.groupRows.getGroups();
10019
+ groups = this.table.modules.groupRows.getGroups(true);
9724
10020
 
9725
10021
  groups.forEach(function (group) {
9726
10022
  results[group.getKey()] = self.getGroupResults(group);
@@ -9856,6 +10152,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9856
10152
  this.pasteParser = function () {};
9857
10153
  this.pasteAction = function () {};
9858
10154
  this.htmlElement = false;
10155
+ this.config = {};
9859
10156
 
9860
10157
  this.blocked = true; //block copy actions not originating from this command
9861
10158
  };
@@ -9869,6 +10166,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9869
10166
  this.table.element.addEventListener("copy", function (e) {
9870
10167
  var data;
9871
10168
 
10169
+ self.processConfig();
10170
+
9872
10171
  if (!self.blocked) {
9873
10172
  e.preventDefault();
9874
10173
 
@@ -9905,6 +10204,38 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
9905
10204
  this.setPasteAction(this.table.options.clipboardPasteAction);
9906
10205
  };
9907
10206
 
10207
+ Clipboard.prototype.processConfig = function () {
10208
+ var config = {
10209
+ columnHeaders: "groups",
10210
+ rowGroups: true
10211
+ };
10212
+
10213
+ if (typeof this.table.options.clipboardCopyHeader !== "undefined") {
10214
+ config.columnHeaders = this.table.options.clipboardCopyHeader;
10215
+ console.warn("DEPRICATION WANRING - clipboardCopyHeader option has been depricated, please use the columnHeaders property on the clipboardCopyConfig option");
10216
+ }
10217
+
10218
+ if (this.table.options.clipboardCopyConfig) {
10219
+ for (var key in this.table.options.clipboardCopyConfig) {
10220
+ config[key] = this.table.options.clipboardCopyConfig[key];
10221
+ }
10222
+ }
10223
+
10224
+ if (config.rowGroups && this.table.options.groupBy && this.table.modExists("groupRows")) {
10225
+ this.config.rowGroups = true;
10226
+ }
10227
+
10228
+ if (config.columnHeaders) {
10229
+ if ((config.columnHeaders === "groups" || config === true) && this.table.columnManager.columns.length != this.table.columnManager.columnsByIndex.length) {
10230
+ this.config.columnHeaders = "groups";
10231
+ } else {
10232
+ this.config.columnHeaders = "columns";
10233
+ }
10234
+ } else {
10235
+ this.config.columnHeaders = false;
10236
+ }
10237
+ };
10238
+
9908
10239
  Clipboard.prototype.reset = function () {
9909
10240
  this.blocked = false;
9910
10241
  this.originalSelectionText = "";
@@ -10032,7 +10363,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10032
10363
  }
10033
10364
 
10034
10365
  this.setSelector(selector);
10035
- this.copySelectorParams = typeof selectorParams != "undefined" && selectorParams != null ? selectorParams : this.table.options.clipboardCopyHeader;
10366
+ this.copySelectorParams = typeof selectorParams != "undefined" && selectorParams != null ? selectorParams : this.config.columnHeaders;
10036
10367
  this.setFormatter(formatter);
10037
10368
  this.copyFormatterParams = typeof formatterParams != "undefined" && formatterParams != null ? formatterParams : {};
10038
10369
 
@@ -10085,86 +10416,369 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10085
10416
  var data;
10086
10417
 
10087
10418
  this.htmlElement = false;
10088
- data = this.copySelector.call(this, this.copySelectorParams);
10419
+ data = this.copySelector.call(this, this.config, this.copySelectorParams);
10089
10420
 
10090
- return this.copyFormatter.call(this, data, this.copyFormatterParams);
10421
+ return this.copyFormatter.call(this, data, this.config, this.copyFormatterParams);
10091
10422
  };
10092
10423
 
10093
- Clipboard.prototype.rowsToData = function (rows, params) {
10094
- var columns = this.table.columnManager.columnsByIndex,
10095
- headers = [],
10096
- data = [];
10424
+ Clipboard.prototype.generateSimpleHeaders = function (columns) {
10425
+ var headers = [];
10097
10426
 
10098
- if (this.table.options.clipboardCopyStyled) {
10099
- this.generateHTML(rows, params);
10100
- }
10427
+ columns.forEach(function (column) {
10428
+ headers.push(column.definition.title);
10429
+ });
10101
10430
 
10102
- if (params) {
10103
- columns.forEach(function (column) {
10104
- headers.push(column.definition.title);
10105
- });
10431
+ return headers;
10432
+ };
10106
10433
 
10107
- data.push(headers);
10108
- }
10434
+ Clipboard.prototype.generateColumnGroupHeaders = function (columns) {
10435
+ var _this18 = this;
10109
10436
 
10110
- rows.forEach(function (row) {
10111
- var rowArray = [],
10112
- rowData = row.getData("clipboard");
10437
+ var output = [];
10113
10438
 
10114
- columns.forEach(function (column) {
10115
- var value = column.getFieldValue(rowData);
10116
- rowArray.push(value);
10117
- });
10439
+ this.table.columnManager.columns.forEach(function (column) {
10440
+ var colData = _this18.processColumnGroup(column);
10118
10441
 
10119
- data.push(rowArray);
10442
+ if (colData) {
10443
+ output.push(colData);
10444
+ }
10120
10445
  });
10121
10446
 
10122
- return data;
10447
+ return output;
10123
10448
  };
10124
10449
 
10125
- Clipboard.prototype.generateHTML = function (rows, showHeaders) {
10126
- var self = this,
10127
- columns = this.table.columnManager.columnsByIndex,
10128
- data = [],
10129
- headers,
10130
- body,
10131
- oddRow,
10132
- evenRow,
10133
- firstRow,
10134
- firstCell,
10135
- lastCell,
10136
- styleCells;
10450
+ Clipboard.prototype.processColumnGroup = function (column) {
10451
+ var _this19 = this;
10137
10452
 
10138
- //create table element
10139
- this.htmlElement = document.createElement("table");
10140
- self.mapElementStyles(this.table.element, this.htmlElement, ["border-top", "border-left", "border-right", "border-bottom"]);
10453
+ var subGroups = column.columns;
10141
10454
 
10142
- //create headers if needed
10143
- if (showHeaders) {
10144
- headers = document.createElement("tr");
10455
+ var groupData = {
10456
+ type: "group",
10457
+ title: column.definition.title,
10458
+ column: column
10459
+ };
10460
+
10461
+ if (subGroups.length) {
10462
+ groupData.subGroups = [];
10463
+ groupData.width = 0;
10464
+
10465
+ subGroups.forEach(function (subGroup) {
10466
+ var subGroupData = _this19.processColumnGroup(subGroup);
10467
+
10468
+ if (subGroupData) {
10469
+ groupData.width += subGroupData.width;
10470
+ groupData.subGroups.push(subGroupData);
10471
+ }
10472
+ });
10473
+
10474
+ if (!groupData.width) {
10475
+ return false;
10476
+ }
10477
+ } else {
10478
+ if (column.field && column.visible) {
10479
+ groupData.width = 1;
10480
+ } else {
10481
+ return false;
10482
+ }
10483
+ }
10484
+
10485
+ return groupData;
10486
+ };
10487
+
10488
+ Clipboard.prototype.groupHeadersToRows = function (columns) {
10489
+
10490
+ var headers = [];
10491
+
10492
+ function parseColumnGroup(column, level) {
10493
+
10494
+ if (typeof headers[level] === "undefined") {
10495
+ headers[level] = [];
10496
+ }
10497
+
10498
+ headers[level].push(column.title);
10499
+
10500
+ if (column.subGroups) {
10501
+ column.subGroups.forEach(function (subGroup) {
10502
+ parseColumnGroup(subGroup, level + 1);
10503
+ });
10504
+ } else {
10505
+ padColumnheaders();
10506
+ }
10507
+ }
10508
+
10509
+ function padColumnheaders() {
10510
+ var max = 0;
10511
+
10512
+ headers.forEach(function (title) {
10513
+ var len = title.length;
10514
+ if (len > max) {
10515
+ max = len;
10516
+ }
10517
+ });
10518
+
10519
+ headers.forEach(function (title) {
10520
+ var len = title.length;
10521
+ if (len < max) {
10522
+ for (var i = len; i < max; i++) {
10523
+ title.push("");
10524
+ }
10525
+ }
10526
+ });
10527
+ }
10528
+
10529
+ columns.forEach(function (column) {
10530
+ parseColumnGroup(column, 0);
10531
+ });
10532
+
10533
+ return headers;
10534
+ };
10535
+
10536
+ Clipboard.prototype.rowsToData = function (rows, config, params) {
10537
+ var columns = this.table.columnManager.columnsByIndex,
10538
+ data = [];
10539
+
10540
+ rows.forEach(function (row) {
10541
+ var rowArray = [],
10542
+ rowData = row.getData("clipboard");
10543
+
10544
+ columns.forEach(function (column) {
10545
+ var value = column.getFieldValue(rowData);
10546
+
10547
+ switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
10548
+ case "object":
10549
+ value = JSON.stringify(value);
10550
+ break;
10551
+
10552
+ case "undefined":
10553
+ case "null":
10554
+ value = "";
10555
+ break;
10556
+
10557
+ default:
10558
+ value = value;
10559
+ }
10560
+
10561
+ rowArray.push(value);
10562
+ });
10563
+
10564
+ data.push(rowArray);
10565
+ });
10566
+
10567
+ return data;
10568
+ };
10569
+
10570
+ Clipboard.prototype.buildComplexRows = function (config) {
10571
+ var _this20 = this;
10572
+
10573
+ var output = [],
10574
+ groups = this.table.modules.groupRows.getGroups();
10575
+
10576
+ groups.forEach(function (group) {
10577
+ output.push(_this20.processGroupData(group));
10578
+ });
10579
+
10580
+ return output;
10581
+ };
10582
+
10583
+ Clipboard.prototype.processGroupData = function (group) {
10584
+ var _this21 = this;
10585
+
10586
+ var subGroups = group.getSubGroups();
10587
+
10588
+ var groupData = {
10589
+ type: "group",
10590
+ key: group.key
10591
+ };
10592
+
10593
+ if (subGroups.length) {
10594
+ groupData.subGroups = [];
10595
+
10596
+ subGroups.forEach(function (subGroup) {
10597
+ groupData.subGroups.push(_this21.processGroupData(subGroup));
10598
+ });
10599
+ } else {
10600
+ groupData.rows = group.getRows(true);
10601
+ }
10602
+
10603
+ return groupData;
10604
+ };
10605
+
10606
+ Clipboard.prototype.buildOutput = function (rows, config, params) {
10607
+ var _this22 = this;
10608
+
10609
+ var output = [],
10610
+ columns = this.table.columnManager.columnsByIndex;
10611
+
10612
+ if (config.columnHeaders) {
10613
+
10614
+ if (config.columnHeaders == "groups") {
10615
+ columns = this.generateColumnGroupHeaders(this.table.columnManager.columns);
10616
+
10617
+ output = output.concat(this.groupHeadersToRows(columns));
10618
+ } else {
10619
+ output.push(this.generateSimpleHeaders(columns));
10620
+ }
10621
+ }
10622
+
10623
+ //generate styled content
10624
+ if (this.table.options.clipboardCopyStyled) {
10625
+ this.generateHTML(rows, columns, config, params);
10626
+ }
10627
+
10628
+ //generate unstyled content
10629
+ if (config.rowGroups) {
10630
+ rows.forEach(function (row) {
10631
+ output = output.concat(_this22.parseRowGroupData(row, config, params));
10632
+ });
10633
+ } else {
10634
+ output = output.concat(this.rowsToData(rows, config, params));
10635
+ }
10636
+
10637
+ return output;
10638
+ };
10639
+
10640
+ Clipboard.prototype.parseRowGroupData = function (group, config, params) {
10641
+ var _this23 = this;
10642
+
10643
+ var groupData = [];
10644
+
10645
+ groupData.push([group.key]);
10646
+
10647
+ if (group.subGroups) {
10648
+ group.subGroups.forEach(function (subGroup) {
10649
+ groupData = groupData.concat(_this23.parseRowGroupData(subGroup, config, params));
10650
+ });
10651
+ } else {
10652
+
10653
+ groupData = groupData.concat(this.rowsToData(group.rows, config, params));
10654
+ }
10655
+
10656
+ return groupData;
10657
+ };
10658
+
10659
+ Clipboard.prototype.generateHTML = function (rows, columns, config, params) {
10660
+ var self = this,
10661
+ data = [],
10662
+ headers = [],
10663
+ body,
10664
+ oddRow,
10665
+ evenRow,
10666
+ firstRow,
10667
+ firstCell,
10668
+ firstGroup,
10669
+ lastCell,
10670
+ styleCells;
10671
+
10672
+ //create table element
10673
+ this.htmlElement = document.createElement("table");
10674
+ self.mapElementStyles(this.table.element, this.htmlElement, ["border-top", "border-left", "border-right", "border-bottom"]);
10675
+
10676
+ function generateSimpleHeaders() {
10677
+ var headerEl = document.createElement("tr");
10145
10678
 
10146
10679
  columns.forEach(function (column) {
10147
- var col = document.createElement("th");
10148
- col.innerHTML = column.definition.title;
10680
+ var columnEl = document.createElement("th");
10681
+ columnEl.innerHTML = column.definition.title;
10682
+
10683
+ self.mapElementStyles(column.getElement(), columnEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10684
+
10685
+ headerEl.appendChild(columnEl);
10686
+ });
10687
+
10688
+ self.mapElementStyles(self.table.columnManager.getHeadersElement(), headerEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10689
+
10690
+ self.htmlElement.appendChild(document.createElement("thead").appendChild(headerEl));
10691
+ }
10692
+
10693
+ function generateHeaders(headers) {
10694
+
10695
+ var headerHolderEl = document.createElement("thead");
10696
+
10697
+ headers.forEach(function (columns) {
10698
+ var headerEl = document.createElement("tr");
10699
+
10700
+ columns.forEach(function (column) {
10701
+ var columnEl = document.createElement("th");
10702
+
10703
+ if (column.width > 1) {
10704
+ columnEl.colSpan = column.width;
10705
+ }
10706
+
10707
+ if (column.height > 1) {
10708
+ columnEl.rowSpan = column.height;
10709
+ }
10710
+
10711
+ columnEl.innerHTML = column.title;
10712
+
10713
+ self.mapElementStyles(column.element, columnEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10714
+
10715
+ headerEl.appendChild(columnEl);
10716
+ });
10717
+
10718
+ self.mapElementStyles(self.table.columnManager.getHeadersElement(), headerEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10719
+
10720
+ headerHolderEl.appendChild(headerEl);
10721
+ });
10722
+
10723
+ self.htmlElement.appendChild(headerHolderEl);
10724
+ }
10725
+
10726
+ function parseColumnGroup(column, level) {
10149
10727
 
10150
- self.mapElementStyles(column.getElement(), col, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10728
+ if (typeof headers[level] === "undefined") {
10729
+ headers[level] = [];
10730
+ }
10731
+
10732
+ headers[level].push({
10733
+ title: column.title,
10734
+ width: column.width,
10735
+ height: 1,
10736
+ children: !!column.subGroups,
10737
+ element: column.column.getElement()
10738
+ });
10739
+
10740
+ if (column.subGroups) {
10741
+ column.subGroups.forEach(function (subGroup) {
10742
+ parseColumnGroup(subGroup, level + 1);
10743
+ });
10744
+ }
10745
+ }
10151
10746
 
10152
- headers.appendChild(col);
10747
+ function padVerticalColumnheaders() {
10748
+ headers.forEach(function (row, index) {
10749
+ row.forEach(function (header) {
10750
+ if (!header.children) {
10751
+ header.height = headers.length - index;
10752
+ }
10753
+ });
10153
10754
  });
10755
+ }
10154
10756
 
10155
- self.mapElementStyles(this.table.columnManager.getHeadersElement(), headers, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);
10757
+ //create headers if needed
10758
+ if (config.columnHeaders) {
10759
+ if (config.columnHeaders == "groups") {
10760
+ columns.forEach(function (column) {
10761
+ parseColumnGroup(column, 0);
10762
+ });
10156
10763
 
10157
- this.htmlElement.appendChild(document.createElement("thead").appendChild(headers));
10764
+ padVerticalColumnheaders();
10765
+ generateHeaders(headers);
10766
+ } else {
10767
+ generateSimpleHeaders();
10768
+ }
10158
10769
  }
10159
10770
 
10771
+ columns = this.table.columnManager.columnsByIndex;
10772
+
10160
10773
  //create table body
10161
10774
  body = document.createElement("tbody");
10162
10775
 
10163
10776
  //lookup row styles
10164
10777
  if (window.getComputedStyle) {
10165
- oddRow = this.table.element.getElementsByClassName("tabulator-row-odd")[0];
10166
- evenRow = this.table.element.getElementsByClassName("tabulator-row-even")[0];
10167
- firstRow = this.table.element.getElementsByClassName("tabulator-row")[0];
10778
+ oddRow = this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)");
10779
+ evenRow = this.table.element.querySelector(".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)");
10780
+ firstRow = this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)");
10781
+ firstGroup = this.table.element.getElementsByClassName("tabulator-group")[0];
10168
10782
 
10169
10783
  if (firstRow) {
10170
10784
  styleCells = firstRow.getElementsByClassName("tabulator-cell");
@@ -10173,47 +10787,95 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10173
10787
  }
10174
10788
  }
10175
10789
 
10176
- //add rows to table
10177
- rows.forEach(function (row, i) {
10178
- var rowEl = document.createElement("tr"),
10179
- rowData = row.getData("clipboard"),
10180
- styleRow = firstRow;
10790
+ function processRows(rowArray) {
10791
+ //add rows to table
10792
+ rowArray.forEach(function (row, i) {
10793
+ var rowEl = document.createElement("tr"),
10794
+ rowData = row.getData("clipboard"),
10795
+ styleRow = firstRow;
10181
10796
 
10182
- columns.forEach(function (column, j) {
10183
- var cellEl = document.createElement("td");
10184
- cellEl.innerHTML = column.getFieldValue(rowData);
10797
+ columns.forEach(function (column, j) {
10798
+ var cellEl = document.createElement("td"),
10799
+ value = column.getFieldValue(rowData);
10185
10800
 
10186
- if (column.definition.align) {
10187
- cellEl.style.textAlign = column.definition.align;
10188
- }
10801
+ switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
10802
+ case "object":
10803
+ value = JSON.stringify(value);
10804
+ break;
10805
+
10806
+ case "undefined":
10807
+ case "null":
10808
+ value = "";
10809
+ break;
10189
10810
 
10190
- if (j < columns.length - 1) {
10191
- if (firstCell) {
10192
- self.mapElementStyles(firstCell, cellEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size"]);
10811
+ default:
10812
+ value = value;
10193
10813
  }
10194
- } else {
10195
- if (firstCell) {
10196
- self.mapElementStyles(firstCell, cellEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size"]);
10814
+
10815
+ cellEl.innerHTML = value;
10816
+
10817
+ if (column.definition.align) {
10818
+ cellEl.style.textAlign = column.definition.align;
10197
10819
  }
10820
+
10821
+ if (j < columns.length - 1) {
10822
+ if (firstCell) {
10823
+ self.mapElementStyles(firstCell, cellEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size"]);
10824
+ }
10825
+ } else {
10826
+ if (firstCell) {
10827
+ self.mapElementStyles(firstCell, cellEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size"]);
10828
+ }
10829
+ }
10830
+
10831
+ rowEl.appendChild(cellEl);
10832
+ });
10833
+
10834
+ if (!(i % 2) && oddRow) {
10835
+ styleRow = oddRow;
10198
10836
  }
10199
10837
 
10200
- rowEl.appendChild(cellEl);
10838
+ if (i % 2 && evenRow) {
10839
+ styleRow = evenRow;
10840
+ }
10841
+
10842
+ if (styleRow) {
10843
+ self.mapElementStyles(styleRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
10844
+ }
10845
+
10846
+ body.appendChild(rowEl);
10201
10847
  });
10848
+ }
10202
10849
 
10203
- if (!(i % 2) && oddRow) {
10204
- styleRow = oddRow;
10205
- }
10850
+ function processGroup(group) {
10851
+ var groupEl = document.createElement("tr"),
10852
+ groupCellEl = document.createElement("td");
10206
10853
 
10207
- if (i % 2 && evenRow) {
10208
- styleRow = evenRow;
10209
- }
10854
+ groupCellEl.colSpan = columns.length;
10855
+
10856
+ groupCellEl.innerHTML = group.key;
10210
10857
 
10211
- if (styleRow) {
10212
- self.mapElementStyles(styleRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
10858
+ groupEl.appendChild(groupCellEl);
10859
+ body.appendChild(groupEl);
10860
+
10861
+ self.mapElementStyles(firstGroup, groupEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);
10862
+
10863
+ if (group.subGroups) {
10864
+ group.subGroups.forEach(function (subGroup) {
10865
+ processGroup(subGroup);
10866
+ });
10867
+ } else {
10868
+ processRows(group.rows);
10213
10869
  }
10870
+ }
10214
10871
 
10215
- body.appendChild(rowEl);
10216
- });
10872
+ if (config.rowGroups) {
10873
+ rows.forEach(function (group) {
10874
+ processGroup(group);
10875
+ });
10876
+ } else {
10877
+ processRows(rows);
10878
+ }
10217
10879
 
10218
10880
  this.htmlElement.appendChild(body);
10219
10881
  };
@@ -10244,23 +10906,39 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10244
10906
  };
10245
10907
 
10246
10908
  Clipboard.prototype.copySelectors = {
10247
- userSelection: function userSelection(params) {
10909
+ userSelection: function userSelection(config, params) {
10248
10910
  return params;
10249
10911
  },
10250
- selected: function selected(params) {
10912
+ selected: function selected(config, params) {
10251
10913
  var rows = [];
10252
10914
 
10253
10915
  if (this.table.modExists("selectRow", true)) {
10254
10916
  rows = this.table.modules.selectRow.getSelectedRows();
10255
10917
  }
10256
10918
 
10257
- return this.rowsToData(rows, params);
10919
+ if (config.rowGroups) {
10920
+ console.warn("Clipboard Warning - select coptSelector does not support row groups");
10921
+ }
10922
+
10923
+ return this.buildOutput(rows, config, params);
10258
10924
  },
10259
- table: function table(params) {
10260
- return this.rowsToData(this.table.rowManager.getComponents(), params);
10925
+ table: function table(config, params) {
10926
+ if (config.rowGroups) {
10927
+ console.warn("Clipboard Warning - table coptSelector does not support row groups");
10928
+ }
10929
+
10930
+ return this.buildOutput(this.table.rowManager.getComponents(), config, params);
10261
10931
  },
10262
- active: function active(params) {
10263
- return this.rowsToData(this.table.rowManager.getComponents(true), params);
10932
+ active: function active(config, params) {
10933
+ var rows;
10934
+
10935
+ if (config.rowGroups) {
10936
+ rows = this.buildComplexRows(config);
10937
+ } else {
10938
+ rows = this.table.rowManager.getComponents(true);
10939
+ }
10940
+
10941
+ return this.buildOutput(rows, config, params);
10264
10942
  }
10265
10943
  };
10266
10944
 
@@ -10384,40 +11062,360 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10384
11062
 
10385
11063
  Tabulator.prototype.registerModule("clipboard", Clipboard);
10386
11064
 
10387
- var Download = function Download(table) {
10388
- this.table = table; //hold Tabulator object
10389
- this.fields = {}; //hold filed multi dimension arrays
10390
- this.columnsByIndex = []; //hold columns in their order in the table
10391
- this.columnsByField = {}; //hold columns with lookup by field name
11065
+ var DataTree = function DataTree(table) {
11066
+ this.table = table;
11067
+ this.indent = 10;
11068
+ this.field = "";
11069
+ this.collapseEl = null;
11070
+ this.expandEl = null;
11071
+ this.branchEl = null;
11072
+
11073
+ this.startOpen = function () {};
11074
+
11075
+ this.displayIndex = 0;
10392
11076
  };
10393
11077
 
10394
- //trigger file download
10395
- Download.prototype.download = function (type, filename, options, interceptCallback) {
10396
- var self = this,
10397
- downloadFunc = false;
11078
+ DataTree.prototype.initialize = function () {
11079
+ var dummyEl = null,
11080
+ options = this.table.options;
10398
11081
 
10399
- function buildLink(data, mime) {
10400
- if (interceptCallback) {
10401
- interceptCallback(data);
11082
+ this.field = options.dataTreeChildField;
11083
+ this.indent = options.dataTreeChildIndent;
11084
+
11085
+ if (options.dataTreeBranchElement) {
11086
+
11087
+ if (options.dataTreeBranchElement === true) {
11088
+ this.branchEl = document.createElement("div");
11089
+ this.branchEl.classList.add("tabulator-data-tree-branch");
10402
11090
  } else {
10403
- self.triggerDownload(data, mime, type, filename);
11091
+ if (typeof options.dataTreeBranchElement === "string") {
11092
+ dummyEl = document.createElement("div");
11093
+ dummyEl.innerHTML = options.dataTreeBranchElement;
11094
+ this.branchEl = dummyEl.firstChild;
11095
+ } else {
11096
+ this.branchEl = options.dataTreeBranchElement;
11097
+ }
10404
11098
  }
10405
11099
  }
10406
11100
 
10407
- if (typeof type == "function") {
10408
- downloadFunc = type;
11101
+ if (options.dataTreeCollapseElement) {
11102
+ if (typeof options.dataTreeCollapseElement === "string") {
11103
+ dummyEl = document.createElement("div");
11104
+ dummyEl.innerHTML = options.dataTreeCollapseElement;
11105
+ this.collapseEl = dummyEl.firstChild;
11106
+ } else {
11107
+ this.collapseEl = options.dataTreeCollapseElement;
11108
+ }
10409
11109
  } else {
10410
- if (self.downloaders[type]) {
10411
- downloadFunc = self.downloaders[type];
11110
+ this.collapseEl = document.createElement("div");
11111
+ this.collapseEl.classList.add("tabulator-data-tree-control");
11112
+ this.collapseEl.innerHTML = "<div class='tabulator-data-tree-control-collapse'></div>";
11113
+ }
11114
+
11115
+ if (options.dataTreeExpandElement) {
11116
+ if (typeof options.dataTreeExpandElement === "string") {
11117
+ dummyEl = document.createElement("div");
11118
+ dummyEl.innerHTML = options.dataTreeExpandElement;
11119
+ this.expandEl = dummyEl.firstChild;
10412
11120
  } else {
10413
- console.warn("Download Error - No such download type found: ", type);
11121
+ this.expandEl = options.dataTreeExpandElement;
11122
+ }
11123
+ } else {
11124
+ this.expandEl = document.createElement("div");
11125
+ this.expandEl.classList.add("tabulator-data-tree-control");
11126
+ this.expandEl.innerHTML = "<div class='tabulator-data-tree-control-expand'></div>";
11127
+ }
11128
+
11129
+ switch (_typeof(options.dataTreeStartExpanded)) {
11130
+ case "boolean":
11131
+ this.startOpen = function (row, index) {
11132
+ return options.dataTreeStartExpanded;
11133
+ };
11134
+ break;
11135
+
11136
+ case "function":
11137
+ this.startOpen = options.dataTreeStartExpanded;
11138
+ break;
11139
+
11140
+ default:
11141
+ this.startOpen = function (row, index) {
11142
+ return options.dataTreeStartExpanded[index];
11143
+ };
11144
+ break;
11145
+ }
11146
+ };
11147
+
11148
+ DataTree.prototype.initializeRow = function (row) {
11149
+
11150
+ var children = typeof row.getData()[this.field] !== "undefined";
11151
+
11152
+ row.modules.dataTree = {
11153
+ index: 0,
11154
+ open: children ? this.startOpen(row.getComponent(), 0) : false,
11155
+ controlEl: false,
11156
+ branchEl: false,
11157
+ parent: false,
11158
+ children: children
11159
+ };
11160
+ };
11161
+
11162
+ DataTree.prototype.layoutRow = function (row) {
11163
+ var cell = row.getCells()[0],
11164
+ el = cell.getElement(),
11165
+ config = row.modules.dataTree;
11166
+
11167
+ el.style.paddingLeft = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + config.index * this.indent + "px";
11168
+
11169
+ if (config.branchEl) {
11170
+ config.branchEl.parentNode.removeChild(config.branchEl);
11171
+ }
11172
+
11173
+ this.generateControlElement(row, el);
11174
+
11175
+ if (config.index && this.branchEl) {
11176
+ config.branchEl = this.branchEl.cloneNode(true);
11177
+ el.insertBefore(config.branchEl, el.firstChild);
11178
+ el.style.paddingLeft = parseInt(el.style.paddingLeft) + (config.branchEl.offsetWidth + config.branchEl.style.marginRight) * (config.index - 1) + "px";
11179
+ }
11180
+ };
11181
+
11182
+ DataTree.prototype.generateControlElement = function (row, el) {
11183
+ var _this24 = this;
11184
+
11185
+ var config = row.modules.dataTree,
11186
+ el = el || row.getCells()[0].getElement(),
11187
+ oldControl = config.controlEl;
11188
+
11189
+ if (config.children !== false) {
11190
+
11191
+ if (config.open) {
11192
+ config.controlEl = this.collapseEl.cloneNode(true);
11193
+ config.controlEl.addEventListener("click", function (e) {
11194
+ e.stopPropagation();
11195
+ _this24.collapseRow(row);
11196
+ });
11197
+ } else {
11198
+ config.controlEl = this.expandEl.cloneNode(true);
11199
+ config.controlEl.addEventListener("click", function (e) {
11200
+ e.stopPropagation();
11201
+ _this24.expandRow(row);
11202
+ });
11203
+ }
11204
+
11205
+ config.controlEl.addEventListener("mousedown", function (e) {
11206
+ e.stopPropagation();
11207
+ });
11208
+
11209
+ if (oldControl && oldControl.parentNode === el) {
11210
+ oldControl.parentNode.replaceChild(config.controlEl, oldControl);
11211
+ } else {
11212
+ el.insertBefore(config.controlEl, el.firstChild);
11213
+ }
11214
+ }
11215
+ };
11216
+
11217
+ DataTree.prototype.setDisplayIndex = function (index) {
11218
+ this.displayIndex = index;
11219
+ };
11220
+
11221
+ DataTree.prototype.getDisplayIndex = function () {
11222
+ return this.displayIndex;
11223
+ };
11224
+
11225
+ DataTree.prototype.getRows = function (rows) {
11226
+ var _this25 = this;
11227
+
11228
+ var output = [];
11229
+
11230
+ rows.forEach(function (row, i) {
11231
+ var config = row.modules.dataTree.children,
11232
+ children;
11233
+
11234
+ output.push(row);
11235
+
11236
+ if (!config.index && config.children !== false) {
11237
+ children = _this25.getChildren(row);
11238
+
11239
+ children.forEach(function (child) {
11240
+ output.push(child);
11241
+ });
11242
+ }
11243
+ });
11244
+
11245
+ return output;
11246
+ };
11247
+
11248
+ DataTree.prototype.getChildren = function (row) {
11249
+ var _this26 = this;
11250
+
11251
+ var config = row.modules.dataTree,
11252
+ output = [];
11253
+
11254
+ if (config.children !== false && config.open) {
11255
+ if (!Array.isArray(config.children)) {
11256
+ config.children = this.generateChildren(row);
11257
+ }
11258
+
11259
+ config.children.forEach(function (child) {
11260
+ output.push(child);
11261
+
11262
+ var subChildren = _this26.getChildren(child);
11263
+
11264
+ subChildren.forEach(function (sub) {
11265
+ output.push(sub);
11266
+ });
11267
+ });
11268
+ }
11269
+
11270
+ return output;
11271
+ };
11272
+
11273
+ DataTree.prototype.generateChildren = function (row) {
11274
+ var _this27 = this;
11275
+
11276
+ var children = [];
11277
+
11278
+ row.getData()[this.field].forEach(function (childData) {
11279
+ var childRow = new Row(childData || {}, _this27.table.rowManager);
11280
+ childRow.modules.dataTree.index = row.modules.dataTree.index + 1;
11281
+ childRow.modules.dataTree.parent = row;
11282
+ childRow.modules.dataTree.open = _this27.startOpen(row, childRow.modules.dataTree.index);
11283
+ children.push(childRow);
11284
+ });
11285
+
11286
+ return children;
11287
+ };
11288
+
11289
+ DataTree.prototype.expandRow = function (row, silent) {
11290
+ var config = row.modules.dataTree;
11291
+
11292
+ if (config.children !== false) {
11293
+ config.open = true;
11294
+
11295
+ row.reinitialize();
11296
+
11297
+ this.table.rowManager.refreshActiveData("tree", false, true);
11298
+
11299
+ this.table.options.dataTreeRowExpanded(row.getComponent(), row.modules.dataTree.index);
11300
+ }
11301
+ };
11302
+
11303
+ DataTree.prototype.collapseRow = function (row) {
11304
+ var config = row.modules.dataTree;
11305
+
11306
+ if (config.children !== false) {
11307
+ config.open = false;
11308
+
11309
+ row.reinitialize();
11310
+
11311
+ this.table.rowManager.refreshActiveData("tree", false, true);
11312
+
11313
+ this.table.options.dataTreeRowCollapsed(row.getComponent(), row.modules.dataTree.index);
11314
+ }
11315
+ };
11316
+
11317
+ DataTree.prototype.toggleRow = function (row) {
11318
+ var config = row.modules.dataTree;
11319
+
11320
+ if (config.children !== false) {
11321
+ if (config.open) {
11322
+ this.collapseRow(row);
11323
+ } else {
11324
+ this.expandRow(row);
11325
+ }
11326
+ }
11327
+ };
11328
+
11329
+ DataTree.prototype.getTreeParent = function (row) {
11330
+ return row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() : false;
11331
+ };
11332
+
11333
+ DataTree.prototype.getTreeChildren = function (row) {
11334
+ var config = row.modules.dataTree,
11335
+ output = [];
11336
+
11337
+ if (config.children) {
11338
+
11339
+ if (!Array.isArray(config.children)) {
11340
+ config.children = this.generateChildren(row);
11341
+ }
11342
+
11343
+ config.children.forEach(function (childRow) {
11344
+ if (childRow instanceof Row) {
11345
+ output.push(childRow.getComponent());
11346
+ }
11347
+ });
11348
+ }
11349
+
11350
+ return output;
11351
+ };
11352
+
11353
+ DataTree.prototype.checkForRestyle = function (cell) {
11354
+ if (!cell.row.cells.indexOf(cell)) {
11355
+ if (cell.row.modules.dataTree.children !== false) {
11356
+ cell.row.reinitialize();
11357
+ }
11358
+ }
11359
+ };
11360
+
11361
+ Tabulator.prototype.registerModule("dataTree", DataTree);
11362
+ var Download = function Download(table) {
11363
+ this.table = table; //hold Tabulator object
11364
+ this.fields = {}; //hold filed multi dimension arrays
11365
+ this.columnsByIndex = []; //hold columns in their order in the table
11366
+ this.columnsByField = {}; //hold columns with lookup by field name
11367
+ this.config = {};
11368
+ };
11369
+
11370
+ //trigger file download
11371
+ Download.prototype.download = function (type, filename, options, interceptCallback) {
11372
+ var self = this,
11373
+ downloadFunc = false;
11374
+ this.processConfig();
11375
+
11376
+ function buildLink(data, mime) {
11377
+ if (interceptCallback) {
11378
+ interceptCallback(data);
11379
+ } else {
11380
+ self.triggerDownload(data, mime, type, filename);
11381
+ }
11382
+ }
11383
+
11384
+ if (typeof type == "function") {
11385
+ downloadFunc = type;
11386
+ } else {
11387
+ if (self.downloaders[type]) {
11388
+ downloadFunc = self.downloaders[type];
11389
+ } else {
11390
+ console.warn("Download Error - No such download type found: ", type);
10414
11391
  }
10415
11392
  }
10416
11393
 
10417
11394
  this.processColumns();
10418
11395
 
10419
11396
  if (downloadFunc) {
10420
- downloadFunc.call(this, self.processDefinitions(), self.processData(), options || {}, buildLink);
11397
+ downloadFunc.call(this, self.processDefinitions(), self.processData(), options || {}, buildLink, this.config);
11398
+ }
11399
+ };
11400
+
11401
+ Download.prototype.processConfig = function () {
11402
+ var config = { //download config
11403
+ columnGroups: true,
11404
+ rowGroups: true
11405
+ };
11406
+
11407
+ if (this.table.options.downloadConfig) {
11408
+ for (var key in this.table.options.downloadConfig) {
11409
+ config[key] = this.table.options.downloadConfig[key];
11410
+ }
11411
+ }
11412
+
11413
+ if (config.rowGroups && this.table.options.groupBy && this.table.modExists("groupRows")) {
11414
+ this.config.rowGroups = true;
11415
+ }
11416
+
11417
+ if (config.columnGroups && this.table.columnManager.columns.length != this.table.columnManager.columnsByIndex.length) {
11418
+ this.config.columnGroups = true;
10421
11419
  }
10422
11420
  };
10423
11421
 
@@ -10440,31 +11438,94 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10440
11438
  var self = this,
10441
11439
  processedDefinitions = [];
10442
11440
 
10443
- self.columnsByIndex.forEach(function (column) {
10444
- var definition = column.definition;
10445
-
10446
- if (column.download !== false) {
10447
- //isolate definiton from defintion object
10448
- var def = {};
11441
+ if (this.config.columnGroups) {
11442
+ self.table.columnManager.columns.forEach(function (column) {
11443
+ var colData = self.processColumnGroup(column);
10449
11444
 
10450
- for (var key in definition) {
10451
- def[key] = definition[key];
11445
+ if (colData) {
11446
+ processedDefinitions.push(colData);
11447
+ }
11448
+ });
11449
+ } else {
11450
+ self.columnsByIndex.forEach(function (column) {
11451
+ if (column.download !== false) {
11452
+ //isolate definiton from defintion object
11453
+ processedDefinitions.push(self.processDefinition(column));
10452
11454
  }
11455
+ });
11456
+ }
11457
+
11458
+ return processedDefinitions;
11459
+ };
11460
+
11461
+ Download.prototype.processColumnGroup = function (column) {
11462
+ var _this28 = this;
11463
+
11464
+ var subGroups = column.columns;
10453
11465
 
10454
- if (typeof definition.downloadTitle != "undefined") {
10455
- def.title = definition.downloadTitle;
11466
+ var groupData = {
11467
+ type: "group",
11468
+ title: column.definition.title
11469
+ };
11470
+
11471
+ if (subGroups.length) {
11472
+ groupData.subGroups = [];
11473
+ groupData.width = 0;
11474
+
11475
+ subGroups.forEach(function (subGroup) {
11476
+ var subGroupData = _this28.processColumnGroup(subGroup);
11477
+
11478
+ if (subGroupData) {
11479
+ groupData.width += subGroupData.width;
11480
+ groupData.subGroups.push(subGroupData);
10456
11481
  }
11482
+ });
10457
11483
 
10458
- processedDefinitions.push(def);
11484
+ if (!groupData.width) {
11485
+ return false;
10459
11486
  }
10460
- });
11487
+ } else {
11488
+ if (column.field && column.visible && column.definition.download !== false) {
11489
+ groupData.width = 1;
11490
+ groupData.definition = this.processDefinition(column);
11491
+ } else {
11492
+ return false;
11493
+ }
11494
+ }
10461
11495
 
10462
- return processedDefinitions;
11496
+ return groupData;
11497
+ };
11498
+
11499
+ Download.prototype.processDefinition = function (column) {
11500
+ var def = {};
11501
+
11502
+ for (var key in column.definition) {
11503
+ def[key] = column.definition[key];
11504
+ }
11505
+
11506
+ if (typeof column.definition.downloadTitle != "undefined") {
11507
+ def.title = column.definition.downloadTitle;
11508
+ }
11509
+
11510
+ return def;
10463
11511
  };
10464
11512
 
10465
11513
  Download.prototype.processData = function () {
11514
+ var _this29 = this;
11515
+
10466
11516
  var self = this,
10467
- data = self.table.rowManager.getData(true, "download");
11517
+ data = [],
11518
+ groups = [];
11519
+
11520
+ if (this.config.rowGroups) {
11521
+ groups = this.table.modules.groupRows.getGroups();
11522
+
11523
+ groups.forEach(function (group) {
11524
+ data.push(_this29.processGroupData(group));
11525
+ });
11526
+ } else {
11527
+ data = self.table.rowManager.getData(true, "download");
11528
+ }
10468
11529
 
10469
11530
  //bulk data processing
10470
11531
  if (typeof self.table.options.downloadDataFormatter == "function") {
@@ -10474,6 +11535,29 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10474
11535
  return data;
10475
11536
  };
10476
11537
 
11538
+ Download.prototype.processGroupData = function (group) {
11539
+ var _this30 = this;
11540
+
11541
+ var subGroups = group.getSubGroups();
11542
+
11543
+ var groupData = {
11544
+ type: "group",
11545
+ key: group.key
11546
+ };
11547
+
11548
+ if (subGroups.length) {
11549
+ groupData.subGroups = [];
11550
+
11551
+ subGroups.forEach(function (subGroup) {
11552
+ groupData.subGroups.push(_this30.processGroupData(subGroup));
11553
+ });
11554
+ } else {
11555
+ groupData.rows = group.getData(true, "download");
11556
+ }
11557
+
11558
+ return groupData;
11559
+ };
11560
+
10477
11561
  Download.prototype.triggerDownload = function (data, mime, type, filename) {
10478
11562
  var element = document.createElement('a'),
10479
11563
  blob = new Blob([data], { type: mime }),
@@ -10527,107 +11611,214 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10527
11611
 
10528
11612
  //downloaders
10529
11613
  Download.prototype.downloaders = {
10530
- csv: function csv(columns, data, options, setFileContents) {
11614
+ csv: function csv(columns, data, options, setFileContents, config) {
10531
11615
  var self = this,
10532
11616
  titles = [],
10533
11617
  fields = [],
10534
11618
  delimiter = options && options.delimiter ? options.delimiter : ",",
10535
11619
  fileContents;
10536
11620
 
10537
- //get field lists
10538
- columns.forEach(function (column) {
10539
- if (column.field) {
11621
+ //build column headers
11622
+ function parseSimpleTitles() {
11623
+ columns.forEach(function (column) {
10540
11624
  titles.push('"' + String(column.title).split('"').join('""') + '"');
10541
11625
  fields.push(column.field);
11626
+ });
11627
+ }
11628
+
11629
+ function parseColumnGroup(column, level) {
11630
+ if (column.subGroups) {
11631
+ column.subGroups.forEach(function (subGroup) {
11632
+ parseColumnGroup(subGroup, level + 1);
11633
+ });
11634
+ } else {
11635
+ titles.push('"' + String(column.title).split('"').join('""') + '"');
11636
+ fields.push(column.definition.field);
10542
11637
  }
10543
- });
11638
+ }
11639
+
11640
+ if (config.columnGroups) {
11641
+ console.warn("Download Warning - CSV downloader cannot process column groups");
11642
+
11643
+ columns.forEach(function (column) {
11644
+ parseColumnGroup(column, 0);
11645
+ });
11646
+ } else {
11647
+ parseSimpleTitles();
11648
+ }
10544
11649
 
10545
11650
  //generate header row
10546
11651
  fileContents = [titles.join(delimiter)];
10547
11652
 
10548
- //generate each row of the table
10549
- data.forEach(function (row) {
10550
- var rowData = [];
11653
+ function parseRows(data) {
11654
+ //generate each row of the table
11655
+ data.forEach(function (row) {
11656
+ var rowData = [];
10551
11657
 
10552
- fields.forEach(function (field) {
10553
- var value = self.getFieldValue(field, row);
11658
+ fields.forEach(function (field) {
11659
+ var value = self.getFieldValue(field, row);
10554
11660
 
10555
- switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
10556
- case "object":
10557
- value = JSON.stringify(value);
10558
- break;
11661
+ switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
11662
+ case "object":
11663
+ value = JSON.stringify(value);
11664
+ break;
10559
11665
 
10560
- case "undefined":
10561
- case "null":
10562
- value = "";
10563
- break;
11666
+ case "undefined":
11667
+ case "null":
11668
+ value = "";
11669
+ break;
10564
11670
 
10565
- default:
10566
- value = value;
10567
- }
11671
+ default:
11672
+ value = value;
11673
+ }
10568
11674
 
10569
- //escape uotation marks
10570
- rowData.push('"' + String(value).split('"').join('""') + '"');
10571
- });
11675
+ //escape quotation marks
11676
+ rowData.push('"' + String(value).split('"').join('""') + '"');
11677
+ });
10572
11678
 
10573
- fileContents.push(rowData.join(delimiter));
10574
- });
11679
+ fileContents.push(rowData.join(delimiter));
11680
+ });
11681
+ }
11682
+
11683
+ function parseGroup(group) {
11684
+ if (group.subGroups) {
11685
+ group.subGroups.forEach(function (subGroup) {
11686
+ parseGroup(subGroup);
11687
+ });
11688
+ } else {
11689
+ parseRows(group.rows);
11690
+ }
11691
+ }
11692
+
11693
+ if (config.rowGroups) {
11694
+ console.warn("Download Warning - CSV downloader cannot process row groups");
11695
+
11696
+ data.forEach(function (group) {
11697
+ parseGroup(group);
11698
+ });
11699
+ } else {
11700
+ parseRows(data);
11701
+ }
10575
11702
 
10576
11703
  setFileContents(fileContents.join("\n"), "text/csv");
10577
11704
  },
10578
11705
 
10579
- json: function json(columns, data, options, setFileContents) {
11706
+ json: function json(columns, data, options, setFileContents, config) {
10580
11707
  var fileContents = JSON.stringify(data, null, '\t');
10581
11708
 
10582
11709
  setFileContents(fileContents, "application/json");
10583
11710
  },
10584
11711
 
10585
- pdf: function pdf(columns, data, options, setFileContents) {
11712
+ pdf: function pdf(columns, data, options, setFileContents, config) {
10586
11713
  var self = this,
10587
11714
  fields = [],
10588
11715
  header = [],
10589
11716
  body = [],
10590
11717
  table = "",
11718
+ groupRowIndexs = [],
10591
11719
  autoTableParams = {},
10592
- title = options && options.title ? options.title : "",
10593
- orientation = options && options.orientation == "portrait" ? "p" : "l";
11720
+ rowGroupStyles = {},
11721
+ jsPDFParams = options.jsPDF || {},
11722
+ title = options && options.title ? options.title : "";
11723
+
11724
+ if (!jsPDFParams.orientation) {
11725
+ jsPDFParams.orientation = options.orientation || "landscape";
11726
+ }
11727
+
11728
+ if (!jsPDFParams.unit) {
11729
+ jsPDFParams.unit = "pt";
11730
+ }
10594
11731
 
10595
11732
  //build column headers
10596
- columns.forEach(function (column) {
10597
- if (column.field) {
11733
+ function parseSimpleTitles() {
11734
+ columns.forEach(function (column) {
11735
+ if (column.field) {
11736
+ header.push(column.title || "");
11737
+ fields.push(column.field);
11738
+ }
11739
+ });
11740
+ }
11741
+
11742
+ function parseColumnGroup(column, level) {
11743
+ if (column.subGroups) {
11744
+ column.subGroups.forEach(function (subGroup) {
11745
+ parseColumnGroup(subGroup, level + 1);
11746
+ });
11747
+ } else {
10598
11748
  header.push(column.title || "");
10599
- fields.push(column.field);
11749
+ fields.push(column.definition.field);
10600
11750
  }
10601
- });
11751
+ }
10602
11752
 
10603
- //build table rows
10604
- data.forEach(function (row) {
10605
- var rowData = [];
11753
+ if (config.columnGroups) {
11754
+ console.warn("Download Warning - PDF downloader cannot process column groups");
10606
11755
 
10607
- fields.forEach(function (field) {
10608
- var value = self.getFieldValue(field, row);
11756
+ columns.forEach(function (column) {
11757
+ parseColumnGroup(column, 0);
11758
+ });
11759
+ } else {
11760
+ parseSimpleTitles();
11761
+ }
10609
11762
 
10610
- switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
10611
- case "object":
10612
- value = JSON.stringify(value);
10613
- break;
11763
+ function parseValue(value) {
11764
+ switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
11765
+ case "object":
11766
+ value = JSON.stringify(value);
11767
+ break;
10614
11768
 
10615
- case "undefined":
10616
- case "null":
10617
- value = "";
10618
- break;
11769
+ case "undefined":
11770
+ case "null":
11771
+ value = "";
11772
+ break;
10619
11773
 
10620
- default:
10621
- value = value;
10622
- }
11774
+ default:
11775
+ value = value;
11776
+ }
10623
11777
 
10624
- rowData.push(value);
11778
+ return value;
11779
+ }
11780
+
11781
+ function parseRows(data) {
11782
+ //build table rows
11783
+ data.forEach(function (row) {
11784
+ var rowData = [];
11785
+
11786
+ fields.forEach(function (field) {
11787
+ var value = self.getFieldValue(field, row);
11788
+ rowData.push(parseValue(value));
11789
+ });
11790
+
11791
+ body.push(rowData);
10625
11792
  });
11793
+ }
10626
11794
 
10627
- body.push(rowData);
10628
- });
11795
+ function parseGroup(group) {
11796
+ var groupData = [];
11797
+
11798
+ groupData.push(parseValue(group.key));
11799
+
11800
+ groupRowIndexs.push(body.length);
11801
+
11802
+ body.push(groupData);
11803
+
11804
+ if (group.subGroups) {
11805
+ group.subGroups.forEach(function (subGroup) {
11806
+ parseGroup(subGroup);
11807
+ });
11808
+ } else {
11809
+ parseRows(group.rows);
11810
+ }
11811
+ }
10629
11812
 
10630
- var doc = new jsPDF(orientation, 'pt'); //set document to landscape, better for most tables
11813
+ if (config.rowGroups) {
11814
+ data.forEach(function (group) {
11815
+ parseGroup(group);
11816
+ });
11817
+ } else {
11818
+ parseRows(data);
11819
+ }
11820
+
11821
+ var doc = new jsPDF(jsPDFParams); //set document to landscape, better for most tables
10631
11822
 
10632
11823
  if (options && options.autoTable) {
10633
11824
  if (typeof options.autoTable === "function") {
@@ -10637,6 +11828,34 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10637
11828
  }
10638
11829
  }
10639
11830
 
11831
+ if (config.rowGroups) {
11832
+ var createdCell = function createdCell(cell, data) {
11833
+ if (groupRowIndexs.indexOf(data.row.index) > -1) {
11834
+ for (var key in rowGroupStyles) {
11835
+ cell.styles[key] = rowGroupStyles[key];
11836
+ }
11837
+ }
11838
+ };
11839
+
11840
+ rowGroupStyles = options.rowGroupStyles || {
11841
+ fontStyle: "bold",
11842
+ fontSize: 12,
11843
+ cellPadding: 6,
11844
+ fillColor: 220
11845
+ };
11846
+
11847
+ if (!autoTableParams.createdCell) {
11848
+ autoTableParams.createdCell = createdCell;
11849
+ } else {
11850
+ var createdCellHolder = autoTableParams.createdCell;
11851
+
11852
+ autoTableParams.createdCell = function (cell, data) {
11853
+ createdCell(cell, data);
11854
+ createdCellHolder(cell, data);
11855
+ };
11856
+ }
11857
+ }
11858
+
10640
11859
  if (title) {
10641
11860
  autoTableParams.addPageContent = function (data) {
10642
11861
  doc.text(title, 40, 30);
@@ -10648,10 +11867,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10648
11867
  setFileContents(doc.output("arraybuffer"), "application/pdf");
10649
11868
  },
10650
11869
 
10651
- xlsx: function xlsx(columns, data, options, setFileContents) {
11870
+ xlsx: function xlsx(columns, data, options, setFileContents, config) {
10652
11871
  var self = this,
10653
11872
  sheetName = options.sheetName || "Sheet1",
10654
11873
  workbook = { SheetNames: [], Sheets: {} },
11874
+ groupRowIndexs = [],
11875
+ groupColumnIndexs = [],
10655
11876
  output;
10656
11877
 
10657
11878
  function generateSheet() {
@@ -10669,29 +11890,155 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10669
11890
 
10670
11891
  sheet['!ref'] = XLSX.utils.encode_range(range);
10671
11892
 
11893
+ var merges = generateMerges();
11894
+
11895
+ if (merges.length) {
11896
+ sheet["!merges"] = merges;
11897
+ }
11898
+
10672
11899
  return sheet;
10673
11900
  }
10674
11901
 
10675
- //get field lists
10676
- columns.forEach(function (column) {
10677
- if (column.field) {
11902
+ function parseSimpleTitles() {
11903
+ //get field lists
11904
+ columns.forEach(function (column) {
10678
11905
  titles.push(column.title);
10679
11906
  fields.push(column.field);
11907
+ });
11908
+
11909
+ rows.push(titles);
11910
+ }
11911
+
11912
+ function parseColumnGroup(column, level) {
11913
+
11914
+ if (typeof titles[level] === "undefined") {
11915
+ titles[level] = [];
10680
11916
  }
10681
- });
10682
11917
 
10683
- rows.push(titles);
11918
+ if (typeof groupColumnIndexs[level] === "undefined") {
11919
+ groupColumnIndexs[level] = [];
11920
+ }
11921
+
11922
+ if (column.width > 1) {
11923
+
11924
+ groupColumnIndexs[level].push({
11925
+ type: "hoz",
11926
+ start: titles[level].length,
11927
+ end: titles[level].length + column.width - 1
11928
+ });
11929
+ }
11930
+
11931
+ titles[level].push(column.title);
11932
+
11933
+ if (column.subGroups) {
11934
+ column.subGroups.forEach(function (subGroup) {
11935
+ parseColumnGroup(subGroup, level + 1);
11936
+ });
11937
+ } else {
11938
+ fields.push(column.definition.field);
11939
+ padColumnTitles(fields.length - 1, level);
11940
+
11941
+ groupColumnIndexs[level].push({
11942
+ type: "vert",
11943
+ start: fields.length - 1
11944
+ });
11945
+ }
11946
+ }
11947
+
11948
+ function padColumnTitles() {
11949
+ var max = 0;
11950
+
11951
+ titles.forEach(function (title) {
11952
+ var len = title.length;
11953
+ if (len > max) {
11954
+ max = len;
11955
+ }
11956
+ });
11957
+
11958
+ titles.forEach(function (title) {
11959
+ var len = title.length;
11960
+ if (len < max) {
11961
+ for (var i = len; i < max; i++) {
11962
+ title.push("");
11963
+ }
11964
+ }
11965
+ });
11966
+ }
11967
+
11968
+ if (config.columnGroups) {
11969
+ columns.forEach(function (column) {
11970
+ parseColumnGroup(column, 0);
11971
+ });
11972
+
11973
+ titles.forEach(function (title) {
11974
+ rows.push(title);
11975
+ });
11976
+ } else {
11977
+ parseSimpleTitles();
11978
+ }
11979
+
11980
+ function generateMerges() {
11981
+ var output = [];
11982
+
11983
+ groupRowIndexs.forEach(function (index) {
11984
+ output.push({ s: { r: index, c: 0 }, e: { r: index, c: fields.length - 1 } });
11985
+ });
11986
+
11987
+ groupColumnIndexs.forEach(function (merges, level) {
11988
+ merges.forEach(function (merge) {
11989
+ if (merge.type === "hoz") {
11990
+ output.push({ s: { r: level, c: merge.start }, e: { r: level, c: merge.end } });
11991
+ } else {
11992
+ if (level != titles.length - 1) {
11993
+ output.push({ s: { r: level, c: merge.start }, e: { r: titles.length - 1, c: merge.start } });
11994
+ }
11995
+ }
11996
+ });
11997
+ });
11998
+
11999
+ return output;
12000
+ }
10684
12001
 
10685
12002
  //generate each row of the table
10686
- data.forEach(function (row) {
10687
- var rowData = [];
12003
+ function parseRows(data) {
12004
+ data.forEach(function (row) {
12005
+ var rowData = [];
10688
12006
 
10689
- fields.forEach(function (field) {
10690
- rowData.push(self.getFieldValue(field, row));
12007
+ fields.forEach(function (field) {
12008
+ var value = self.getFieldValue(field, row);
12009
+
12010
+ rowData.push((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === "object" ? JSON.stringify(value) : value);
12011
+ });
12012
+
12013
+ rows.push(rowData);
10691
12014
  });
12015
+ }
10692
12016
 
10693
- rows.push(rowData);
10694
- });
12017
+ function parseGroup(group) {
12018
+ var groupData = [];
12019
+
12020
+ groupData.push(group.key);
12021
+
12022
+ groupRowIndexs.push(rows.length);
12023
+
12024
+ rows.push(groupData);
12025
+
12026
+ if (group.subGroups) {
12027
+ group.subGroups.forEach(function (subGroup) {
12028
+ parseGroup(subGroup);
12029
+ });
12030
+ } else {
12031
+ parseRows(group.rows);
12032
+ }
12033
+ }
12034
+
12035
+ if (config.rowGroups) {
12036
+ data.forEach(function (group) {
12037
+ parseGroup(group);
12038
+ });
12039
+ } else {
12040
+ parseRows(data);
12041
+ }
10695
12042
 
10696
12043
  worksheet = rowsToSheet();
10697
12044
 
@@ -10765,6 +12112,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10765
12112
  //set column editor
10766
12113
  switch (_typeof(column.definition.editor)) {
10767
12114
  case "string":
12115
+
12116
+ if (column.definition.editor === "tick") {
12117
+ column.definition.editor = "tickCross";
12118
+ console.warn("DEPRICATION WANRING - the tick editor has been depricated, please use the tickCross editor");
12119
+ }
12120
+
10768
12121
  if (self.editors[column.definition.editor]) {
10769
12122
  config.editor = self.editors[column.definition.editor];
10770
12123
  } else {
@@ -10781,6 +12134,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10781
12134
  if (column.definition.editor === true) {
10782
12135
 
10783
12136
  if (typeof column.definition.formatter !== "function") {
12137
+
12138
+ if (column.definition.formatter === "tick") {
12139
+ column.definition.formatter = "tickCross";
12140
+ console.warn("DEPRICATION WANRING - the tick editor has been depricated, please use the tickCross editor");
12141
+ }
12142
+
10784
12143
  if (self.editors[column.definition.formatter]) {
10785
12144
  config.editor = self.editors[column.definition.formatter];
10786
12145
  } else {
@@ -10902,6 +12261,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10902
12261
  if (valid === true) {
10903
12262
  self.clearEditor();
10904
12263
  cell.setValue(value, true);
12264
+
12265
+ if (self.table.options.dataTree && self.table.modExists("dataTree")) {
12266
+ self.table.modules.dataTree.checkForRestyle(cell);
12267
+ }
10905
12268
  } else {
10906
12269
  self.invalidEdit = true;
10907
12270
  element.classList.add("tabulator-validation-fail");
@@ -10918,6 +12281,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10918
12281
  function cancel() {
10919
12282
  if (self.currentCell === cell) {
10920
12283
  self.cancelEdit();
12284
+
12285
+ if (self.table.options.dataTree && self.table.modExists("dataTree")) {
12286
+ self.table.modules.dataTree.checkForRestyle(cell);
12287
+ }
10921
12288
  } else {
10922
12289
  // console.warn("Edit Success Error - cannot call cancel on a cell that is no longer being edited");
10923
12290
  }
@@ -10970,22 +12337,29 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
10970
12337
 
10971
12338
  //if editor returned, add to DOM, if false, abort edit
10972
12339
  if (cellEditor !== false) {
10973
- element.classList.add("tabulator-editing");
10974
- cell.row.getElement().classList.add("tabulator-row-editing");
10975
- while (element.firstChild) {
10976
- element.removeChild(element.firstChild);
10977
- }element.appendChild(cellEditor);
10978
12340
 
10979
- //trigger onRendered Callback
10980
- rendered();
12341
+ if (cellEditor instanceof Node) {
12342
+ element.classList.add("tabulator-editing");
12343
+ cell.row.getElement().classList.add("tabulator-row-editing");
12344
+ while (element.firstChild) {
12345
+ element.removeChild(element.firstChild);
12346
+ }element.appendChild(cellEditor);
10981
12347
 
10982
- //prevent editing from triggering rowClick event
10983
- var children = element.children;
12348
+ //trigger onRendered Callback
12349
+ rendered();
10984
12350
 
10985
- for (var i = 0; i < children.length; i++) {
10986
- children[i].addEventListener("click", function (e) {
10987
- e.stopPropagation();
10988
- });
12351
+ //prevent editing from triggering rowClick event
12352
+ var children = element.children;
12353
+
12354
+ for (var i = 0; i < children.length; i++) {
12355
+ children[i].addEventListener("click", function (e) {
12356
+ e.stopPropagation();
12357
+ });
12358
+ }
12359
+ } else {
12360
+ console.warn("Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor);
12361
+ element.blur();
12362
+ return false;
10989
12363
  }
10990
12364
  } else {
10991
12365
  element.blur();
@@ -11029,7 +12403,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11029
12403
  });
11030
12404
 
11031
12405
  function onChange(e) {
11032
- if (input.value != cellValue) {
12406
+ if ((cellValue === null || typeof cellValue === "undefined") && input.value !== "" || input.value != cellValue) {
11033
12407
  success(input.value);
11034
12408
  } else {
11035
12409
  cancel();
@@ -11082,7 +12456,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11082
12456
  });
11083
12457
 
11084
12458
  function onChange(e) {
11085
- if (input.value != cellValue) {
12459
+
12460
+ if ((cellValue === null || typeof cellValue === "undefined") && input.value !== "" || input.value != cellValue) {
11086
12461
  success(input.value);
11087
12462
  setTimeout(function () {
11088
12463
  cell.getRow().normalizeHeight();
@@ -11110,235 +12485,740 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11110
12485
  }
11111
12486
  });
11112
12487
 
11113
- input.addEventListener("keydown", function (e) {
11114
- if (e.keyCode == 27) {
11115
- cancel();
12488
+ input.addEventListener("keydown", function (e) {
12489
+ if (e.keyCode == 27) {
12490
+ cancel();
12491
+ }
12492
+ });
12493
+
12494
+ return input;
12495
+ },
12496
+
12497
+ //input element with type of number
12498
+ number: function number(cell, onRendered, success, cancel, editorParams) {
12499
+
12500
+ var cellValue = cell.getValue(),
12501
+ input = document.createElement("input");
12502
+
12503
+ input.setAttribute("type", "number");
12504
+
12505
+ if (typeof editorParams.max != "undefined") {
12506
+ input.setAttribute("max", editorParams.max);
12507
+ }
12508
+
12509
+ if (typeof editorParams.min != "undefined") {
12510
+ input.setAttribute("min", editorParams.min);
12511
+ }
12512
+
12513
+ if (typeof editorParams.step != "undefined") {
12514
+ input.setAttribute("step", editorParams.step);
12515
+ }
12516
+
12517
+ //create and style input
12518
+ input.style.padding = "4px";
12519
+ input.style.width = "100%";
12520
+ input.style.boxSizing = "border-box";
12521
+
12522
+ input.value = cellValue;
12523
+
12524
+ onRendered(function () {
12525
+ input.focus();
12526
+ input.style.height = "100%";
12527
+ });
12528
+
12529
+ function onChange() {
12530
+ var value = input.value;
12531
+
12532
+ if (!isNaN(value) && value !== "") {
12533
+ value = Number(value);
12534
+ }
12535
+
12536
+ if (value != cellValue) {
12537
+ success(value);
12538
+ } else {
12539
+ cancel();
12540
+ }
12541
+ }
12542
+
12543
+ //submit new value on blur
12544
+ input.addEventListener("blur", function (e) {
12545
+ onChange();
12546
+ });
12547
+
12548
+ //submit new value on enter
12549
+ input.addEventListener("keydown", function (e) {
12550
+ switch (e.keyCode) {
12551
+ case 13:
12552
+ case 9:
12553
+ onChange();
12554
+ break;
12555
+
12556
+ case 27:
12557
+ cancel();
12558
+ break;
12559
+ }
12560
+ });
12561
+
12562
+ return input;
12563
+ },
12564
+
12565
+ //input element with type of number
12566
+ range: function range(cell, onRendered, success, cancel, editorParams) {
12567
+
12568
+ var cellValue = cell.getValue(),
12569
+ input = document.createElement("input");
12570
+
12571
+ input.setAttribute("type", "range");
12572
+
12573
+ if (typeof editorParams.max != "undefined") {
12574
+ input.setAttribute("max", editorParams.max);
12575
+ }
12576
+
12577
+ if (typeof editorParams.min != "undefined") {
12578
+ input.setAttribute("min", editorParams.min);
12579
+ }
12580
+
12581
+ if (typeof editorParams.step != "undefined") {
12582
+ input.setAttribute("step", editorParams.step);
12583
+ }
12584
+
12585
+ //create and style input
12586
+ input.style.padding = "4px";
12587
+ input.style.width = "100%";
12588
+ input.style.boxSizing = "border-box";
12589
+
12590
+ input.value = cellValue;
12591
+
12592
+ onRendered(function () {
12593
+ input.focus();
12594
+ input.style.height = "100%";
12595
+ });
12596
+
12597
+ function onChange() {
12598
+ var value = input.value;
12599
+
12600
+ if (!isNaN(value) && value !== "") {
12601
+ value = Number(value);
12602
+ }
12603
+
12604
+ if (value != cellValue) {
12605
+ success(value);
12606
+ } else {
12607
+ cancel();
12608
+ }
12609
+ }
12610
+
12611
+ //submit new value on blur
12612
+ input.addEventListener("blur", function (e) {
12613
+ onChange();
12614
+ });
12615
+
12616
+ //submit new value on enter
12617
+ input.addEventListener("keydown", function (e) {
12618
+ switch (e.keyCode) {
12619
+ case 13:
12620
+ case 9:
12621
+ onChange();
12622
+ break;
12623
+
12624
+ case 27:
12625
+ cancel();
12626
+ break;
12627
+ }
12628
+ });
12629
+
12630
+ return input;
12631
+ },
12632
+
12633
+ //select
12634
+ select: function select(cell, onRendered, success, cancel, editorParams) {
12635
+ var self = this,
12636
+ cellEl = cell.getElement(),
12637
+ initialValue = cell.getValue(),
12638
+ input = document.createElement("input"),
12639
+ listEl = document.createElement("div"),
12640
+ dataItems = [],
12641
+ displayItems = [],
12642
+ currentItem = {},
12643
+ blurable = true;
12644
+
12645
+ if (Array.isArray(editorParams) || !Array.isArray(editorParams) && (typeof editorParams === 'undefined' ? 'undefined' : _typeof(editorParams)) === "object" && !editorParams.values) {
12646
+ console.warn("DEPRICATION WANRING - values for the select editor must now be passed into the valuse property of the editorParams object, not as the editorParams object");
12647
+ editorParams = { values: editorParams };
12648
+ }
12649
+
12650
+ function getUniqueColumnValues() {
12651
+ var output = {},
12652
+ column = cell.getColumn()._getSelf(),
12653
+ data = self.table.getData();
12654
+
12655
+ data.forEach(function (row) {
12656
+ var val = column.getFieldValue(row);
12657
+
12658
+ if (val !== null && typeof val !== "undefined" && val !== "") {
12659
+ output[val] = true;
12660
+ }
12661
+ });
12662
+
12663
+ return Object.keys(output);
12664
+ }
12665
+
12666
+ function parseItems(inputValues, curentValue) {
12667
+ var dataList = [];
12668
+ var displayList = [];
12669
+
12670
+ function processComplexListItem(item) {
12671
+ var item = {
12672
+ label: editorParams.listItemFormatter ? editorParams.listItemFormatter(item.value, item.label) : item.label,
12673
+ value: item.value,
12674
+ element: false
12675
+ };
12676
+
12677
+ if (item.value === curentValue) {
12678
+ setCurrentItem(item);
12679
+ }
12680
+
12681
+ dataList.push(item);
12682
+ displayList.push(item);
12683
+
12684
+ return item;
12685
+ }
12686
+
12687
+ if (typeof inputValues == "function") {
12688
+ inputValues = inputValues(cell);
12689
+ }
12690
+
12691
+ if (Array.isArray(inputValues)) {
12692
+ inputValues.forEach(function (value) {
12693
+ var item;
12694
+
12695
+ if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === "object") {
12696
+
12697
+ if (value.options) {
12698
+ item = {
12699
+ label: value.label,
12700
+ group: true,
12701
+ element: false
12702
+ };
12703
+
12704
+ displayList.push(item);
12705
+
12706
+ value.options.forEach(function (item) {
12707
+ processComplexListItem(item);
12708
+ });
12709
+ } else {
12710
+ processComplexListItem(value);
12711
+ }
12712
+ } else {
12713
+ item = {
12714
+ label: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
12715
+ value: value,
12716
+ element: false
12717
+ };
12718
+
12719
+ if (item.value === curentValue) {
12720
+ setCurrentItem(item);
12721
+ }
12722
+
12723
+ dataList.push(item);
12724
+ displayList.push(item);
12725
+ }
12726
+ });
12727
+ } else {
12728
+ for (var key in inputValues) {
12729
+ var item = {
12730
+ label: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
12731
+ value: key,
12732
+ element: false
12733
+ };
12734
+
12735
+ if (item.value === curentValue) {
12736
+ setCurrentItem(item);
12737
+ }
12738
+
12739
+ dataList.push(item);
12740
+ displayList.push(item);
12741
+ }
12742
+ }
12743
+
12744
+ dataItems = dataList;
12745
+ displayItems = displayList;
12746
+
12747
+ fillList();
12748
+ }
12749
+
12750
+ function fillList() {
12751
+ while (listEl.firstChild) {
12752
+ listEl.removeChild(listEl.firstChild);
12753
+ }displayItems.forEach(function (item) {
12754
+ var el = item.element;
12755
+
12756
+ if (!el) {
12757
+
12758
+ if (item.group) {
12759
+ el = document.createElement("div");
12760
+ el.classList.add("tabulator-edit-select-list-group");
12761
+ el.tabIndex = 0;
12762
+ el.innerHTML = item.label;
12763
+ } else {
12764
+ el = document.createElement("div");
12765
+ el.classList.add("tabulator-edit-select-list-item");
12766
+ el.tabIndex = 0;
12767
+ el.innerHTML = item.label;
12768
+
12769
+ el.addEventListener("click", function () {
12770
+ setCurrentItem(item);
12771
+ chooseItem();
12772
+ });
12773
+
12774
+ if (item === currentItem) {
12775
+ el.classList.add("active");
12776
+ }
12777
+ }
12778
+
12779
+ el.addEventListener("mousedown", function () {
12780
+ blurable = false;
12781
+
12782
+ setTimeout(function () {
12783
+ blurable = true;
12784
+ }, 10);
12785
+ });
12786
+
12787
+ item.element = el;
12788
+ }
12789
+
12790
+ listEl.appendChild(el);
12791
+ });
12792
+ }
12793
+
12794
+ function setCurrentItem(item) {
12795
+
12796
+ if (currentItem && currentItem.element) {
12797
+ currentItem.element.classList.remove("active");
12798
+ }
12799
+
12800
+ currentItem = item;
12801
+ input.value = item.label;
12802
+
12803
+ if (item.element) {
12804
+ item.element.classList.add("active");
12805
+ }
12806
+ }
12807
+
12808
+ function chooseItem() {
12809
+ hideList();
12810
+
12811
+ if (initialValue !== currentItem.value) {
12812
+ success(currentItem.value);
12813
+ } else {
12814
+ cancel();
12815
+ }
12816
+ }
12817
+
12818
+ function cancelItem() {
12819
+ hideList();
12820
+ cancel();
12821
+ }
12822
+
12823
+ function showList() {
12824
+ if (!listEl.parentNode) {
12825
+
12826
+ if (editorParams.values === true) {
12827
+ parseItems(getUniqueColumnValues(), initialValue);
12828
+ } else {
12829
+ parseItems(editorParams.values || [], initialValue);
12830
+ }
12831
+
12832
+ var offset = Tabulator.prototype.helpers.elOffset(cellEl);
12833
+
12834
+ listEl.style.minWidth = cellEl.offsetWidth + "px";
12835
+
12836
+ listEl.style.top = offset.top + cellEl.offsetHeight + "px";
12837
+ listEl.style.left = offset.left + "px";
12838
+ document.body.appendChild(listEl);
12839
+ }
12840
+ }
12841
+
12842
+ function hideList() {
12843
+ if (listEl.parentNode) {
12844
+ listEl.parentNode.removeChild(listEl);
12845
+ }
12846
+ }
12847
+
12848
+ //style input
12849
+ input.setAttribute("type", "text");
12850
+
12851
+ input.style.padding = "4px";
12852
+ input.style.width = "100%";
12853
+ input.style.boxSizing = "border-box";
12854
+ input.readonly = true;
12855
+
12856
+ //allow key based navigation
12857
+ input.addEventListener("keydown", function (e) {
12858
+ var index;
12859
+
12860
+ switch (e.keyCode) {
12861
+ case 38:
12862
+ //up arrow
12863
+ e.stopImmediatePropagation();
12864
+ e.stopPropagation();
12865
+
12866
+ index = dataItems.indexOf(currentItem);
12867
+
12868
+ if (index > 0) {
12869
+ setCurrentItem(dataItems[index - 1]);
12870
+ }
12871
+ break;
12872
+
12873
+ case 40:
12874
+ //down arrow
12875
+ e.stopImmediatePropagation();
12876
+ e.stopPropagation();
12877
+
12878
+ index = dataItems.indexOf(currentItem);
12879
+
12880
+ if (index < dataItems.length - 1) {
12881
+ if (index == -1) {
12882
+ setCurrentItem(dataItems[0]);
12883
+ } else {
12884
+ setCurrentItem(dataItems[index + 1]);
12885
+ }
12886
+ }
12887
+ break;
12888
+
12889
+ case 13:
12890
+ //enter
12891
+ chooseItem();
12892
+ break;
12893
+
12894
+ case 27:
12895
+ //escape
12896
+ cancelItem();
12897
+ break;
12898
+ }
12899
+ });
12900
+
12901
+ input.addEventListener("blur", function (e) {
12902
+ if (blurable) {
12903
+ cancelItem();
11116
12904
  }
11117
12905
  });
11118
12906
 
12907
+ input.addEventListener("focus", function (e) {
12908
+ showList();
12909
+ });
12910
+
12911
+ //style list element
12912
+ listEl = document.createElement("div");
12913
+ listEl.classList.add("tabulator-edit-select-list");
12914
+
12915
+ onRendered(function () {
12916
+ input.style.height = "100%";
12917
+ input.focus();
12918
+ });
12919
+
11119
12920
  return input;
11120
12921
  },
11121
12922
 
11122
- //input element with type of number
11123
- number: function number(cell, onRendered, success, cancel, editorParams) {
11124
-
11125
- var cellValue = cell.getValue(),
11126
- input = document.createElement("input");
12923
+ //autocomplete
12924
+ autocomplete: function autocomplete(cell, onRendered, success, cancel, editorParams) {
12925
+ var self = this,
12926
+ cellEl = cell.getElement(),
12927
+ initialValue = cell.getValue(),
12928
+ input = document.createElement("input"),
12929
+ listEl = document.createElement("div"),
12930
+ allItems = [],
12931
+ displayItems = [],
12932
+ currentItem = {},
12933
+ blurable = true;
12934
+
12935
+ function getUniqueColumnValues() {
12936
+ var output = {},
12937
+ column = cell.getColumn()._getSelf(),
12938
+ data = self.table.getData();
11127
12939
 
11128
- input.setAttribute("type", "number");
12940
+ data.forEach(function (row) {
12941
+ var val = column.getFieldValue(row);
11129
12942
 
11130
- if (typeof editorParams.max != "undefined") {
11131
- input.setAttribute("max", editorParams.max);
11132
- }
12943
+ if (val !== null && typeof val !== "undefined" && val !== "") {
12944
+ output[val] = true;
12945
+ }
12946
+ });
11133
12947
 
11134
- if (typeof editorParams.min != "undefined") {
11135
- input.setAttribute("min", editorParams.min);
12948
+ return Object.keys(output);
11136
12949
  }
11137
12950
 
11138
- if (typeof editorParams.step != "undefined") {
11139
- input.setAttribute("step", editorParams.step);
11140
- }
12951
+ function parseItems(inputValues, curentValue) {
12952
+ var itemList = [];
11141
12953
 
11142
- //create and style input
11143
- input.style.padding = "4px";
11144
- input.style.width = "100%";
11145
- input.style.boxSizing = "border-box";
12954
+ if (Array.isArray(inputValues)) {
12955
+ inputValues.forEach(function (value) {
12956
+ var item = {
12957
+ title: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
12958
+ value: value,
12959
+ element: false
12960
+ };
11146
12961
 
11147
- input.value = cellValue;
12962
+ if (item.value === curentValue) {
12963
+ setCurrentItem(item);
12964
+ }
11148
12965
 
11149
- onRendered(function () {
11150
- input.focus();
11151
- input.style.height = "100%";
11152
- });
12966
+ itemList.push(item);
12967
+ });
12968
+ } else {
12969
+ for (var key in inputValues) {
12970
+ var item = {
12971
+ title: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
12972
+ value: key,
12973
+ element: false
12974
+ };
11153
12975
 
11154
- function onChange() {
11155
- var value = input.value;
12976
+ if (item.value === curentValue) {
12977
+ setCurrentItem(item);
12978
+ }
11156
12979
 
11157
- if (!isNaN(value) && value !== "") {
11158
- value = Number(value);
12980
+ itemList.push(item);
12981
+ }
11159
12982
  }
11160
12983
 
11161
- if (value != cellValue) {
11162
- success(value);
11163
- } else {
11164
- cancel();
11165
- }
12984
+ allItems = itemList;
11166
12985
  }
11167
12986
 
11168
- //submit new value on blur
11169
- input.addEventListener("blur", function (e) {
11170
- onChange();
11171
- });
12987
+ function filterList(term) {
12988
+ var matches = [];
11172
12989
 
11173
- //submit new value on enter
11174
- input.addEventListener("keydown", function (e) {
11175
- switch (e.keyCode) {
11176
- case 13:
11177
- case 9:
11178
- onChange();
11179
- break;
12990
+ if (editorParams.searchFunc) {
12991
+ matches = editorParams.searchFunc(term, values);
12992
+ } else {
12993
+ if (term === "") {
11180
12994
 
11181
- case 27:
11182
- cancel();
11183
- break;
11184
- }
11185
- });
12995
+ if (editorParams.showListOnEmpty) {
12996
+ allItems.forEach(function (item) {
12997
+ matches.push(item);
12998
+ });
12999
+ }
13000
+ } else {
13001
+ allItems.forEach(function (item) {
11186
13002
 
11187
- return input;
11188
- },
13003
+ if (item.value !== null || typeof item.value !== "undefined") {
13004
+ if (String(item.value).toLowerCase().indexOf(String(term).toLowerCase()) > -1) {
13005
+ matches.push(item);
13006
+ }
13007
+ }
13008
+ });
13009
+ }
13010
+ }
11189
13011
 
11190
- //input element with type of number
11191
- range: function range(cell, onRendered, success, cancel, editorParams) {
13012
+ displayItems = matches;
11192
13013
 
11193
- var cellValue = cell.getValue(),
11194
- input = document.createElement("input");
13014
+ fillList();
13015
+ }
11195
13016
 
11196
- input.setAttribute("type", "range");
13017
+ function fillList() {
13018
+ var current = false;
11197
13019
 
11198
- if (typeof editorParams.max != "undefined") {
11199
- input.setAttribute("max", editorParams.max);
11200
- }
13020
+ while (listEl.firstChild) {
13021
+ listEl.removeChild(listEl.firstChild);
13022
+ }displayItems.forEach(function (item) {
13023
+ var el = item.element;
11201
13024
 
11202
- if (typeof editorParams.min != "undefined") {
11203
- input.setAttribute("min", editorParams.min);
11204
- }
13025
+ if (!el) {
13026
+ el = document.createElement("div");
13027
+ el.classList.add("tabulator-edit-select-list-item");
13028
+ el.tabIndex = 0;
13029
+ el.innerHTML = item.title;
11205
13030
 
11206
- if (typeof editorParams.step != "undefined") {
11207
- input.setAttribute("step", editorParams.step);
11208
- }
13031
+ el.addEventListener("click", function () {
13032
+ setCurrentItem(item);
13033
+ chooseItem();
13034
+ });
11209
13035
 
11210
- //create and style input
11211
- input.style.padding = "4px";
11212
- input.style.width = "100%";
11213
- input.style.boxSizing = "border-box";
13036
+ el.addEventListener("mousedown", function () {
13037
+ blurable = false;
11214
13038
 
11215
- input.value = cellValue;
13039
+ setTimeout(function () {
13040
+ blurable = true;
13041
+ }, 10);
13042
+ });
11216
13043
 
11217
- onRendered(function () {
11218
- input.focus();
11219
- input.style.height = "100%";
11220
- });
13044
+ item.element = el;
11221
13045
 
11222
- function onChange() {
11223
- var value = input.value;
13046
+ if (item === currentItem) {
13047
+ item.element.classList.add("active");
13048
+ current = true;
13049
+ }
13050
+ }
11224
13051
 
11225
- if (!isNaN(value) && value !== "") {
11226
- value = Number(value);
11227
- }
13052
+ listEl.appendChild(el);
13053
+ });
11228
13054
 
11229
- if (value != cellValue) {
11230
- success(value);
11231
- } else {
11232
- cancel();
13055
+ if (!current) {
13056
+ setCurrentItem(false);
11233
13057
  }
11234
13058
  }
11235
13059
 
11236
- //submit new value on blur
11237
- input.addEventListener("blur", function (e) {
11238
- onChange();
11239
- });
13060
+ function setCurrentItem(item, showInputValue) {
13061
+ if (currentItem && currentItem.element) {
13062
+ currentItem.element.classList.remove("active");
13063
+ }
11240
13064
 
11241
- //submit new value on enter
11242
- input.addEventListener("keydown", function (e) {
11243
- switch (e.keyCode) {
11244
- case 13:
11245
- case 9:
11246
- onChange();
11247
- break;
13065
+ currentItem = item;
11248
13066
 
11249
- case 27:
11250
- cancel();
11251
- break;
13067
+ if (item && item.element) {
13068
+ item.element.classList.add("active");
11252
13069
  }
11253
- });
13070
+ }
11254
13071
 
11255
- return input;
11256
- },
13072
+ function chooseItem() {
13073
+ hideList();
11257
13074
 
11258
- //select
11259
- select: function select(cell, onRendered, success, cancel, editorParams) {
11260
- //create and style select
11261
- var select = document.createElement("select");
11262
- var isArray = Array.isArray(editorParams);
13075
+ if (currentItem) {
13076
+ if (initialValue !== currentItem.value) {
13077
+ initialValue = currentItem.value;
13078
+ input.value = currentItem.value;
13079
+ success(input.value);
13080
+ } else {
13081
+ cancel();
13082
+ }
13083
+ } else {
13084
+ if (editorParams.freetext) {
13085
+ initialValue = input.value;
13086
+ success(input.value);
13087
+ } else {
13088
+ if (editorParams.allowEmpty && input.value === "") {
13089
+ initialValue = input.value;
13090
+ success(input.value);
13091
+ } else {
13092
+ cancel();
13093
+ }
13094
+ }
13095
+ }
13096
+ }
11263
13097
 
11264
- if (typeof editorParams == "function") {
11265
- editorParams = editorParams(cell);
11266
- isArray = Array.isArray(editorParams);
13098
+ function cancelItem() {
13099
+ hideList();
13100
+ cancel();
11267
13101
  }
11268
13102
 
11269
- function optionAppend(element, label, value, disabled) {
13103
+ function showList() {
13104
+ if (!listEl.parentNode) {
13105
+ while (listEl.firstChild) {
13106
+ listEl.removeChild(listEl.firstChild);
13107
+ }if (editorParams.values === true) {
13108
+ parseItems(getUniqueColumnValues(), initialValue);
13109
+ } else {
13110
+ parseItems(editorParams.values || [], initialValue);
13111
+ }
11270
13112
 
11271
- var option = document.createElement("option");
13113
+ var offset = Tabulator.prototype.helpers.elOffset(cellEl);
11272
13114
 
11273
- option.value = value;
11274
- option.text = label;
13115
+ listEl.style.minWidth = cellEl.offsetWidth + "px";
11275
13116
 
11276
- if (disabled) {
11277
- option.disabled = true;
13117
+ listEl.style.top = offset.top + cellEl.offsetHeight + "px";
13118
+ listEl.style.left = offset.left + "px";
13119
+ document.body.appendChild(listEl);
11278
13120
  }
13121
+ }
11279
13122
 
11280
- element.appendChild(option);
13123
+ function hideList() {
13124
+ if (listEl.parentNode) {
13125
+ listEl.parentNode.removeChild(listEl);
13126
+ }
11281
13127
  }
11282
13128
 
11283
- function processOption(element, option) {
11284
- var groupEl;
13129
+ //style input
13130
+ input.setAttribute("type", "text");
13131
+
13132
+ input.style.padding = "4px";
13133
+ input.style.width = "100%";
13134
+ input.style.boxSizing = "border-box";
11285
13135
 
11286
- if (option.options) {
11287
- groupEl = document.createElement("optgroup");
13136
+ //allow key based navigation
13137
+ input.addEventListener("keydown", function (e) {
13138
+ var index;
11288
13139
 
11289
- groupEl.setAttribute("lavel", option.label);
13140
+ switch (e.keyCode) {
13141
+ case 38:
13142
+ //up arrow
13143
+ e.stopImmediatePropagation();
13144
+ e.stopPropagation();
11290
13145
 
11291
- option.options.forEach(function (item) {
11292
- processOption(groupEl, item);
11293
- });
13146
+ index = displayItems.indexOf(currentItem);
11294
13147
 
11295
- element.appendChild(groupEl);
11296
- } else {
11297
- optionAppend(element, typeof option.label == "undefined" ? option.value : option.label, typeof option.value == "undefined" ? option.label : option.value, option.disabled);
11298
- }
11299
- }
13148
+ if (index > 0) {
13149
+ setCurrentItem(displayItems[index - 1]);
13150
+ } else {
13151
+ setCurrentItem(false);
13152
+ }
13153
+ break;
13154
+
13155
+ case 40:
13156
+ //down arrow
13157
+ e.stopImmediatePropagation();
13158
+ e.stopPropagation();
11300
13159
 
11301
- if (!isArray && (typeof editorParams === 'undefined' ? 'undefined' : _typeof(editorParams)) === "object") {
11302
- for (var key in editorParams) {
11303
- optionAppend(select, editorParams[key], key);
13160
+ index = displayItems.indexOf(currentItem);
13161
+
13162
+ if (index < displayItems.length - 1) {
13163
+ if (index == -1) {
13164
+ setCurrentItem(displayItems[0]);
13165
+ } else {
13166
+ setCurrentItem(displayItems[index + 1]);
13167
+ }
13168
+ }
13169
+ break;
13170
+
13171
+ case 13:
13172
+ //enter
13173
+ chooseItem();
13174
+ break;
13175
+
13176
+ case 27:
13177
+ //escape
13178
+ cancelItem();
13179
+ break;
11304
13180
  }
11305
- } else if (isArray) {
11306
- editorParams.forEach(function (item) {
11307
- processOption(select, item);
11308
- });
11309
- }
13181
+ });
11310
13182
 
11311
- //create and style input
11312
- select.style.padding = "4px";
11313
- select.style.width = "100%";
11314
- select.style.boxSizing = "border-box";
11315
- select.style.fontFamily = "";
13183
+ input.addEventListener("keyup", function (e) {
11316
13184
 
11317
- select.value = cell.getValue();
13185
+ switch (e.keyCode) {
13186
+ case 38: //up arrow
13187
+ case 37: //left arrow
13188
+ case 39: //up arrow
13189
+ case 40: //right arrow
13190
+ case 13: //enter
13191
+ case 27:
13192
+ //escape
13193
+ break;
11318
13194
 
11319
- onRendered(function () {
11320
- select.focus();
13195
+ default:
13196
+ filterList(input.value);
13197
+ }
11321
13198
  });
11322
13199
 
11323
- //submit new value on blur
11324
- function onChange(e) {
11325
- if (select.selectedIndex > -1) {
11326
- success(select.options[select.selectedIndex].value);
11327
- } else {
11328
- cancel();
13200
+ input.addEventListener("blur", function (e) {
13201
+ if (blurable) {
13202
+ chooseItem();
11329
13203
  }
11330
- }
13204
+ });
13205
+
13206
+ input.addEventListener("focus", function (e) {
13207
+ showList();
13208
+ input.value = initialValue;
13209
+ filterList(initialValue);
13210
+ });
11331
13211
 
11332
- select.addEventListener("change", onChange);
11333
- select.addEventListener("blur", onChange);
13212
+ //style list element
13213
+ listEl = document.createElement("div");
13214
+ listEl.classList.add("tabulator-edit-select-list");
11334
13215
 
11335
- //submit new value on enter
11336
- select.addEventListener("keydown", function (e) {
11337
- if (e.keyCode === 13) {
11338
- success(select.options[select.selectedIndex].value);
11339
- }
13216
+ onRendered(function () {
13217
+ input.style.height = "100%";
13218
+ input.focus();
11340
13219
  });
11341
- return select;
13220
+
13221
+ return input;
11342
13222
  },
11343
13223
 
11344
13224
  //start rating
@@ -11586,7 +13466,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11586
13466
  //checkbox
11587
13467
  tickCross: function tickCross(cell, onRendered, success, cancel, editorParams) {
11588
13468
  var value = cell.getValue(),
11589
- input = document.createElement("input");
13469
+ input = document.createElement("input"),
13470
+ tristate = editorParams.tristate,
13471
+ indetermValue = typeof editorParams.indeterminateValue === "undefined" ? null : editorParams.indeterminateValue,
13472
+ indetermState = false;
11590
13473
 
11591
13474
  input.setAttribute("type", "checkbox");
11592
13475
  input.style.marginTop = "5px";
@@ -11594,6 +13477,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11594
13477
 
11595
13478
  input.value = value;
11596
13479
 
13480
+ if (tristate && (typeof value === "undefined" || value === indetermValue || value === "")) {
13481
+ indetermState = true;
13482
+ input.indeterminate = true;
13483
+ }
13484
+
11597
13485
  if (this.table.browser != "firefox") {
11598
13486
  //prevent blur issue on mac firefox
11599
13487
  onRendered(function () {
@@ -11603,61 +13491,35 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11603
13491
 
11604
13492
  input.checked = value === true || value === "true" || value === "True" || value === 1;
11605
13493
 
11606
- //submit new value on blur
11607
- input.addEventListener("change", function (e) {
11608
- success(input.checked);
11609
- });
11610
-
11611
- input.addEventListener("blur", function (e) {
11612
- success(input.checked);
11613
- });
11614
-
11615
- //submit new value on enter
11616
- input.addEventListener("keydown", function (e) {
11617
- if (e.keyCode == 13) {
11618
- success(input.checked);
11619
- }
11620
- if (e.keyCode == 27) {
11621
- cancel();
11622
- }
11623
- });
11624
-
11625
- return input;
11626
- },
11627
-
11628
- //checkbox
11629
- tick: function tick(cell, onRendered, success, cancel, editorParams) {
11630
- var value = cell.getValue(),
11631
- input = document.createElement("input");
11632
-
11633
- input.setAttribute("type", "checkbox");
11634
- input.style.marginTop = "5px";
11635
- input.style.boxSizing = "border-box";
11636
-
11637
- input.value = value;
11638
-
11639
- if (this.table.browser != "firefox") {
11640
- //prevent blur issue on mac firefox
11641
- onRendered(function () {
11642
- input.focus();
11643
- });
13494
+ function setValue() {
13495
+ if (tristate) {
13496
+ if (input.checked && !indetermState) {
13497
+ input.checked = false;
13498
+ input.indeterminate = true;
13499
+ indetermState = true;
13500
+ return indetermValue;
13501
+ } else {
13502
+ indetermState = false;
13503
+ return input.checked;
13504
+ }
13505
+ } else {
13506
+ return input.checked;
13507
+ }
11644
13508
  }
11645
13509
 
11646
- input.checked = value === true || value === "true" || value === "True" || value === 1;
11647
-
11648
13510
  //submit new value on blur
11649
13511
  input.addEventListener("change", function (e) {
11650
- success(input.checked);
13512
+ success(setValue());
11651
13513
  });
11652
13514
 
11653
13515
  input.addEventListener("blur", function (e) {
11654
- success(input.checked);
13516
+ success(setValue());
11655
13517
  });
11656
13518
 
11657
13519
  //submit new value on enter
11658
13520
  input.addEventListener("keydown", function (e) {
11659
13521
  if (e.keyCode == 13) {
11660
- success(input.checked);
13522
+ success(setValue());
11661
13523
  }
11662
13524
  if (e.keyCode == 27) {
11663
13525
  cancel();
@@ -11676,6 +13538,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11676
13538
  this.filterList = []; //hold filter list
11677
13539
  this.headerFilters = {}; //hold column filters
11678
13540
  this.headerFilterElements = []; //hold header filter elements for manipulation
13541
+ this.headerFilterColumns = []; //hold columns that use header filters
11679
13542
 
11680
13543
  this.changed = false; //has filtering changed since last render
11681
13544
  };
@@ -11855,7 +13718,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11855
13718
 
11856
13719
  params = typeof params === "function" ? params.call(self.table) : params;
11857
13720
 
11858
- editorElement = editor.call(self, cellWrapper, function () {}, success, cancel, params);
13721
+ editorElement = editor.call(this.table.modules.edit, cellWrapper, function () {}, success, cancel, params);
13722
+
13723
+ if (!editorElement) {
13724
+ console.warn("Filter Error - Cannot add filter to " + field + " column, editor returned a value of false");
13725
+ return;
13726
+ }
13727
+
13728
+ if (!(editorElement instanceof Node)) {
13729
+ console.warn("Filter Error - Cannot add filter to " + field + " column, editor should return an instance of Node, the editor returned:", editorElement);
13730
+ return;
13731
+ }
11859
13732
 
11860
13733
  //set Placeholder Text
11861
13734
  if (field) {
@@ -11887,32 +13760,36 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11887
13760
  }, 300);
11888
13761
  };
11889
13762
 
11890
- editorElement.addEventListener("keyup", searchTrigger);
11891
- editorElement.addEventListener("search", searchTrigger);
11892
-
11893
13763
  column.modules.filter.headerElement = editorElement;
13764
+ column.modules.filter.attrType = editorElement.hasAttribute("type") ? editorElement.getAttribute("type").toLowerCase() : "";
13765
+ column.modules.filter.tagType = editorElement.tagName.toLowerCase();
11894
13766
 
11895
- //update number filtered columns on change
13767
+ if (column.definition.headerFilterLiveFilter !== false) {
11896
13768
 
11897
- column.modules.filter.attrType = editorElement.hasAttribute("type") ? editorElement.getAttribute("type").toLowerCase() : "";
11898
- if (column.modules.filter.attrType == "number") {
11899
- editorElement.addEventListener("change", function (e) {
11900
- success(editorElement.value);
11901
- });
11902
- }
13769
+ if (!(column.definition.headerFilter === "autocomplete" || column.definition.editor === "autocomplete" && column.definition.headerFilter === true)) {
13770
+ editorElement.addEventListener("keyup", searchTrigger);
13771
+ editorElement.addEventListener("search", searchTrigger);
11903
13772
 
11904
- //change text inputs to search inputs to allow for clearing of field
11905
- if (column.modules.filter.attrType == "text" && this.table.browser !== "ie") {
11906
- editorElement.setAttribute("type", "search");
11907
- // editorElement.off("change blur"); //prevent blur from triggering filter and preventing selection click
11908
- }
13773
+ //update number filtered columns on change
13774
+ if (column.modules.filter.attrType == "number") {
13775
+ editorElement.addEventListener("change", function (e) {
13776
+ success(editorElement.value);
13777
+ });
13778
+ }
11909
13779
 
11910
- //prevent input and select elements from propegating click to column sorters etc
11911
- column.modules.filter.tagType = editorElement.tagName.toLowerCase();
11912
- if (column.modules.filter.tagType == "input" || column.modules.filter.tagType == "select" || column.modules.filter.tagType == "textarea") {
11913
- editorElement.addEventListener("mousedown", function (e) {
11914
- e.stopPropagation();
11915
- });
13780
+ //change text inputs to search inputs to allow for clearing of field
13781
+ if (column.modules.filter.attrType == "text" && this.table.browser !== "ie") {
13782
+ editorElement.setAttribute("type", "search");
13783
+ // editorElement.off("change blur"); //prevent blur from triggering filter and preventing selection click
13784
+ }
13785
+ }
13786
+
13787
+ //prevent input and select elements from propegating click to column sorters etc
13788
+ if (column.modules.filter.tagType == "input" || column.modules.filter.tagType == "select" || column.modules.filter.tagType == "textarea") {
13789
+ editorElement.addEventListener("mousedown", function (e) {
13790
+ e.stopPropagation();
13791
+ });
13792
+ }
11916
13793
  }
11917
13794
 
11918
13795
  filterElement.appendChild(editorElement);
@@ -11920,6 +13797,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
11920
13797
  column.contentElement.appendChild(filterElement);
11921
13798
 
11922
13799
  self.headerFilterElements.push(editorElement);
13800
+ self.headerFilterColumns.push(column);
11923
13801
  }
11924
13802
  } else {
11925
13803
  console.warn("Filter Error - Cannot add header filter, column has no field set:", column.definition.title);
@@ -12156,17 +14034,55 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
12156
14034
 
12157
14035
  //clear header filters
12158
14036
  Filter.prototype.clearHeaderFilter = function () {
14037
+ var self = this;
14038
+
12159
14039
  this.headerFilters = {};
12160
14040
 
12161
- this.headerFilterElements.forEach(function (element) {
12162
- element.value = "";
14041
+ this.headerFilterColumns.forEach(function (column) {
14042
+ column.modules.filter.value = null;
14043
+ self.reloadHeaderFilter(column);
12163
14044
  });
12164
14045
 
12165
14046
  this.changed = true;
12166
14047
  };
12167
14048
 
14049
+ //search data and return matching rows
14050
+ Filter.prototype.search = function (searchType, field, type, value) {
14051
+ var self = this,
14052
+ activeRows = [],
14053
+ filterList = [];
14054
+
14055
+ if (!Array.isArray(field)) {
14056
+ field = [{ field: field, type: type, value: value }];
14057
+ }
14058
+
14059
+ field.forEach(function (filter) {
14060
+ filter = self.findFilter(filter);
14061
+
14062
+ if (filter) {
14063
+ filterList.push(filter);
14064
+ }
14065
+ });
14066
+
14067
+ this.table.rowManager.rows.forEach(function (row) {
14068
+ var match = true;
14069
+
14070
+ filterList.forEach(function (filter) {
14071
+ if (!self.filterRecurse(filter, row.getData())) {
14072
+ match = false;
14073
+ }
14074
+ });
14075
+
14076
+ if (match) {
14077
+ activeRows.push(searchType === "data" ? row.getData("data") : row.getComponent());
14078
+ }
14079
+ });
14080
+
14081
+ return activeRows;
14082
+ };
14083
+
12168
14084
  //filter row array
12169
- Filter.prototype.filter = function (rowList) {
14085
+ Filter.prototype.filter = function (rowList, filters) {
12170
14086
  var self = this,
12171
14087
  activeRows = [],
12172
14088
  activeRowComponents = [];
@@ -12199,7 +14115,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
12199
14115
  };
12200
14116
 
12201
14117
  //filter individual row
12202
- Filter.prototype.filterRow = function (row) {
14118
+ Filter.prototype.filterRow = function (row, filters) {
12203
14119
  var self = this,
12204
14120
  match = true,
12205
14121
  data = row.getData();
@@ -12315,6 +14231,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
12315
14231
  //set column formatter
12316
14232
  switch (_typeof(column.definition.formatter)) {
12317
14233
  case "string":
14234
+
14235
+ if (column.definition.formatter === "tick") {
14236
+ column.definition.formatter = "tickCross";
14237
+
14238
+ if (typeof column.definition.formatterParams.crossElement == "undefined") {
14239
+ column.definition.formatterParams.crossElement = false;
14240
+ }
14241
+
14242
+ console.warn("DEPRICATION WANRING - the tick formatter has been depricated, please use the tickCross formatter with the crossElement param set to false");
14243
+ }
14244
+
12318
14245
  if (self.formatters[column.definition.formatter]) {
12319
14246
  config.formatter = self.formatters[column.definition.formatter];
12320
14247
  } else {
@@ -12510,9 +14437,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
12510
14437
 
12511
14438
  //image element
12512
14439
  image: function image(cell, formatterParams, onRendered) {
12513
- var value = this.sanitizeHTML(cell.getValue()),
12514
- el = document.createElement("img");
12515
- el.setAttribute("src", value);
14440
+ var el = document.createElement("img");
14441
+ el.setAttribute("src", cell.getValue());
12516
14442
 
12517
14443
  switch (_typeof(formatterParams.height)) {
12518
14444
  case "number":
@@ -12541,41 +14467,25 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
12541
14467
  return el;
12542
14468
  },
12543
14469
 
12544
- //tick or empty cell
12545
- tick: function tick(cell, formatterParams, onRendered) {
12546
- var value = cell.getValue(),
12547
- element = cell.getElement();
12548
-
12549
- var tick = '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>';
12550
-
12551
- if (value === true || value === "true" || value === "True" || value === 1 || value === "1") {
12552
- element.setAttribute("aria-checked", true);
12553
- return tick;
12554
- } else {
12555
- element.setAttribute("aria-checked", false);
12556
- return "";
12557
- }
12558
- },
12559
-
12560
14470
  //tick or cross
12561
14471
  tickCross: function tickCross(cell, formatterParams, onRendered) {
12562
14472
  var value = cell.getValue(),
12563
14473
  element = cell.getElement(),
12564
14474
  empty = formatterParams.allowEmpty,
12565
14475
  truthy = formatterParams.allowTruthy,
12566
- tick = '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>',
12567
- cross = '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';
14476
+ tick = typeof formatterParams.tickElement !== "undefined" ? formatterParams.tickElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>',
14477
+ cross = typeof formatterParams.crossElement !== "undefined" ? formatterParams.crossElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';
12568
14478
 
12569
14479
  if (truthy && value || value === true || value === "true" || value === "True" || value === 1 || value === "1") {
12570
14480
  element.setAttribute("aria-checked", true);
12571
- return tick;
14481
+ return tick || "";
12572
14482
  } else {
12573
14483
  if (empty && (value === "null" || value === "" || value === null || typeof value === "undefined")) {
12574
14484
  element.setAttribute("aria-checked", "mixed");
12575
14485
  return "";
12576
14486
  } else {
12577
14487
  element.setAttribute("aria-checked", false);
12578
- return cross;
14488
+ return cross || "";
12579
14489
  }
12580
14490
  }
12581
14491
  },
@@ -13112,23 +15022,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13112
15022
  };
13113
15023
 
13114
15024
  GroupComponent.prototype.getRows = function () {
13115
- var output = [];
13116
-
13117
- this._group.rows.forEach(function (row) {
13118
- output.push(row.getComponent());
13119
- });
13120
-
13121
- return output;
15025
+ return this._group.getRows(true);
13122
15026
  };
13123
15027
 
13124
15028
  GroupComponent.prototype.getSubGroups = function () {
13125
- var output = [];
13126
-
13127
- this._group.groupList.forEach(function (child) {
13128
- output.push(child.getComponent());
13129
- });
13130
-
13131
- return output;
15029
+ return this._group.getSubGroups(true);
13132
15030
  };
13133
15031
 
13134
15032
  GroupComponent.prototype.getParentGroup = function () {
@@ -13190,6 +15088,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13190
15088
 
13191
15089
  this.createElements();
13192
15090
  this.addBindings();
15091
+
15092
+ this.createValueGroups();
13193
15093
  };
13194
15094
 
13195
15095
  Group.prototype.createElements = function () {
@@ -13203,6 +15103,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13203
15103
  this.arrowElement.classList.add("tabulator-arrow");
13204
15104
  };
13205
15105
 
15106
+ Group.prototype.createValueGroups = function () {
15107
+ var _this31 = this;
15108
+
15109
+ var level = this.level + 1;
15110
+ if (this.groupManager.allowedValues && this.groupManager.allowedValues[level]) {
15111
+ this.groupManager.allowedValues[level].forEach(function (value) {
15112
+ _this31._createGroup(value, level);
15113
+ });
15114
+ }
15115
+ };
15116
+
13206
15117
  Group.prototype.addBindings = function () {
13207
15118
  var self = this,
13208
15119
  dblTap,
@@ -13299,21 +15210,33 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13299
15210
  }
13300
15211
  };
13301
15212
 
15213
+ Group.prototype._createGroup = function (groupID, level) {
15214
+ var groupKey = level + "_" + groupID;
15215
+ var group = new Group(this.groupManager, this, level, groupID, this.groupManager.groupIDLookups[level].field, this.groupManager.headerGenerator[level] || this.groupManager.headerGenerator[0], this.old ? this.old.groups[groupKey] : false);
15216
+
15217
+ this.groups[groupKey] = group;
15218
+ this.groupList.push(group);
15219
+ };
15220
+
13302
15221
  Group.prototype._addRowToGroup = function (row) {
13303
15222
 
13304
15223
  var level = this.level + 1;
13305
15224
 
13306
15225
  if (this.hasSubGroups) {
13307
- var groupID = this.groupManager.groupIDLookups[level].func(row.getData());
15226
+ var groupID = this.groupManager.groupIDLookups[level].func(row.getData()),
15227
+ groupKey = level + "_" + groupID;
13308
15228
 
13309
- if (!this.groups[groupID]) {
13310
- var group = new Group(this.groupManager, this, level, groupID, this.groupManager.groupIDLookups[level].field, this.groupManager.headerGenerator[level] || this.groupManager.headerGenerator[0], this.old ? this.old.groups[groupID] : false);
15229
+ if (this.groupManager.allowedValues && this.groupManager.allowedValues[level]) {
15230
+ if (this.groups[groupKey]) {
15231
+ this.groups[groupKey].addRow(row);
15232
+ }
15233
+ } else {
15234
+ if (!this.groups[groupKey]) {
15235
+ this._createGroup(groupID, level);
15236
+ }
13311
15237
 
13312
- this.groups[groupID] = group;
13313
- this.groupList.push(group);
15238
+ this.groups[groupKey].addRow(row);
13314
15239
  }
13315
-
13316
- this.groups[groupID].addRow(row);
13317
15240
  }
13318
15241
  };
13319
15242
 
@@ -13393,10 +15316,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13393
15316
  };
13394
15317
 
13395
15318
  Group.prototype.removeGroup = function (group) {
13396
- var index;
15319
+ var groupKey = group.level + "_" + group.key,
15320
+ index;
13397
15321
 
13398
- if (this.groups[group.key]) {
13399
- delete this.groups[group.key];
15322
+ if (this.groups[groupKey]) {
15323
+ delete this.groups[groupKey];
13400
15324
 
13401
15325
  index = this.groupList.indexOf(group);
13402
15326
 
@@ -13459,12 +15383,27 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13459
15383
  return output;
13460
15384
  };
13461
15385
 
13462
- Group.prototype.getRows = function () {
15386
+ Group.prototype.getData = function (visible, transform) {
15387
+ var self = this,
15388
+ output = [];
15389
+
13463
15390
  this._visSet();
13464
15391
 
13465
- return this.visible ? this.rows : [];
15392
+ if (!visible || visible && this.visible) {
15393
+ this.rows.forEach(function (row) {
15394
+ output.push(row.getData(transform || "data"));
15395
+ });
15396
+ }
15397
+
15398
+ return output;
13466
15399
  };
13467
15400
 
15401
+ // Group.prototype.getRows = function(){
15402
+ // this._visSet();
15403
+
15404
+ // return this.visible ? this.rows : [];
15405
+ // };
15406
+
13468
15407
  Group.prototype.getRowCount = function () {
13469
15408
  var count = 0;
13470
15409
 
@@ -13603,6 +15542,26 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13603
15542
  return match;
13604
15543
  };
13605
15544
 
15545
+ Group.prototype.getSubGroups = function (component) {
15546
+ var output = [];
15547
+
15548
+ this.groupList.forEach(function (child) {
15549
+ output.push(component ? child.getComponent() : child);
15550
+ });
15551
+
15552
+ return output;
15553
+ };
15554
+
15555
+ Group.prototype.getRows = function (compoment) {
15556
+ var output = [];
15557
+
15558
+ this.rows.forEach(function (row) {
15559
+ output.push(compoment ? row.getComponent() : row);
15560
+ });
15561
+
15562
+ return output;
15563
+ };
15564
+
13606
15565
  Group.prototype.generateGroupHeaderContents = function () {
13607
15566
  var data = [];
13608
15567
 
@@ -13710,6 +15669,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13710
15669
  return "";
13711
15670
  }];
13712
15671
  this.groupList = []; //ordered list of groups
15672
+ this.allowedValues = false;
13713
15673
  this.groups = {}; //hold row groups
13714
15674
  this.displayIndex = 0; //index in display pipeline
13715
15675
  };
@@ -13721,6 +15681,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13721
15681
  startOpen = self.table.options.groupStartOpen,
13722
15682
  groupHeader = self.table.options.groupHeader;
13723
15683
 
15684
+ this.allowedValues = self.table.options.groupValues;
15685
+
13724
15686
  self.headerGenerator = [function () {
13725
15687
  return "";
13726
15688
  }];
@@ -13762,7 +15724,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13762
15724
  groupBy = [groupBy];
13763
15725
  }
13764
15726
 
13765
- groupBy.forEach(function (group) {
15727
+ groupBy.forEach(function (group, i) {
13766
15728
  var lookupFunc, column;
13767
15729
 
13768
15730
  if (typeof group == "function") {
@@ -13783,7 +15745,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13783
15745
 
13784
15746
  self.groupIDLookups.push({
13785
15747
  field: typeof group === "function" ? false : group,
13786
- func: lookupFunc
15748
+ func: lookupFunc,
15749
+ values: self.allowedValues ? self.allowedValues[i] : false
13787
15750
  });
13788
15751
  });
13789
15752
 
@@ -13826,7 +15789,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13826
15789
  this.generateGroups(rows);
13827
15790
 
13828
15791
  if (this.table.options.dataGrouped) {
13829
- this.table.options.dataGrouped.call(this.table, this.getGroups());
15792
+ this.table.options.dataGrouped.call(this.table, this.getGroups(true));
13830
15793
  }
13831
15794
 
13832
15795
  return this.updateGroupRows();
@@ -13835,16 +15798,57 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13835
15798
  }
13836
15799
  };
13837
15800
 
13838
- GroupRows.prototype.getGroups = function () {
15801
+ GroupRows.prototype.getGroups = function (compoment) {
13839
15802
  var groupComponents = [];
13840
15803
 
13841
15804
  this.groupList.forEach(function (group) {
13842
- groupComponents.push(group.getComponent());
15805
+ groupComponents.push(compoment ? group.getComponent() : group);
13843
15806
  });
13844
15807
 
13845
15808
  return groupComponents;
13846
15809
  };
13847
15810
 
15811
+ GroupRows.prototype.pullGroupListData = function (groupList) {
15812
+ var self = this;
15813
+ var groupListData = [];
15814
+
15815
+ groupList.forEach(function (group) {
15816
+ var groupHeader = {};
15817
+ groupHeader.level = 0;
15818
+ groupHeader.rowCount = 0;
15819
+ groupHeader.headerContent = "";
15820
+ var childData = [];
15821
+
15822
+ if (group.hasSubGroups) {
15823
+ childData = self.pullGroupListData(group.groupList);
15824
+
15825
+ groupHeader.level = group.level;
15826
+ groupHeader.rowCount = childData.length - group.groupList.length; // data length minus number of sub-headers
15827
+ groupHeader.headerContent = group.generator(group.key, groupHeader.rowCount, group.rows, group);
15828
+
15829
+ groupListData.push(groupHeader);
15830
+ groupListData = groupListData.concat(childData);
15831
+ } else {
15832
+ groupHeader.level = group.level;
15833
+ groupHeader.headerContent = group.generator(group.key, group.rows.length, group.rows, group);
15834
+ groupHeader.rowCount = group.getRows().length;
15835
+
15836
+ groupListData.push(groupHeader);
15837
+
15838
+ group.getRows().forEach(function (row) {
15839
+ groupListData.push(row.getData("data"));
15840
+ });
15841
+ }
15842
+ });
15843
+
15844
+ return groupListData;
15845
+ };
15846
+
15847
+ GroupRows.prototype.getGroupedData = function () {
15848
+
15849
+ return this.pullGroupListData(this.groupList);
15850
+ };
15851
+
13848
15852
  GroupRows.prototype.getRowGroup = function (row) {
13849
15853
  var match = false;
13850
15854
 
@@ -13870,25 +15874,62 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13870
15874
  self.groups = {};
13871
15875
  self.groupList = [];
13872
15876
 
13873
- rows.forEach(function (row) {
13874
- self.assignRowToGroup(row, oldGroups);
13875
- });
15877
+ if (this.allowedValues && this.allowedValues[0]) {
15878
+ this.allowedValues[0].forEach(function (value) {
15879
+ self.createGroup(value, 0, oldGroups);
15880
+ });
15881
+
15882
+ rows.forEach(function (row) {
15883
+ self.assignRowToExistingGroup(row, oldGroups);
15884
+ });
15885
+ } else {
15886
+ rows.forEach(function (row) {
15887
+ self.assignRowToGroup(row, oldGroups);
15888
+ });
15889
+ }
15890
+ };
15891
+
15892
+ GroupRows.prototype.createGroup = function (groupID, level, oldGroups) {
15893
+ var groupKey = level + "_" + groupID,
15894
+ group;
15895
+
15896
+ oldGroups = oldGroups || [];
15897
+
15898
+ group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]);
15899
+
15900
+ this.groups[groupKey] = group;
15901
+ this.groupList.push(group);
13876
15902
  };
13877
15903
 
13878
15904
  GroupRows.prototype.assignRowToGroup = function (row, oldGroups) {
13879
15905
  var groupID = this.groupIDLookups[0].func(row.getData()),
13880
- newGroupNeeded = !this.groups[groupID];
15906
+ groupKey = "0_" + groupID;
13881
15907
 
13882
- oldGroups = oldGroups || [];
15908
+ if (!this.groups[groupKey]) {
15909
+ this.createGroup(groupID, 0, oldGroups);
15910
+ }
13883
15911
 
13884
- if (newGroupNeeded) {
13885
- var group = new Group(this, false, 0, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupID]);
15912
+ this.groups[groupKey].addRow(row);
15913
+ };
15914
+
15915
+ GroupRows.prototype.assignRowToExistingGroup = function (row, oldGroups) {
15916
+ var groupID = this.groupIDLookups[0].func(row.getData()),
15917
+ groupKey = "0_" + groupID;
13886
15918
 
13887
- this.groups[groupID] = group;
13888
- this.groupList.push(group);
15919
+ if (this.groups[groupKey]) {
15920
+ this.groups[groupKey].addRow(row);
13889
15921
  }
15922
+ };
15923
+
15924
+ GroupRows.prototype.assignRowToGroup = function (row, oldGroups) {
15925
+ var groupID = this.groupIDLookups[0].func(row.getData()),
15926
+ newGroupNeeded = !this.groups["0_" + groupID];
13890
15927
 
13891
- this.groups[groupID].addRow(row);
15928
+ if (newGroupNeeded) {
15929
+ this.createGroup(groupID, 0, oldGroups);
15930
+ }
15931
+
15932
+ this.groups["0_" + groupID].addRow(row);
13892
15933
 
13893
15934
  return !newGroupNeeded;
13894
15935
  };
@@ -13924,10 +15965,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
13924
15965
  };
13925
15966
 
13926
15967
  GroupRows.prototype.removeGroup = function (group) {
13927
- var index;
15968
+ var groupKey = group.level + "_" + group.key,
15969
+ index;
13928
15970
 
13929
- if (this.groups[group.key]) {
13930
- delete this.groups[group.key];
15971
+ if (this.groups[groupKey]) {
15972
+ delete this.groups[groupKey];
13931
15973
 
13932
15974
  index = this.groupList.indexOf(group);
13933
15975
 
@@ -14298,13 +16340,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
14298
16340
  };
14299
16341
 
14300
16342
  Keybindings.prototype.mapBindings = function (bindings) {
14301
- var _this18 = this;
16343
+ var _this32 = this;
14302
16344
 
14303
16345
  var self = this;
14304
16346
 
14305
16347
  var _loop2 = function _loop2(key) {
14306
16348
 
14307
- if (_this18.actions[key]) {
16349
+ if (_this32.actions[key]) {
14308
16350
 
14309
16351
  if (bindings[key]) {
14310
16352
 
@@ -15542,18 +17584,18 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15542
17584
 
15543
17585
  //set current page number
15544
17586
  Page.prototype.setPage = function (page) {
15545
- var _this19 = this;
17587
+ var _this33 = this;
15546
17588
 
15547
17589
  return new Promise(function (resolve, reject) {
15548
- if (page > 0 && page <= _this19.max) {
15549
- _this19.page = page;
15550
- _this19.trigger().then(function () {
17590
+ if (page > 0 && page <= _this33.max) {
17591
+ _this33.page = page;
17592
+ _this33.trigger().then(function () {
15551
17593
  resolve();
15552
17594
  }).catch(function () {
15553
17595
  reject();
15554
17596
  });
15555
17597
  } else {
15556
- console.warn("Pagination Error - Requested page is out of range of 1 - " + _this19.max + ":", page);
17598
+ console.warn("Pagination Error - Requested page is out of range of 1 - " + _this33.max + ":", page);
15557
17599
  reject();
15558
17600
  }
15559
17601
  });
@@ -15626,12 +17668,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15626
17668
 
15627
17669
  //previous page
15628
17670
  Page.prototype.previousPage = function () {
15629
- var _this20 = this;
17671
+ var _this34 = this;
15630
17672
 
15631
17673
  return new Promise(function (resolve, reject) {
15632
- if (_this20.page > 1) {
15633
- _this20.page--;
15634
- _this20.trigger().then(function () {
17674
+ if (_this34.page > 1) {
17675
+ _this34.page--;
17676
+ _this34.trigger().then(function () {
15635
17677
  resolve();
15636
17678
  }).catch(function () {
15637
17679
  reject();
@@ -15645,19 +17687,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15645
17687
 
15646
17688
  //next page
15647
17689
  Page.prototype.nextPage = function () {
15648
- var _this21 = this;
17690
+ var _this35 = this;
15649
17691
 
15650
17692
  return new Promise(function (resolve, reject) {
15651
- if (_this21.page < _this21.max) {
15652
- _this21.page++;
15653
- _this21.trigger().then(function () {
17693
+ if (_this35.page < _this35.max) {
17694
+ _this35.page++;
17695
+ _this35.trigger().then(function () {
15654
17696
  resolve();
15655
17697
  }).catch(function () {
15656
17698
  reject();
15657
17699
  });
15658
17700
  } else {
15659
- if (!_this21.progressiveLoad) {
15660
- console.warn("Pagination Error - Next page would be greater than maximum page of " + _this21.max + ":", _this21.max + 1);
17701
+ if (!_this35.progressiveLoad) {
17702
+ console.warn("Pagination Error - Next page would be greater than maximum page of " + _this35.max + ":", _this35.max + 1);
15661
17703
  }
15662
17704
  reject();
15663
17705
  }
@@ -15709,28 +17751,28 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15709
17751
  };
15710
17752
 
15711
17753
  Page.prototype.trigger = function () {
15712
- var _this22 = this;
17754
+ var _this36 = this;
15713
17755
 
15714
17756
  var left;
15715
17757
 
15716
17758
  return new Promise(function (resolve, reject) {
15717
17759
 
15718
- switch (_this22.mode) {
17760
+ switch (_this36.mode) {
15719
17761
  case "local":
15720
- left = _this22.table.rowManager.scrollLeft;
17762
+ left = _this36.table.rowManager.scrollLeft;
15721
17763
 
15722
- _this22.table.rowManager.refreshActiveData("page");
15723
- _this22.table.rowManager.scrollHorizontal(left);
17764
+ _this36.table.rowManager.refreshActiveData("page");
17765
+ _this36.table.rowManager.scrollHorizontal(left);
15724
17766
 
15725
- _this22.table.options.pageLoaded.call(_this22.table, _this22.getPage());
17767
+ _this36.table.options.pageLoaded.call(_this36.table, _this36.getPage());
15726
17768
  resolve();
15727
17769
  break;
15728
17770
 
15729
17771
  case "remote":
15730
17772
  case "progressive_load":
15731
17773
  case "progressive_scroll":
15732
- _this22.table.modules.ajax.blockActiveRequest();
15733
- _this22._getRemotePage().then(function () {
17774
+ _this36.table.modules.ajax.blockActiveRequest();
17775
+ _this36._getRemotePage().then(function () {
15734
17776
  resolve();
15735
17777
  }).catch(function () {
15736
17778
  reject();
@@ -15738,14 +17780,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15738
17780
  break;
15739
17781
 
15740
17782
  default:
15741
- console.warn("Pagination Error - no such pagination mode:", _this22.mode);
17783
+ console.warn("Pagination Error - no such pagination mode:", _this36.mode);
15742
17784
  reject();
15743
17785
  }
15744
17786
  });
15745
17787
  };
15746
17788
 
15747
17789
  Page.prototype._getRemotePage = function () {
15748
- var _this23 = this;
17790
+ var _this37 = this;
15749
17791
 
15750
17792
  var self = this,
15751
17793
  oldParams,
@@ -15762,33 +17804,33 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
15762
17804
  pageParams = self.table.modules.ajax.getParams();
15763
17805
 
15764
17806
  //configure request params
15765
- pageParams[_this23.paginationDataSentNames.page] = self.page;
17807
+ pageParams[_this37.paginationDataSentNames.page] = self.page;
15766
17808
 
15767
17809
  //set page size if defined
15768
- if (_this23.size) {
15769
- pageParams[_this23.paginationDataSentNames.size] = _this23.size;
17810
+ if (_this37.size) {
17811
+ pageParams[_this37.paginationDataSentNames.size] = _this37.size;
15770
17812
  }
15771
17813
 
15772
17814
  //set sort data if defined
15773
- if (_this23.table.options.ajaxSorting && _this23.table.modExists("sort")) {
17815
+ if (_this37.table.options.ajaxSorting && _this37.table.modExists("sort")) {
15774
17816
  var sorters = self.table.modules.sort.getSort();
15775
17817
 
15776
17818
  sorters.forEach(function (item) {
15777
17819
  delete item.column;
15778
17820
  });
15779
17821
 
15780
- pageParams[_this23.paginationDataSentNames.sorters] = sorters;
17822
+ pageParams[_this37.paginationDataSentNames.sorters] = sorters;
15781
17823
  }
15782
17824
 
15783
17825
  //set filter data if defined
15784
- if (_this23.table.options.ajaxFiltering && _this23.table.modExists("filter")) {
17826
+ if (_this37.table.options.ajaxFiltering && _this37.table.modExists("filter")) {
15785
17827
  var filters = self.table.modules.filter.getFilters(true, true);
15786
- pageParams[_this23.paginationDataSentNames.filters] = filters;
17828
+ pageParams[_this37.paginationDataSentNames.filters] = filters;
15787
17829
  }
15788
17830
 
15789
17831
  self.table.modules.ajax.setParams(pageParams);
15790
17832
 
15791
- self.table.modules.ajax.sendRequest(_this23.progressiveLoad).then(function (data) {
17833
+ self.table.modules.ajax.sendRequest(_this37.progressiveLoad).then(function (data) {
15792
17834
  self._parseRemoteData(data);
15793
17835
  resolve();
15794
17836
  }).catch(function (e) {
@@ -16599,12 +18641,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
16599
18641
  var SelectRow = function SelectRow(table) {
16600
18642
  this.table = table; //hold Tabulator object
16601
18643
  this.selecting = false; //flag selecting in progress
18644
+ this.lastClickedRow = false; //last clicked row
16602
18645
  this.selectPrev = []; //hold previously selected element for drag drop selection
16603
18646
  this.selectedRows = []; //hold selected rows
16604
18647
  };
16605
18648
 
16606
18649
  SelectRow.prototype.clearSelectionData = function (silent) {
16607
18650
  this.selecting = false;
18651
+ this.lastClickedRow = false;
16608
18652
  this.selectPrev = [];
16609
18653
  this.selectedRows = [];
16610
18654
 
@@ -16635,42 +18679,78 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
16635
18679
  element.classList.remove("tabulator-unselectable");
16636
18680
 
16637
18681
  if (self.table.options.selectable && self.table.options.selectable != "highlight") {
16638
- element.addEventListener("click", function (e) {
16639
- if (!self.selecting) {
16640
- self.toggleRow(row);
16641
- }
16642
- });
18682
+ if (self.table.options.selectableRangeMode && self.table.options.selectableRangeMode === "click") {
18683
+ element.addEventListener("click", function (e) {
18684
+ if (e.shiftKey) {
18685
+ self.lastClickedRow = self.lastClickedRow || row;
18686
+
18687
+ var lastClickedRowIdx = self.table.rowManager.getDisplayRowIndex(self.lastClickedRow);
18688
+ var rowIdx = self.table.rowManager.getDisplayRowIndex(row);
18689
+
18690
+ var fromRowIdx = lastClickedRowIdx <= rowIdx ? lastClickedRowIdx : rowIdx;
18691
+ var toRowIdx = lastClickedRowIdx >= rowIdx ? lastClickedRowIdx : rowIdx;
18692
+
18693
+ var rows = self.table.rowManager.getDisplayRows().slice(0);
18694
+ var toggledRows = rows.splice(fromRowIdx, toRowIdx - fromRowIdx + 1);
18695
+
18696
+ if (e.ctrlKey) {
18697
+ toggledRows.forEach(function (toggledRow) {
18698
+ if (toggledRow !== self.lastClickedRow) {
18699
+ self.toggleRow(toggledRow);
18700
+ }
18701
+ });
18702
+ self.lastClickedRow = row;
18703
+ } else {
18704
+ self.deselectRows();
18705
+ self.selectRows(toggledRows);
18706
+ }
18707
+ } else if (e.ctrlKey) {
18708
+ self.toggleRow(row);
18709
+ self.lastClickedRow = row;
18710
+ } else {
18711
+ self.deselectRows();
18712
+ self.selectRows(row);
18713
+ self.lastClickedRow = row;
18714
+ }
18715
+ });
18716
+ } else {
18717
+ element.addEventListener("click", function (e) {
18718
+ if (!self.selecting) {
18719
+ self.toggleRow(row);
18720
+ }
18721
+ });
16643
18722
 
16644
- element.addEventListener("mousedown", function (e) {
16645
- if (e.shiftKey) {
16646
- self.selecting = true;
18723
+ element.addEventListener("mousedown", function (e) {
18724
+ if (e.shiftKey) {
18725
+ self.selecting = true;
16647
18726
 
16648
- self.selectPrev = [];
18727
+ self.selectPrev = [];
16649
18728
 
16650
- document.body.addEventListener("mouseup", endSelect);
16651
- document.body.addEventListener("keyup", endSelect);
18729
+ document.body.addEventListener("mouseup", endSelect);
18730
+ document.body.addEventListener("keyup", endSelect);
16652
18731
 
16653
- self.toggleRow(row);
18732
+ self.toggleRow(row);
16654
18733
 
16655
- return false;
16656
- }
16657
- });
18734
+ return false;
18735
+ }
18736
+ });
16658
18737
 
16659
- element.addEventListener("mouseenter", function (e) {
16660
- if (self.selecting) {
16661
- self.toggleRow(row);
18738
+ element.addEventListener("mouseenter", function (e) {
18739
+ if (self.selecting) {
18740
+ self.toggleRow(row);
16662
18741
 
16663
- if (self.selectPrev[1] == row) {
16664
- self.toggleRow(self.selectPrev[0]);
18742
+ if (self.selectPrev[1] == row) {
18743
+ self.toggleRow(self.selectPrev[0]);
18744
+ }
16665
18745
  }
16666
- }
16667
- });
18746
+ });
16668
18747
 
16669
- element.addEventListener("mouseout", function (e) {
16670
- if (self.selecting) {
16671
- self.selectPrev.unshift(row);
16672
- }
16673
- });
18748
+ element.addEventListener("mouseout", function (e) {
18749
+ if (self.selecting) {
18750
+ self.selectPrev.unshift(row);
18751
+ }
18752
+ });
18753
+ }
16674
18754
  }
16675
18755
  } else {
16676
18756
  element.classList.add("tabulator-unselectable");
@@ -16848,6 +18928,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
16848
18928
  };
16849
18929
 
16850
18930
  Tabulator.prototype.registerModule("selectRow", SelectRow);
18931
+
16851
18932
  var Sort = function Sort(table) {
16852
18933
  this.table = table; //hold Tabulator object
16853
18934
  this.sortList = []; //holder current sort
@@ -16901,7 +18982,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
16901
18982
  if (column.modules.sort) {
16902
18983
  dir = column.modules.sort.dir == "asc" ? "desc" : column.modules.sort.dir == "desc" ? "asc" : column.modules.sort.startingDir;
16903
18984
 
16904
- if (e.shiftKey || e.ctrlKey) {
18985
+ if (self.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {
16905
18986
  sorters = self.getSort();
16906
18987
 
16907
18988
  match = sorters.findIndex(function (sorter) {
@@ -17030,7 +19111,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17030
19111
  //work through sort list sorting data
17031
19112
  Sort.prototype.sort = function () {
17032
19113
  var self = this,
17033
- lastSort;
19114
+ lastSort,
19115
+ sortList;
19116
+
19117
+ sortList = this.table.options.sortOrderReverse ? self.sortList.slice().reverse() : self.sortList;
17034
19118
 
17035
19119
  if (self.table.options.dataSorting) {
17036
19120
  self.table.options.dataSorting.call(self.table, self.getSort());
@@ -17040,7 +19124,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17040
19124
 
17041
19125
  if (!self.table.options.ajaxSorting) {
17042
19126
 
17043
- self.sortList.forEach(function (item, i) {
19127
+ sortList.forEach(function (item, i) {
17044
19128
 
17045
19129
  if (item.column && item.column.modules.sort) {
17046
19130
 
@@ -17049,13 +19133,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17049
19133
  item.column.modules.sort.sorter = self.findSorter(item.column);
17050
19134
  }
17051
19135
 
17052
- self._sortItem(item.column, item.dir, self.sortList, i);
19136
+ self._sortItem(item.column, item.dir, sortList, i);
17053
19137
  }
17054
19138
 
17055
19139
  self.setColumnHeader(item.column, item.dir);
17056
19140
  });
17057
19141
  } else {
17058
- self.sortList.forEach(function (item, i) {
19142
+ sortList.forEach(function (item, i) {
17059
19143
  self.setColumnHeader(item.column, item.dir);
17060
19144
  });
17061
19145
  }
@@ -17194,72 +19278,27 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17194
19278
 
17195
19279
  //sort date
17196
19280
  date: function date(a, b, aRow, bRow, column, dir, params) {
17197
- var self = this;
17198
- var format = params.format || "DD/MM/YYYY";
17199
- var alignEmptyValues = params.alignEmptyValues;
17200
- var emptyAlign = 0;
17201
-
17202
- if (typeof moment != "undefined") {
17203
- a = moment(a, format);
17204
- b = moment(b, format);
17205
-
17206
- if (!a.isValid()) {
17207
- emptyAlign = !b.isValid() ? 0 : -1;
17208
- } else if (!b.isValid()) {
17209
- emptyAlign = 1;
17210
- } else {
17211
- //compare valid values
17212
- return a - b;
17213
- }
17214
-
17215
- //fix empty values in position
17216
- if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
17217
- emptyAlign *= -1;
17218
- }
17219
-
17220
- return emptyAlign;
17221
- } else {
17222
- console.error("Sort Error - 'date' sorter is dependant on moment.js");
19281
+ if (!params.format) {
19282
+ params.format = "DD/MM/YYYY";
17223
19283
  }
19284
+
19285
+ return this.sorters.datetime.call(this, a, b, aRow, bRow, column, dir, params);
17224
19286
  },
17225
19287
 
17226
19288
  //sort hh:mm formatted times
17227
19289
  time: function time(a, b, aRow, bRow, column, dir, params) {
17228
- var self = this;
17229
- var format = params.format || "hh:mm";
17230
- var alignEmptyValues = params.alignEmptyValues;
17231
- var emptyAlign = 0;
17232
-
17233
- if (typeof moment != "undefined") {
17234
- a = moment(a, format);
17235
- b = moment(b, format);
17236
-
17237
- if (!a.isValid()) {
17238
- emptyAlign = !b.isValid() ? 0 : -1;
17239
- } else if (!b.isValid()) {
17240
- emptyAlign = 1;
17241
- } else {
17242
- //compare valid values
17243
- return a - b;
17244
- }
17245
-
17246
- //fix empty values in position
17247
- if (alignEmptyValues === "top" && dir === "desc" || alignEmptyValues === "bottom" && dir === "asc") {
17248
- emptyAlign *= -1;
17249
- }
17250
-
17251
- return emptyAlign;
17252
- } else {
17253
- console.error("Sort Error - 'date' sorter is dependant on moment.js");
19290
+ if (!params.format) {
19291
+ params.format = "hh:mm";
17254
19292
  }
19293
+
19294
+ return this.sorters.datetime.call(this, a, b, aRow, bRow, column, dir, params);
17255
19295
  },
17256
19296
 
17257
19297
  //sort datetime
17258
19298
  datetime: function datetime(a, b, aRow, bRow, column, dir, params) {
17259
- var self = this;
17260
- var format = params.format || "DD/MM/YYYY hh:mm:ss";
17261
- var alignEmptyValues = params.alignEmptyValues;
17262
- var emptyAlign = 0;
19299
+ var format = params.format || "DD/MM/YYYY hh:mm:ss",
19300
+ alignEmptyValues = params.alignEmptyValues,
19301
+ emptyAlign = 0;
17263
19302
 
17264
19303
  if (typeof moment != "undefined") {
17265
19304
  a = moment(a, format);
@@ -17281,7 +19320,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17281
19320
 
17282
19321
  return emptyAlign;
17283
19322
  } else {
17284
- console.error("Sort Error - 'date' sorter is dependant on moment.js");
19323
+ console.error("Sort Error - 'datetime' sorter is dependant on moment.js");
17285
19324
  }
17286
19325
  },
17287
19326
 
@@ -17413,6 +19452,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17413
19452
  };
17414
19453
 
17415
19454
  Tabulator.prototype.registerModule("sort", Sort);
19455
+
17416
19456
  var Validate = function Validate(table) {
17417
19457
  this.table = table;
17418
19458
  };
@@ -17450,7 +19490,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
17450
19490
 
17451
19491
  switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
17452
19492
  case "string":
17453
- parts = value.split(":", 1);
19493
+ parts = value.split(":", 2);
17454
19494
  type = parts.shift();
17455
19495
  params = parts[0];
17456
19496