tabulator-tables 5.0.3 → 5.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/bower.json +1 -1
  2. package/build/rollup.js +1 -1
  3. package/dist/css/tabulator_bootstrap3.css +9 -0
  4. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  5. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  6. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  7. package/dist/css/tabulator_bulma.css +5 -1
  8. package/dist/css/tabulator_bulma.css.map +1 -1
  9. package/dist/css/tabulator_bulma.min.css +1 -1
  10. package/dist/css/tabulator_bulma.min.css.map +1 -1
  11. package/dist/css/tabulator_semanticui.css +11 -2
  12. package/dist/css/tabulator_semanticui.css.map +1 -1
  13. package/dist/css/tabulator_semanticui.min.css +1 -1
  14. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  15. package/dist/js/tabulator.js +456 -307
  16. package/dist/js/tabulator.js.map +1 -1
  17. package/dist/js/tabulator.min.js +2 -2
  18. package/dist/js/tabulator.min.js.map +1 -1
  19. package/dist/js/tabulator_esm.js +483 -354
  20. package/dist/js/tabulator_esm.js.map +1 -1
  21. package/dist/js/tabulator_esm.min.js +2 -2
  22. package/dist/js/tabulator_esm.min.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/js/core/ColumnManager.js +18 -17
  25. package/src/js/core/RowManager.js +5 -3
  26. package/src/js/core/Tabulator.js +180 -125
  27. package/src/js/core/column/Column.js +2 -2
  28. package/src/js/core/tools/{ComponentFuctionBinder.js → ComponentFunctionBinder.js} +1 -1
  29. package/src/js/core/tools/Helpers.js +19 -13
  30. package/src/js/core/tools/InteractionMonitor.js +4 -1
  31. package/src/js/core/tools/OptionsList.js +2 -2
  32. package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +22 -1
  33. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +1 -1
  34. package/src/js/modules/DataTree/DataTree.js +1 -1
  35. package/src/js/modules/Edit/Edit.js +7 -6
  36. package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
  37. package/src/js/modules/Filter/Filter.js +9 -4
  38. package/src/js/modules/Format/defaults/formatters/datetime.js +2 -2
  39. package/src/js/modules/Format/defaults/formatters/datetimediff.js +1 -1
  40. package/src/js/modules/Format/defaults/formatters/money.js +8 -1
  41. package/src/js/modules/FrozenColumns/FrozenColumns.js +21 -0
  42. package/src/js/modules/FrozenRows/FrozenRows.js +4 -1
  43. package/src/js/modules/GroupRows/Group.js +10 -4
  44. package/src/js/modules/GroupRows/GroupRows.js +41 -29
  45. package/src/js/modules/History/History.js +3 -1
  46. package/src/js/modules/History/defaults/redoers.js +1 -0
  47. package/src/js/modules/History/defaults/undoers.js +1 -0
  48. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +8 -29
  49. package/src/js/modules/MoveColumns/MoveColumns.js +64 -61
  50. package/src/js/modules/Page/Page.js +2 -1
  51. package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +5 -1
  52. package/src/js/modules/SelectRow/SelectRow.js +3 -3
  53. package/src/js/modules/Sort/Sort.js +1 -1
  54. package/src/js/modules/Sort/defaults/sorters/datetime.js +3 -2
  55. package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +9 -0
  56. package/src/scss/themes/bulma/tabulator_bulma.scss +5 -1
  57. package/src/scss/themes/semanticui/tabulator_semanticui.scss +12 -7
@@ -2,10 +2,10 @@ import Module from '../../core/Module.js';
2
2
  import Helpers from '../../core/tools/Helpers.js';
3
3
 
4
4
  class MoveColumns extends Module{
5
-
5
+
6
6
  constructor(table){
7
7
  super(table);
8
-
8
+
9
9
  this.placeholderElement = this.createPlaceholderElement();
10
10
  this.hoverElement = false; //floating column header element
11
11
  this.checkTimeout = false; //click check timeout holder
@@ -18,35 +18,36 @@ class MoveColumns extends Module{
18
18
  this.autoScrollStep = 5; //auto scroll distance in pixels
19
19
  this.autoScrollTimeout = false; //auto scroll timeout
20
20
  this.touchMove = false;
21
-
21
+
22
22
  this.moveHover = this.moveHover.bind(this);
23
23
  this.endMove = this.endMove.bind(this);
24
-
24
+
25
25
  this.registerTableOption("movableColumns", false); //enable movable columns
26
26
  }
27
-
27
+
28
28
  createPlaceholderElement(){
29
29
  var el = document.createElement("div");
30
-
30
+
31
31
  el.classList.add("tabulator-col");
32
32
  el.classList.add("tabulator-col-placeholder");
33
-
33
+
34
34
  return el;
35
35
  }
36
-
36
+
37
37
  initialize(){
38
- this.subscribe("column-init", this.initializeColumn.bind(this));
38
+ if(this.table.options.movableColumns){
39
+ this.subscribe("column-init", this.initializeColumn.bind(this));
40
+ }
39
41
  }
40
-
42
+
41
43
  initializeColumn(column){
42
44
  var self = this,
43
45
  config = {},
44
46
  colEl;
45
-
47
+
46
48
  if(!column.modules.frozen){
47
-
48
49
  colEl = column.getElement();
49
-
50
+
50
51
  config.mousemove = function(e){
51
52
  if(column.parent === self.moving.parent){
52
53
  if((((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(colEl).left) + self.table.columnManager.element.scrollLeft) > (column.getWidth() / 2)){
@@ -62,7 +63,7 @@ class MoveColumns extends Module{
62
63
  }
63
64
  }
64
65
  }.bind(self);
65
-
66
+
66
67
  colEl.addEventListener("mousedown", function(e){
67
68
  self.touchMove = false;
68
69
  if(e.which === 1){
@@ -71,7 +72,7 @@ class MoveColumns extends Module{
71
72
  }, self.checkPeriod);
72
73
  }
73
74
  });
74
-
75
+
75
76
  colEl.addEventListener("mouseup", function(e){
76
77
  if(e.which === 1){
77
78
  if(self.checkTimeout){
@@ -79,19 +80,19 @@ class MoveColumns extends Module{
79
80
  }
80
81
  }
81
82
  });
82
-
83
+
83
84
  self.bindTouchEvents(column);
84
85
  }
85
-
86
+
86
87
  column.modules.moveColumn = config;
87
88
  }
88
-
89
+
89
90
  bindTouchEvents(column){
90
91
  var colEl = column.getElement(),
91
92
  startXMove = false, //shifting center position of the cell
92
93
  dir = false,
93
94
  currentCol, nextCol, prevCol, nextColWidth, prevColWidth, nextColWidthLast, prevColWidthLast;
94
-
95
+
95
96
  colEl.addEventListener("touchstart", (e) => {
96
97
  this.checkTimeout = setTimeout(() => {
97
98
  this.touchMove = true;
@@ -103,27 +104,27 @@ class MoveColumns extends Module{
103
104
  nextColWidthLast = 0;
104
105
  prevColWidthLast = 0;
105
106
  startXMove = false;
106
-
107
+
107
108
  this.startMove(e, column);
108
109
  }, this.checkPeriod);
109
110
  }, {passive: true});
110
-
111
+
111
112
  colEl.addEventListener("touchmove", (e) => {
112
113
  var halfCol, diff, moveToCol;
113
-
114
+
114
115
  if(this.moving){
115
116
  this.moveHover(e);
116
-
117
+
117
118
  if(!startXMove){
118
119
  startXMove = e.touches[0].pageX;
119
120
  }
120
-
121
+
121
122
  diff = e.touches[0].pageX - startXMove;
122
-
123
+
123
124
  if(diff > 0){
124
125
  if(nextCol && diff - nextColWidthLast > nextColWidth){
125
126
  moveToCol = nextCol;
126
-
127
+
127
128
  if(moveToCol !== column){
128
129
  startXMove = e.touches[0].pageX;
129
130
  moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement().nextSibling);
@@ -133,7 +134,7 @@ class MoveColumns extends Module{
133
134
  }else{
134
135
  if(prevCol && -diff - prevColWidthLast > prevColWidth){
135
136
  moveToCol = prevCol;
136
-
137
+
137
138
  if(moveToCol !== column){
138
139
  startXMove = e.touches[0].pageX;
139
140
  moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement());
@@ -141,7 +142,7 @@ class MoveColumns extends Module{
141
142
  }
142
143
  }
143
144
  }
144
-
145
+
145
146
  if(moveToCol){
146
147
  currentCol = moveToCol;
147
148
  nextCol = moveToCol.nextColumn();
@@ -153,7 +154,7 @@ class MoveColumns extends Module{
153
154
  }
154
155
  }
155
156
  }, {passive: true});
156
-
157
+
157
158
  colEl.addEventListener("touchend", (e) => {
158
159
  if(this.checkTimeout){
159
160
  clearTimeout(this.checkTimeout);
@@ -163,41 +164,43 @@ class MoveColumns extends Module{
163
164
  }
164
165
  });
165
166
  }
166
-
167
+
167
168
  startMove(e, column){
168
- var element = column.getElement();
169
-
169
+ var element = column.getElement(),
170
+ headerElement = this.table.columnManager.getElement(),
171
+ headersElement = this.table.columnManager.getHeadersElement();
172
+
170
173
  this.moving = column;
171
174
  this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;
172
-
175
+
173
176
  this.table.element.classList.add("tabulator-block-select");
174
-
177
+
175
178
  //create placeholder
176
179
  this.placeholderElement.style.width = column.getWidth() + "px";
177
180
  this.placeholderElement.style.height = column.getHeight() + "px";
178
-
181
+
179
182
  element.parentNode.insertBefore(this.placeholderElement, element);
180
183
  element.parentNode.removeChild(element);
181
-
184
+
182
185
  //create hover element
183
186
  this.hoverElement = element.cloneNode(true);
184
187
  this.hoverElement.classList.add("tabulator-moving");
185
-
188
+
186
189
  this.table.columnManager.getElement().appendChild(this.hoverElement);
187
-
190
+
188
191
  this.hoverElement.style.left = "0";
189
- this.hoverElement.style.bottom = "0";
190
-
192
+ this.hoverElement.style.bottom = (headerElement.clientHeight - headersElement.offsetHeight) + "px";
193
+
191
194
  if(!this.touchMove){
192
195
  this._bindMouseMove();
193
-
196
+
194
197
  document.body.addEventListener("mousemove", this.moveHover);
195
198
  document.body.addEventListener("mouseup", this.endMove);
196
199
  }
197
-
200
+
198
201
  this.moveHover(e);
199
202
  }
200
-
203
+
201
204
  _bindMouseMove(){
202
205
  this.table.columnManager.columnsByIndex.forEach(function(column){
203
206
  if(column.modules.moveColumn.mousemove){
@@ -205,7 +208,7 @@ class MoveColumns extends Module{
205
208
  }
206
209
  });
207
210
  }
208
-
211
+
209
212
  _unbindMouseMove(){
210
213
  this.table.columnManager.columnsByIndex.forEach(function(column){
211
214
  if(column.modules.moveColumn.mousemove){
@@ -213,65 +216,65 @@ class MoveColumns extends Module{
213
216
  }
214
217
  });
215
218
  }
216
-
219
+
217
220
  moveColumn(column, after){
218
221
  var movingCells = this.moving.getCells();
219
-
222
+
220
223
  this.toCol = column;
221
224
  this.toColAfter = after;
222
-
225
+
223
226
  if(after){
224
227
  column.getCells().forEach(function(cell, i){
225
228
  var cellEl = cell.getElement(true);
226
-
227
- if(cellEl.parentNode){
229
+
230
+ if(cellEl.parentNode && movingCells[i]){
228
231
  cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl.nextSibling);
229
232
  }
230
233
  });
231
234
  }else{
232
235
  column.getCells().forEach(function(cell, i){
233
236
  var cellEl = cell.getElement(true);
234
-
235
- if(cellEl.parentNode){
237
+
238
+ if(cellEl.parentNode && movingCells[i]){
236
239
  cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl);
237
240
  }
238
241
  });
239
242
  }
240
243
  }
241
-
244
+
242
245
  endMove(e){
243
246
  if(e.which === 1 || this.touchMove){
244
247
  this._unbindMouseMove();
245
-
248
+
246
249
  this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);
247
250
  this.placeholderElement.parentNode.removeChild(this.placeholderElement);
248
251
  this.hoverElement.parentNode.removeChild(this.hoverElement);
249
-
252
+
250
253
  this.table.element.classList.remove("tabulator-block-select");
251
-
254
+
252
255
  if(this.toCol){
253
256
  this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
254
257
  }
255
-
258
+
256
259
  this.moving = false;
257
260
  this.toCol = false;
258
261
  this.toColAfter = false;
259
-
262
+
260
263
  if(!this.touchMove){
261
264
  document.body.removeEventListener("mousemove", this.moveHover);
262
265
  document.body.removeEventListener("mouseup", this.endMove);
263
266
  }
264
267
  }
265
268
  }
266
-
269
+
267
270
  moveHover(e){
268
271
  var columnHolder = this.table.columnManager.getElement(),
269
272
  scrollLeft = columnHolder.scrollLeft,
270
273
  xPos = ((this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(columnHolder).left) + scrollLeft,
271
274
  scrollPos;
272
-
275
+
273
276
  this.hoverElement.style.left = (xPos - this.startX) + "px";
274
-
277
+
275
278
  if(xPos - scrollLeft < this.autoScrollMargin){
276
279
  if(!this.autoScrollTimeout){
277
280
  this.autoScrollTimeout = setTimeout(() => {
@@ -281,7 +284,7 @@ class MoveColumns extends Module{
281
284
  }, 1);
282
285
  }
283
286
  }
284
-
287
+
285
288
  if(scrollLeft + columnHolder.clientWidth - xPos < this.autoScrollMargin){
286
289
  if(!this.autoScrollTimeout){
287
290
  this.autoScrollTimeout = setTimeout(() => {
@@ -198,7 +198,8 @@ class Page extends Module{
198
198
  margin = this.table.options.progressiveLoadScrollMargin || (element.clientHeight * 2);
199
199
 
200
200
  if(diff < margin){
201
- this.nextPage();
201
+ this.nextPage()
202
+ .catch(() => {}); //consume the exception thrown when on the last page
202
203
  }
203
204
  }
204
205
  }
@@ -290,10 +290,14 @@ class ResponsiveLayout extends Module{
290
290
  },
291
291
  };
292
292
 
293
+ function onRendered(callback){
294
+ callback();
295
+ }
296
+
293
297
  output.push({
294
298
  field: column.field,
295
299
  title: column.definition.title,
296
- value: column.modules.format.formatter.call(self.table.modules.format, mockCellComponent, column.modules.format.params)
300
+ value: column.modules.format.formatter.call(self.table.modules.format, mockCellComponent, column.modules.format.params, onRendered)
297
301
  });
298
302
  }else{
299
303
  output.push({
@@ -35,9 +35,9 @@ class SelectRow extends Module{
35
35
  this.subscribe("row-init", this.initializeRow.bind(this));
36
36
  this.subscribe("row-deleting", this.rowDeleted.bind(this));
37
37
  this.subscribe("rows-wipe", this.clearSelectionData.bind(this));
38
- this.subscribe("rows-retrieve", this.clearSelectionData.bind(this));
38
+ this.subscribe("rows-retrieve", this.rowRetrieve.bind(this));
39
39
 
40
- if(this.table.options.selectable && this.table.options.selectablePersistence){
40
+ if(this.table.options.selectable && !this.table.options.selectablePersistence){
41
41
  this.subscribe("data-refeshing", this.deselectRows.bind(this));
42
42
  }
43
43
  }
@@ -51,7 +51,6 @@ class SelectRow extends Module{
51
51
  this._deselectRow(row, true);
52
52
  }
53
53
 
54
-
55
54
  clearSelectionData(silent){
56
55
  this.selecting = false;
57
56
  this.lastClickedRow = false;
@@ -300,6 +299,7 @@ class SelectRow extends Module{
300
299
  var self = this,
301
300
  rowCount;
302
301
 
302
+ console.trace("deselect")
303
303
  if(typeof rows == "undefined"){
304
304
 
305
305
  rowCount = self.selectedRows.length;
@@ -206,7 +206,7 @@ class Sort extends Module{
206
206
  if(this.table.options.sortMode === "remote"){
207
207
  this.reloadData();
208
208
  }else{
209
- this.refreshData()
209
+ this.refreshData(true);
210
210
  }
211
211
 
212
212
  //TODO - Persist left position of row manager
@@ -6,8 +6,9 @@ export default function(a, b, aRow, bRow, column, dir, params){
6
6
  emptyAlign = 0;
7
7
 
8
8
  if(typeof DT != "undefined"){
9
- a = DT.fromFormat(a, format);
10
- b = DT.fromFormat(b, format);
9
+ a = DT.fromFormat(String(a), format);
10
+ b = DT.fromFormat(String(b), format);
11
+
11
12
  if(!a.isValid){
12
13
  emptyAlign = !b.isValid ? 0 : -1;
13
14
  }else if(!b.isValid){
@@ -185,6 +185,15 @@ $footerActiveColor:#d00 !default; //footer bottom active text color
185
185
  background-color:$rowHoverBackground !important;
186
186
  }
187
187
 
188
+ &.tabulator-selected{
189
+ background-color:$rowSelectedBackground !important;
190
+ }
191
+
192
+ &.tabulator-selected:hover{
193
+ background-color:$rowSelectedBackgroundHover !important;
194
+ cursor: pointer;
195
+ }
196
+
188
197
  .tabulator-cell{
189
198
  padding:$cellPadding;
190
199
  border-right:none;
@@ -204,8 +204,12 @@ $footerBorderColor:$grey-lighter !default; //footer border color
204
204
  background-color: inherit;
205
205
  }
206
206
 
207
+ &.tabulator-selected{
208
+ background-color:$rowSelectedBackground !important;
209
+ }
210
+
207
211
  &.tabulator-selected:hover{
208
- background-color:darken($rowSelectedBackground, 10%);
212
+ background-color:darken($rowSelectedBackground, 10%) !important;
209
213
  }
210
214
 
211
215
  .tabulator-cell{
@@ -219,13 +219,9 @@ $footerActiveColor:#d00 !default; //footer bottom active text color
219
219
  }
220
220
 
221
221
  &.striped{
222
- .tabulator-tableholder{
223
- .tabulator-table{
224
- .tabulator-row{
225
- &:nth-child(even){
226
- background-color: $basicTableStripedBackground !important;
227
- }
228
- }
222
+ .tabulator-row{
223
+ &:nth-child(even){
224
+ background-color: $basicTableStripedBackground;
229
225
  }
230
226
  }
231
227
  }
@@ -488,6 +484,15 @@ $footerActiveColor:#d00 !default; //footer bottom active text color
488
484
  color: $activeColor !important;
489
485
  }
490
486
 
487
+ &.tabulator-selected{
488
+ background-color:$rowSelectedBackground !important;
489
+ }
490
+
491
+ &.tabulator-selected:hover{
492
+ background-color:$rowSelectedBackgroundHover !important;
493
+ cursor: pointer;
494
+ }
495
+
491
496
  &.tabulator-moving{
492
497
  pointer-events: none !important;
493
498
  }