tabulator-tables 5.1.7 → 5.2.1

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 (103) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +3 -2
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
  3. package/bower.json +1 -1
  4. package/dist/css/tabulator.css +64 -51
  5. package/dist/css/tabulator.css.map +1 -1
  6. package/dist/css/tabulator.min.css +1 -1
  7. package/dist/css/tabulator.min.css.map +1 -1
  8. package/dist/css/tabulator_bootstrap3.css +64 -51
  9. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  10. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  11. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  12. package/dist/css/tabulator_bootstrap4.css +64 -51
  13. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  14. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  15. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  16. package/dist/css/tabulator_bootstrap5.css +1580 -0
  17. package/dist/css/tabulator_bootstrap5.css.map +1 -0
  18. package/dist/css/tabulator_bootstrap5.min.css +2 -0
  19. package/dist/css/tabulator_bootstrap5.min.css.map +1 -0
  20. package/dist/css/tabulator_bulma.css +64 -51
  21. package/dist/css/tabulator_bulma.css.map +1 -1
  22. package/dist/css/tabulator_bulma.min.css +1 -1
  23. package/dist/css/tabulator_bulma.min.css.map +1 -1
  24. package/dist/css/tabulator_materialize.css +64 -51
  25. package/dist/css/tabulator_materialize.css.map +1 -1
  26. package/dist/css/tabulator_materialize.min.css +1 -1
  27. package/dist/css/tabulator_materialize.min.css.map +1 -1
  28. package/dist/css/tabulator_midnight.css +64 -51
  29. package/dist/css/tabulator_midnight.css.map +1 -1
  30. package/dist/css/tabulator_midnight.min.css +1 -1
  31. package/dist/css/tabulator_midnight.min.css.map +1 -1
  32. package/dist/css/tabulator_modern.css +64 -51
  33. package/dist/css/tabulator_modern.css.map +1 -1
  34. package/dist/css/tabulator_modern.min.css +1 -1
  35. package/dist/css/tabulator_modern.min.css.map +1 -1
  36. package/dist/css/tabulator_semanticui.css +64 -51
  37. package/dist/css/tabulator_semanticui.css.map +1 -1
  38. package/dist/css/tabulator_semanticui.min.css +1 -1
  39. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  40. package/dist/css/tabulator_simple.css +64 -51
  41. package/dist/css/tabulator_simple.css.map +1 -1
  42. package/dist/css/tabulator_simple.min.css +1 -1
  43. package/dist/css/tabulator_simple.min.css.map +1 -1
  44. package/dist/css/tabulator_site.css +64 -51
  45. package/dist/css/tabulator_site.css.map +1 -1
  46. package/dist/css/tabulator_site.min.css +1 -1
  47. package/dist/css/tabulator_site.min.css.map +1 -1
  48. package/dist/js/tabulator.js +2543 -1658
  49. package/dist/js/tabulator.js.map +1 -1
  50. package/dist/js/tabulator.min.js +2 -2
  51. package/dist/js/tabulator.min.js.map +1 -1
  52. package/dist/js/tabulator_esm.js +2746 -2069
  53. package/dist/js/tabulator_esm.js.map +1 -1
  54. package/dist/js/tabulator_esm.min.js +2 -2
  55. package/dist/js/tabulator_esm.min.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/js/core/FooterManager.js +6 -13
  58. package/src/js/core/Module.js +44 -2
  59. package/src/js/core/Tabulator.js +341 -289
  60. package/src/js/core/cell/Cell.js +9 -38
  61. package/src/js/core/column/Column.js +8 -44
  62. package/src/js/core/column/defaults/options.js +0 -2
  63. package/src/js/core/defaults/options.js +5 -2
  64. package/src/js/core/modules/optional.js +2 -0
  65. package/src/js/core/row/Row.js +127 -118
  66. package/src/js/core/tools/Alert.js +63 -0
  67. package/src/js/core/tools/ComponentFunctionBinder.js +3 -3
  68. package/src/js/core/tools/DataLoader.js +12 -84
  69. package/src/js/core/tools/InteractionMonitor.js +1 -1
  70. package/src/js/core/tools/ModuleBinder.js +30 -23
  71. package/src/js/core/tools/Popup.js +251 -0
  72. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +2 -2
  73. package/src/js/modules/Edit/Edit.js +6 -25
  74. package/src/js/modules/Edit/List.js +997 -0
  75. package/src/js/modules/Edit/defaults/editors/autocomplete.js +6 -446
  76. package/src/js/modules/Edit/defaults/editors/input.js +4 -0
  77. package/src/js/modules/Edit/defaults/editors/list.js +7 -0
  78. package/src/js/modules/Edit/defaults/editors/number.js +4 -0
  79. package/src/js/modules/Edit/defaults/editors/select.js +5 -584
  80. package/src/js/modules/Edit/defaults/editors/textarea.js +4 -0
  81. package/src/js/modules/Edit/defaults/editors/tickCross.js +17 -5
  82. package/src/js/modules/Edit/defaults/editors.js +2 -0
  83. package/src/js/modules/Filter/Filter.js +7 -4
  84. package/src/js/modules/Format/defaults/formatters/datetime.js +10 -4
  85. package/src/js/modules/Format/defaults/formatters/datetimediff.js +10 -3
  86. package/src/js/modules/Format/defaults/formatters/link.js +12 -1
  87. package/src/js/modules/Format/defaults/formatters/money.js +5 -3
  88. package/src/js/modules/Format/defaults/formatters/tickCross.js +2 -1
  89. package/src/js/modules/FrozenColumns/FrozenColumns.js +30 -8
  90. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +5 -1
  91. package/src/js/modules/Menu/Menu.js +59 -157
  92. package/src/js/modules/Mutator/Mutator.js +20 -0
  93. package/src/js/modules/Page/Page.js +7 -3
  94. package/src/js/modules/Persistence/Persistence.js +1 -1
  95. package/src/js/modules/Popup/Popup.js +194 -0
  96. package/src/js/modules/ResizeColumns/ResizeColumns.js +138 -81
  97. package/src/js/modules/Sort/defaults/sorters/datetime.js +15 -2
  98. package/src/js/modules/Tooltip/Tooltip.js +132 -0
  99. package/src/js/modules/Validate/Validate.js +107 -71
  100. package/src/scss/tabulator.scss +354 -349
  101. package/src/scss/themes/bootstrap/functions5.scss +302 -0
  102. package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +546 -0
  103. package/src/scss/themes/bootstrap/variables5.scss +1641 -0
@@ -5,7 +5,7 @@ import Helpers from '../tools/Helpers.js';
5
5
  export default class Row extends CoreFeature{
6
6
  constructor (data, parent, type = "row"){
7
7
  super(parent.table);
8
-
8
+
9
9
  this.parent = parent;
10
10
  this.data = {};
11
11
  this.type = type; //type of element
@@ -15,247 +15,256 @@ export default class Row extends CoreFeature{
15
15
  this.height = 0; //hold element height
16
16
  this.heightStyled = ""; //hold element height prestyled to improve render efficiency
17
17
  this.manualHeight = false; //user has manually set row height
18
- this.outerHeight = 0; //holde lements outer height
18
+ this.outerHeight = 0; //hold elements outer height
19
19
  this.initialized = false; //element has been rendered
20
20
  this.heightInitialized = false; //element has resized cells to fit
21
-
21
+
22
22
  this.component = null;
23
-
23
+
24
24
  this.created = false;
25
-
25
+
26
26
  this.setData(data);
27
27
  }
28
-
28
+
29
29
  create(){
30
30
  if(!this.created){
31
31
  this.created = true;
32
32
  this.generateElement();
33
33
  }
34
34
  }
35
-
35
+
36
36
  createElement (){
37
37
  var el = document.createElement("div");
38
-
38
+
39
39
  el.classList.add("tabulator-row");
40
40
  el.setAttribute("role", "row");
41
-
41
+
42
42
  this.element = el;
43
43
  }
44
-
44
+
45
45
  getElement(){
46
46
  this.create();
47
47
  return this.element;
48
48
  }
49
-
49
+
50
50
  detachElement(){
51
51
  if (this.element && this.element.parentNode){
52
52
  this.element.parentNode.removeChild(this.element);
53
53
  }
54
54
  }
55
-
55
+
56
56
  generateElement(){
57
57
  this.createElement();
58
58
  this.dispatch("row-init", this);
59
59
  }
60
-
60
+
61
61
  generateCells(){
62
62
  this.cells = this.table.columnManager.generateCells(this);
63
63
  }
64
-
64
+
65
65
  //functions to setup on first render
66
66
  initialize(force){
67
67
  this.create();
68
-
68
+
69
69
  if(!this.initialized || force){
70
-
70
+
71
71
  this.deleteCells();
72
-
72
+
73
73
  while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
74
-
74
+
75
75
  this.dispatch("row-layout-before", this);
76
-
76
+
77
77
  this.generateCells();
78
-
78
+
79
79
  this.initialized = true;
80
-
80
+
81
81
  this.table.columnManager.renderer.renderRowCells(this);
82
-
82
+
83
83
  if(force){
84
84
  this.normalizeHeight();
85
85
  }
86
-
86
+
87
87
  this.dispatch("row-layout", this);
88
-
88
+
89
89
  if(this.table.options.rowFormatter){
90
90
  this.table.options.rowFormatter(this.getComponent());
91
91
  }
92
-
92
+
93
93
  this.dispatch("row-layout-after", this);
94
94
  }else{
95
95
  this.table.columnManager.renderer.rerenderRowCells(this);
96
96
  }
97
97
  }
98
-
98
+
99
99
  reinitializeHeight(){
100
100
  this.heightInitialized = false;
101
-
101
+
102
102
  if(this.element && this.element.offsetParent !== null){
103
103
  this.normalizeHeight(true);
104
104
  }
105
105
  }
106
106
 
107
+ deinitialize(){
108
+ this.initialized = false;
109
+ }
110
+
107
111
  deinitializeHeight(){
108
112
  this.heightInitialized = false;
109
113
  }
110
-
114
+
111
115
  reinitialize(children){
112
116
  this.initialized = false;
113
117
  this.heightInitialized = false;
114
-
118
+
115
119
  if(!this.manualHeight){
116
120
  this.height = 0;
117
121
  this.heightStyled = "";
118
122
  }
119
-
123
+
120
124
  if(this.element && this.element.offsetParent !== null){
121
125
  this.initialize(true);
122
126
  }
123
-
127
+
124
128
  this.dispatch("row-relayout", this);
125
129
  }
126
-
130
+
127
131
  //get heights when doing bulk row style calcs in virtual DOM
128
132
  calcHeight(force){
129
-
130
133
  var maxHeight = 0,
131
- minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
132
-
133
- this.cells.forEach(function(cell){
134
- var height = cell.getHeight();
135
- if(height > maxHeight){
136
- maxHeight = height;
137
- }
138
- });
139
-
140
- if(force){
141
- this.height = Math.max(maxHeight, minHeight);
134
+ minHeight;
135
+
136
+ if(this.table.options.rowHeight){
137
+ this.height = this.table.options.rowHeight;
142
138
  }else{
143
- this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
139
+ minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
140
+
141
+ this.cells.forEach(function(cell){
142
+ var height = cell.getHeight();
143
+ if(height > maxHeight){
144
+ maxHeight = height;
145
+ }
146
+ });
147
+
148
+ if(force){
149
+ this.height = Math.max(maxHeight, minHeight);
150
+ }else{
151
+ this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
152
+ }
144
153
  }
145
-
154
+
146
155
  this.heightStyled = this.height ? this.height + "px" : "";
147
156
  this.outerHeight = this.element.offsetHeight;
148
157
  }
149
-
158
+
150
159
  //set of cells
151
160
  setCellHeight(){
152
161
  this.cells.forEach(function(cell){
153
162
  cell.setHeight();
154
163
  });
155
-
164
+
156
165
  this.heightInitialized = true;
157
166
  }
158
-
167
+
159
168
  clearCellHeight(){
160
169
  this.cells.forEach(function(cell){
161
170
  cell.clearHeight();
162
171
  });
163
172
  }
164
-
173
+
165
174
  //normalize the height of elements in the row
166
175
  normalizeHeight(force){
167
- if(force){
176
+ if(force && !this.table.options.rowHeight){
168
177
  this.clearCellHeight();
169
178
  }
170
-
179
+
171
180
  this.calcHeight(force);
172
-
181
+
173
182
  this.setCellHeight();
174
183
  }
175
-
184
+
176
185
  //set height of rows
177
186
  setHeight(height, force){
178
187
  if(this.height != height || force){
179
-
188
+
180
189
  this.manualHeight = true;
181
-
190
+
182
191
  this.height = height;
183
192
  this.heightStyled = height ? height + "px" : "";
184
-
193
+
185
194
  this.setCellHeight();
186
-
195
+
187
196
  // this.outerHeight = this.element.outerHeight();
188
197
  this.outerHeight = this.element.offsetHeight;
189
198
  }
190
199
  }
191
-
200
+
192
201
  //return rows outer height
193
202
  getHeight(){
194
203
  return this.outerHeight;
195
204
  }
196
-
205
+
197
206
  //return rows outer Width
198
207
  getWidth(){
199
208
  return this.element.offsetWidth;
200
209
  }
201
-
210
+
202
211
  //////////////// Cell Management /////////////////
203
212
  deleteCell(cell){
204
213
  var index = this.cells.indexOf(cell);
205
-
214
+
206
215
  if(index > -1){
207
216
  this.cells.splice(index, 1);
208
217
  }
209
218
  }
210
-
219
+
211
220
  //////////////// Data Management /////////////////
212
221
  setData(data){
213
222
  this.data = this.chain("row-data-init-before", [this, data], undefined, data);
214
-
223
+
215
224
  this.dispatch("row-data-init-after", this);
216
225
  }
217
-
226
+
218
227
  //update the rows data
219
228
  updateData(updatedData){
220
229
  var visible = this.element && Helpers.elVisible(this.element),
221
230
  tempData = {},
222
231
  newRowData;
223
-
232
+
224
233
  return new Promise((resolve, reject) => {
225
-
234
+
226
235
  if(typeof updatedData === "string"){
227
236
  updatedData = JSON.parse(updatedData);
228
237
  }
229
-
238
+
230
239
  this.dispatch("row-data-save-before", this);
231
-
240
+
232
241
  if(this.subscribed("row-data-changing")){
233
242
  tempData = Object.assign(tempData, this.data);
234
243
  tempData = Object.assign(tempData, updatedData);
235
244
  }
236
-
245
+
237
246
  newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);
238
-
247
+
239
248
  //set data
240
249
  for (var attrname in newRowData) {
241
250
  this.data[attrname] = newRowData[attrname];
242
251
  }
243
-
252
+
244
253
  this.dispatch("row-data-save-after", this);
245
-
254
+
246
255
  //update affected cells only
247
256
  for (var attrname in updatedData) {
248
-
257
+
249
258
  let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);
250
-
259
+
251
260
  columns.forEach((column) => {
252
261
  let cell = this.getCell(column.getField());
253
-
262
+
254
263
  if(cell){
255
264
  let value = column.getFieldValue(newRowData);
256
265
  if(cell.getValue() != value){
257
266
  cell.setValueProcessData(value);
258
-
267
+
259
268
  if(visible){
260
269
  cell.cellRendered();
261
270
  }
@@ -263,11 +272,11 @@ export default class Row extends CoreFeature{
263
272
  }
264
273
  });
265
274
  }
266
-
275
+
267
276
  //Partial reinitialization if visible
268
277
  if(visible){
269
278
  this.normalizeHeight(true);
270
-
279
+
271
280
  if(this.table.options.rowFormatter){
272
281
  this.table.options.rowFormatter(this.getComponent());
273
282
  }
@@ -276,78 +285,78 @@ export default class Row extends CoreFeature{
276
285
  this.height = 0;
277
286
  this.heightStyled = "";
278
287
  }
279
-
288
+
280
289
  this.dispatch("row-data-changed", this, visible, updatedData);
281
-
290
+
282
291
  //this.reinitialize();
283
-
292
+
284
293
  this.dispatchExternal("rowUpdated", this.getComponent());
285
-
294
+
286
295
  if(this.subscribedExternal("dataChanged")){
287
296
  this.dispatchExternal("dataChanged", this.table.rowManager.getData());
288
297
  }
289
-
298
+
290
299
  resolve();
291
300
  });
292
301
  }
293
-
302
+
294
303
  getData(transform){
295
304
  if(transform){
296
305
  return this.chain("row-data-retrieve", [this, transform], null, this.data);
297
306
  }
298
-
307
+
299
308
  return this.data;
300
309
  }
301
-
310
+
302
311
  getCell(column){
303
312
  var match = false;
304
-
313
+
305
314
  column = this.table.columnManager.findColumn(column);
306
-
315
+
307
316
  if(!this.initialized){
308
317
  this.generateCells();
309
318
  }
310
-
319
+
311
320
  match = this.cells.find(function(cell){
312
321
  return cell.column === column;
313
322
  });
314
-
323
+
315
324
  return match;
316
325
  }
317
-
326
+
318
327
  getCellIndex(findCell){
319
328
  return this.cells.findIndex(function(cell){
320
329
  return cell === findCell;
321
330
  });
322
331
  }
323
-
332
+
324
333
  findCell(subject){
325
334
  return this.cells.find((cell) => {
326
335
  return cell.element === subject;
327
336
  });
328
337
  }
329
-
338
+
330
339
  getCells(){
331
340
  if(!this.initialized){
332
341
  this.generateCells();
333
342
  }
334
-
343
+
335
344
  return this.cells;
336
345
  }
337
-
346
+
338
347
  nextRow(){
339
348
  var row = this.table.rowManager.nextDisplayRow(this, true);
340
349
  return row || false;
341
350
  }
342
-
351
+
343
352
  prevRow(){
344
353
  var row = this.table.rowManager.prevDisplayRow(this, true);
345
354
  return row || false;
346
355
  }
347
-
356
+
348
357
  moveToRow(to, before){
349
358
  var toRow = this.table.rowManager.findRow(to);
350
-
359
+
351
360
  if(toRow){
352
361
  this.table.rowManager.moveRowActual(this, toRow, !before);
353
362
  this.table.rowManager.refreshActiveData("display", false, true);
@@ -355,70 +364,70 @@ export default class Row extends CoreFeature{
355
364
  console.warn("Move Error - No matching row found:", to);
356
365
  }
357
366
  }
358
-
367
+
359
368
  ///////////////////// Actions /////////////////////
360
369
  delete(){
361
370
  this.dispatch("row-delete", this);
362
-
371
+
363
372
  this.deleteActual();
364
-
373
+
365
374
  return Promise.resolve();
366
375
  }
367
-
376
+
368
377
  deleteActual(blockRedraw){
369
378
  var index = this.table.rowManager.getRowIndex(this);
370
-
379
+
371
380
  this.detatchModules();
372
-
381
+
373
382
  this.table.rowManager.deleteRow(this, blockRedraw);
374
-
383
+
375
384
  this.deleteCells();
376
-
385
+
377
386
  this.initialized = false;
378
387
  this.heightInitialized = false;
379
388
  this.element = false;
380
-
389
+
381
390
  this.dispatch("row-deleted", this);
382
391
  }
383
-
392
+
384
393
  detatchModules(){
385
394
  this.dispatch("row-deleting", this);
386
395
  }
387
-
396
+
388
397
  deleteCells(){
389
398
  var cellCount = this.cells.length;
390
-
399
+
391
400
  for(let i = 0; i < cellCount; i++){
392
401
  this.cells[0].delete();
393
402
  }
394
403
  }
395
-
404
+
396
405
  wipe(){
397
406
  this.detatchModules();
398
407
  this.deleteCells();
399
-
408
+
400
409
  if(this.element){
401
410
  while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
402
-
411
+
403
412
  if(this.element.parentNode){
404
413
  this.element.parentNode.removeChild(this.element);
405
414
  }
406
415
  }
407
-
416
+
408
417
  this.element = false;
409
418
  this.modules = {};
410
419
  }
411
-
420
+
412
421
  getGroup(){
413
422
  return this.modules.group || false;
414
423
  }
415
-
424
+
416
425
  //////////////// Object Generation /////////////////
417
426
  getComponent(){
418
427
  if(!this.component){
419
428
  this.component = new RowComponent(this);
420
429
  }
421
-
430
+
422
431
  return this.component;
423
432
  }
424
433
  }
@@ -0,0 +1,63 @@
1
+ import CoreFeature from '../CoreFeature.js';
2
+ import Helpers from './Helpers.js';
3
+
4
+ export default class Alert extends CoreFeature{
5
+ constructor(table){
6
+ super(table);
7
+
8
+ this.element = this._createAlertElement();
9
+ this.msgElement = this._createMsgElement();
10
+ this.type = null;
11
+
12
+ this.element.appendChild(this.msgElement);
13
+ }
14
+
15
+ _createAlertElement(){
16
+ var el = document.createElement("div");
17
+ el.classList.add("tabulator-alert");
18
+ return el;
19
+ }
20
+
21
+ _createMsgElement(){
22
+ var el = document.createElement("div");
23
+ el.classList.add("tabulator-alert-msg");
24
+ el.setAttribute("role", "alert");
25
+ return el;
26
+ }
27
+
28
+ _typeClass(){
29
+ return "tabulator-alert-state-" + this.type;
30
+ }
31
+
32
+ alert(content, type = "msg"){
33
+ if(content){
34
+ this.clear();
35
+
36
+ this.type = type;
37
+
38
+ while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);
39
+
40
+ this.msgElement.classList.add(this._typeClass());
41
+
42
+ if(typeof content === "function"){
43
+ content = content();
44
+ }
45
+
46
+ if(content instanceof HTMLElement){
47
+ this.msgElement.appendChild(content);
48
+ }else{
49
+ this.msgElement.innerHTML = content;
50
+ }
51
+
52
+ this.table.element.appendChild(this.element);
53
+ }
54
+ }
55
+
56
+ clear(){
57
+ if(this.element.parentNode){
58
+ this.element.parentNode.removeChild(this.element);
59
+ }
60
+
61
+ this.msgElement.classList.remove(this._typeClass());
62
+ }
63
+ }
@@ -12,14 +12,14 @@ export default class ComponentFunctionBinder{
12
12
  }
13
13
 
14
14
  if(this.bindings[type][funcName]){
15
- console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, hanlder)
15
+ console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler)
16
16
  }else{
17
17
  this.bindings[type][funcName] = handler;
18
18
  }
19
19
  }
20
20
 
21
21
  handle(type, component, name){
22
- if(this.bindings[type] && this.bindings[type][name]){
22
+ if(this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function'){
23
23
  return this.bindings[type][name].bind(null, component);
24
24
  }else{
25
25
  if(name !== "then" && typeof name === "string" && !name.startsWith("_")){
@@ -27,4 +27,4 @@ export default class ComponentFunctionBinder{
27
27
  }
28
28
  }
29
29
  }
30
- }
30
+ }