tabulator-tables 5.6.0 → 5.6.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 (64) hide show
  1. package/bower.json +1 -1
  2. package/dist/css/tabulator.css +5 -5
  3. package/dist/css/tabulator.css.map +1 -1
  4. package/dist/css/tabulator.min.css +1 -1
  5. package/dist/css/tabulator.min.css.map +1 -1
  6. package/dist/css/tabulator_bootstrap3.css +5 -5
  7. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  8. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  9. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  10. package/dist/css/tabulator_bootstrap4.css +5 -5
  11. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  12. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  13. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  14. package/dist/css/tabulator_bootstrap5.css +5 -5
  15. package/dist/css/tabulator_bootstrap5.css.map +1 -1
  16. package/dist/css/tabulator_bootstrap5.min.css +1 -1
  17. package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
  18. package/dist/css/tabulator_bulma.css +5 -5
  19. package/dist/css/tabulator_bulma.css.map +1 -1
  20. package/dist/css/tabulator_bulma.min.css +1 -1
  21. package/dist/css/tabulator_bulma.min.css.map +1 -1
  22. package/dist/css/tabulator_materialize.css +5 -5
  23. package/dist/css/tabulator_materialize.css.map +1 -1
  24. package/dist/css/tabulator_materialize.min.css +1 -1
  25. package/dist/css/tabulator_materialize.min.css.map +1 -1
  26. package/dist/css/tabulator_midnight.css +5 -5
  27. package/dist/css/tabulator_midnight.css.map +1 -1
  28. package/dist/css/tabulator_midnight.min.css +1 -1
  29. package/dist/css/tabulator_midnight.min.css.map +1 -1
  30. package/dist/css/tabulator_modern.css +5 -5
  31. package/dist/css/tabulator_modern.css.map +1 -1
  32. package/dist/css/tabulator_modern.min.css +1 -1
  33. package/dist/css/tabulator_modern.min.css.map +1 -1
  34. package/dist/css/tabulator_semanticui.css +5 -5
  35. package/dist/css/tabulator_semanticui.css.map +1 -1
  36. package/dist/css/tabulator_semanticui.min.css +1 -1
  37. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  38. package/dist/css/tabulator_simple.css +5 -5
  39. package/dist/css/tabulator_simple.css.map +1 -1
  40. package/dist/css/tabulator_simple.min.css +1 -1
  41. package/dist/css/tabulator_simple.min.css.map +1 -1
  42. package/dist/css/tabulator_site.css +5 -5
  43. package/dist/css/tabulator_site.css.map +1 -1
  44. package/dist/css/tabulator_site.min.css +1 -1
  45. package/dist/css/tabulator_site.min.css.map +1 -1
  46. package/dist/js/tabulator.js +83 -46
  47. package/dist/js/tabulator.js.map +1 -1
  48. package/dist/js/tabulator.min.js +2 -2
  49. package/dist/js/tabulator.min.js.map +1 -1
  50. package/dist/js/tabulator_esm.js +83 -46
  51. package/dist/js/tabulator_esm.js.map +1 -1
  52. package/dist/js/tabulator_esm.min.js +2 -2
  53. package/dist/js/tabulator_esm.min.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/js/core/RowManager.js +3 -5
  56. package/src/js/core/Tabulator.js +1 -1
  57. package/src/js/core/column/Column.js +4 -0
  58. package/src/js/modules/Edit/Edit.js +16 -6
  59. package/src/js/modules/Edit/defaults/editors/datetime.js +1 -1
  60. package/src/js/modules/Edit/defaults/editors/time.js +3 -1
  61. package/src/js/modules/FrozenColumns/FrozenColumns.js +1 -0
  62. package/src/js/modules/SelectRange/Range.js +18 -11
  63. package/src/js/modules/SelectRange/SelectRange.js +35 -20
  64. package/src/scss/tabulator.scss +7 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulator-tables",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -1109,13 +1109,11 @@ export default class RowManager extends CoreFeature{
1109
1109
 
1110
1110
  //redraw table
1111
1111
  redraw (force){
1112
- const resized = this.adjustTableSize();
1112
+ this.adjustTableSize();
1113
1113
  this.table.tableWidth = this.table.element.clientWidth;
1114
1114
 
1115
- if(!force){
1116
- if(resized) {
1117
- this.reRenderInPosition();
1118
- }
1115
+ if(!force){
1116
+ this.reRenderInPosition();
1119
1117
  this.scrollHorizontal(this.scrollLeft);
1120
1118
  }else{
1121
1119
  this.renderTable();
@@ -830,7 +830,7 @@ class Tabulator {
830
830
  this.options.height = isNaN(height) ? height : height + "px";
831
831
  this.element.style.height = this.options.height;
832
832
  this.rowManager.initializeRenderer();
833
- this.rowManager.redraw();
833
+ this.rowManager.redraw(true);
834
834
  }
835
835
 
836
836
  //////////////////// Event Bus ///////////////////
@@ -257,6 +257,10 @@ class Column extends CoreFeature{
257
257
  titleElement.focus();
258
258
  });
259
259
 
260
+ titleElement.addEventListener("mousedown", (e) => {
261
+ e.stopPropagation();
262
+ });
263
+
260
264
  titleElement.addEventListener("change", () => {
261
265
  def.title = titleElement.value;
262
266
  this.dispatchExternal("columnTitleChanged", this.getComponent());
@@ -596,8 +596,9 @@ class Edit extends Module{
596
596
  allowEdit = true,
597
597
  rendered = function(){},
598
598
  element = cell.getElement(),
599
+ editFinished = false,
599
600
  cellEditor, component, params;
600
-
601
+
601
602
  //prevent editing if another cell is refusing to leave focus (eg. validation fail)
602
603
 
603
604
  if(this.currentCell){
@@ -609,13 +610,15 @@ class Edit extends Module{
609
610
 
610
611
  //handle successful value change
611
612
  function success(value){
612
- if(self.currentCell === cell){
613
+ if(self.currentCell === cell && !editFinished){
613
614
  var valid = self.chain("edit-success", [cell, value], true, true);
614
-
615
+
615
616
  if(valid === true || self.table.options.validationMode === "highlight"){
617
+
618
+ editFinished = true;
619
+
616
620
  self.clearEditor();
617
621
 
618
-
619
622
  if(!cell.modules.edit){
620
623
  cell.modules.edit = {};
621
624
  }
@@ -627,12 +630,17 @@ class Edit extends Module{
627
630
  }
628
631
 
629
632
  cell.setValue(value, true);
630
-
633
+
631
634
  return valid === true;
632
635
  }else{
636
+ editFinished = true;
633
637
  self.invalidEdit = true;
634
638
  self.focusCellNoEvent(cell, true);
635
639
  rendered();
640
+
641
+ setTimeout(() => {
642
+ editFinished = false;
643
+ }, 10);
636
644
  return false;
637
645
  }
638
646
  }else{
@@ -642,7 +650,9 @@ class Edit extends Module{
642
650
 
643
651
  //handle aborted edit
644
652
  function cancel(){
645
- if(self.currentCell === cell){
653
+ // editFinished = true;
654
+
655
+ if(self.currentCell === cell && !editFinished){
646
656
  self.cancelEdit();
647
657
  }else{
648
658
  // console.warn("Edit Success Error - cannot call cancel on a cell that is no longer being edited");
@@ -37,7 +37,7 @@ export default function(cell, onRendered, success, cancel, editorParams){
37
37
  newDatetime = DT.fromFormat(String(cellValue), inputFormat);
38
38
  }
39
39
 
40
- cellValue = newDatetime.toFormat("yyyy-MM-dd") + "T" + newDatetime.toFormat("hh:mm");
40
+ cellValue = newDatetime.toFormat("yyyy-MM-dd") + "T" + newDatetime.toFormat("HH:mm");
41
41
  }else{
42
42
  console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");
43
43
  }
@@ -37,12 +37,14 @@ export default function(cell, onRendered, success, cancel, editorParams){
37
37
  newDatetime = DT.fromFormat(String(cellValue), inputFormat);
38
38
  }
39
39
 
40
- cellValue = newDatetime.toFormat("hh:mm");
40
+ cellValue = newDatetime.toFormat("HH:mm");
41
41
 
42
42
  }else{
43
43
  console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");
44
44
  }
45
45
  }
46
+
47
+ console.log("val", cellValue);
46
48
 
47
49
  input.value = cellValue;
48
50
 
@@ -34,6 +34,7 @@ class FrozenColumns extends Module{
34
34
  this.subscribe("column-deleted", this.reinitializeColumns.bind(this));
35
35
  this.subscribe("column-hide", this.reinitializeColumns.bind(this));
36
36
  this.subscribe("column-show", this.reinitializeColumns.bind(this));
37
+ this.subscribe("columns-loaded", this.reinitializeColumns.bind(this));
37
38
 
38
39
  this.subscribe("table-redraw", this.layout.bind(this));
39
40
  this.subscribe("layout-refreshing", this.blockLayout.bind(this));
@@ -22,6 +22,13 @@ class Range extends CoreFeature{
22
22
  this.table = table;
23
23
  this.start = {row:0, col:0};
24
24
  this.end = {row:0, col:0};
25
+
26
+ if(this.rangeManager.rowHeader){
27
+ this.left = 1;
28
+ this.right = 1;
29
+ this.start.col = 1;
30
+ this.end.col = 1;
31
+ }
25
32
 
26
33
  this.initElement();
27
34
 
@@ -81,14 +88,14 @@ class Range extends CoreFeature{
81
88
 
82
89
  if (element.type === "column") {
83
90
  if(this.rangeManager.columnSelection){
84
- this.setStart(0, element.getPosition() - 2);
91
+ this.setStart(0, element.getPosition() - 1);
85
92
  }
86
93
  }else{
87
94
  row = element.row.position - 1;
88
- col = element.column.getPosition() - 2;
95
+ col = element.column.getPosition() - 1;
89
96
 
90
97
  if (element.column === this.rangeManager.rowHeader) {
91
- this.setStart(row, 0);
98
+ this.setStart(row, 1);
92
99
  } else {
93
100
  this.setStart(row, col);
94
101
  }
@@ -102,18 +109,18 @@ class Range extends CoreFeature{
102
109
  if (element.type === "column") {
103
110
  if(this.rangeManager.columnSelection){
104
111
  if (this.rangeManager.selecting === "column") {
105
- this.setEnd(rowsCount - 1, element.getPosition() - 2);
112
+ this.setEnd(rowsCount - 1, element.getPosition() - 1);
106
113
  } else if (this.rangeManager.selecting === "cell") {
107
- this.setEnd(0, element.getPosition() - 2);
114
+ this.setEnd(0, element.getPosition() - 1);
108
115
  }
109
116
  }
110
117
  }else{
111
118
  row = element.row.position - 1;
112
- col = element.column.getPosition() - 2;
119
+ col = element.column.getPosition() - 1;
113
120
  isRowHeader = element.column === this.rangeManager.rowHeader;
114
121
 
115
122
  if (this.rangeManager.selecting === "row") {
116
- this.setEnd(row, this._getTableColumns().length - 2);
123
+ this.setEnd(row, this._getTableColumns().length - 1);
117
124
  } else if (this.rangeManager.selecting !== "row" && isRowHeader) {
118
125
  this.setEnd(row, 0);
119
126
  } else if (this.rangeManager.selecting === "column") {
@@ -195,11 +202,11 @@ class Range extends CoreFeature{
195
202
  }
196
203
 
197
204
  atTopLeft(cell) {
198
- return cell.row.position - 1 === this.top && cell.column.getPosition() - 2 === this.left;
205
+ return cell.row.position - 1 === this.top && cell.column.getPosition() - 1 === this.left;
199
206
  }
200
207
 
201
208
  atBottomRight(cell) {
202
- return cell.row.position - 1 === this.bottom && cell.column.getPosition() - 2 === this.right;
209
+ return cell.row.position - 1 === this.bottom && cell.column.getPosition() - 1 === this.right;
203
210
  }
204
211
 
205
212
  occupies(cell) {
@@ -211,7 +218,7 @@ class Range extends CoreFeature{
211
218
  }
212
219
 
213
220
  occupiesColumn(col) {
214
- return this.left <= col.getPosition() - 2 && col.getPosition() - 2 <= this.right;
221
+ return this.left <= col.getPosition() - 1 && col.getPosition() - 1 <= this.right;
215
222
  }
216
223
 
217
224
  overlaps(left, top, right, bottom) {
@@ -280,7 +287,7 @@ class Range extends CoreFeature{
280
287
  }
281
288
 
282
289
  getColumns() {
283
- return this._getTableColumns().slice(this.left + 1, this.right + 2);
290
+ return this._getTableColumns().slice(this.left, this.right + 1);
284
291
  }
285
292
 
286
293
  clearValues(){
@@ -123,7 +123,7 @@ class SelectRange extends Module {
123
123
 
124
124
  initializeColumn(column) {
125
125
  if(this.columnSelection && column.definition.headerSort && this.options("headerSortClickElement") !== "icon"){
126
- console.warn("Using column headerSort with selectableRangeColumns option may result in unpredictable behavior");
126
+ console.warn("Using column headerSort with selectableRangeColumns option may result in unpredictable behavior. Consider using headerSortClickElement: 'icon'.");
127
127
  }
128
128
 
129
129
  if (column.modules.edit) {
@@ -422,7 +422,7 @@ class SelectRange extends Module {
422
422
  nextCol = Math.max(nextCol - 1, 0);
423
423
  break;
424
424
  case "right":
425
- nextCol = Math.min(nextCol + 1, this.getTableColumns().length - 2);
425
+ nextCol = Math.min(nextCol + 1, this.getTableColumns().length - 1);
426
426
  break;
427
427
  case "up":
428
428
  nextRow = Math.max(nextRow - 1, 0);
@@ -516,13 +516,14 @@ class SelectRange extends Module {
516
516
  findJumpCellLeft(rowPos, colPos){
517
517
  var row = this.getRowByRangePos(rowPos),
518
518
  cells = row.cells.filter((cell) => cell.column.visible),
519
- isStartingCellEmpty = !cells[colPos + 1].getValue(),
519
+ isStartingCellEmpty = !cells[colPos].getValue(),
520
520
  isLeftOfStartingCellEmpty = cells[colPos] ? !cells[colPos].getValue() : false,
521
521
  jumpCol = colPos,
522
- nextCell = this.findJumpCell(cells.slice(0, colPos), true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
522
+ targetCells = this.rowHeader ? cells.slice(1, colPos) : cells.slice(0, colPos),
523
+ nextCell = this.findJumpCell(targetCells, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
523
524
 
524
525
  if(nextCell){
525
- jumpCol = nextCell.column.getPosition() - 2;
526
+ jumpCol = nextCell.column.getPosition() - 1;
526
527
  }
527
528
 
528
529
  return jumpCol;
@@ -531,13 +532,13 @@ class SelectRange extends Module {
531
532
  findJumpCellRight(rowPos, colPos){
532
533
  var row = this.getRowByRangePos(rowPos),
533
534
  cells = row.cells.filter((cell) => cell.column.visible),
534
- isStartingCellEmpty = !cells[colPos + 1].getValue(),
535
- isRightOfStartingCellEmpty = cells[colPos + 2] ? !cells[colPos + 2].getValue() : false,
535
+ isStartingCellEmpty = !cells[colPos].getValue(),
536
+ isRightOfStartingCellEmpty = cells[colPos + 1] ? !cells[colPos + 1].getValue() : false,
536
537
  jumpCol = colPos,
537
- nextCell = this.findJumpCell(cells.slice(colPos + 2, cells.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
538
+ nextCell = this.findJumpCell(cells.slice(colPos + 1, cells.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
538
539
 
539
540
  if(nextCell){
540
- jumpCol = nextCell.column.getPosition() - 2;
541
+ jumpCol = nextCell.column.getPosition() - 1;
541
542
  }
542
543
 
543
544
  return jumpCol;
@@ -588,8 +589,13 @@ class SelectRange extends Module {
588
589
  range = this.resetRanges();
589
590
  this.selecting = "all";
590
591
 
591
- const topLeftCell = this.getCell(0, 0);
592
- const bottomRightCell = this.getCell(-1, -1);
592
+ var topLeftCell, bottomRightCell = this.getCell(-1, -1);
593
+
594
+ if(this.rowHeader){
595
+ topLeftCell = this.getCell(0, 1);
596
+ }else{
597
+ topLeftCell = this.getCell(0, 0);
598
+ }
593
599
 
594
600
  range.setBounds(topLeftCell, bottomRightCell);
595
601
  return;
@@ -613,9 +619,8 @@ class SelectRange extends Module {
613
619
 
614
620
  autoScroll(range, row, column) {
615
621
  var tableHolder = this.table.rowManager.element,
616
- rowHeader = this.rowHeader.getElement(),
617
- rect, view, withinHorizontalView, withinVerticalView;
618
-
622
+ rowHeader, rect, view, withinHorizontalView, withinVerticalView;
623
+
619
624
  if (typeof row === 'undefined') {
620
625
  row = this.getRowByRangePos(range.end.row).getElement();
621
626
  }
@@ -623,6 +628,10 @@ class SelectRange extends Module {
623
628
  if (typeof column === 'undefined') {
624
629
  column = this.getColumnByRangePos(range.end.col).getElement();
625
630
  }
631
+
632
+ if (this.rowHeader) {
633
+ rowHeader = this.rowHeader.getElement();
634
+ }
626
635
 
627
636
  rect = {
628
637
  left: column.offsetLeft,
@@ -632,11 +641,15 @@ class SelectRange extends Module {
632
641
  };
633
642
 
634
643
  view = {
635
- left: tableHolder.scrollLeft + rowHeader.offsetWidth,
644
+ left: tableHolder.scrollLeft,
636
645
  right: Math.ceil(tableHolder.scrollLeft + tableHolder.clientWidth),
637
646
  top: tableHolder.scrollTop,
638
647
  bottom: tableHolder.scrollTop + tableHolder.offsetHeight - this.table.rowManager.scrollbarWidth,
639
648
  };
649
+
650
+ if (rowHeader) {
651
+ view.left += rowHeader.offsetWidth;
652
+ }
640
653
 
641
654
  withinHorizontalView = view.left < rect.left && rect.left < view.right && view.left < rect.right && rect.right < view.right;
642
655
 
@@ -644,7 +657,10 @@ class SelectRange extends Module {
644
657
 
645
658
  if (!withinHorizontalView) {
646
659
  if (rect.left < view.left) {
647
- tableHolder.scrollLeft = rect.left - rowHeader.offsetWidth;
660
+ tableHolder.scrollLeft = rect.left;
661
+ if (rowHeader) {
662
+ tableHolder.scrollLeft -= rowHeader.offsetWidth;
663
+ }
648
664
  } else if (rect.right > view.right) {
649
665
  tableHolder.scrollLeft = rect.right - tableHolder.clientWidth;
650
666
  }
@@ -763,8 +779,7 @@ class SelectRange extends Module {
763
779
  var row;
764
780
 
765
781
  if (colIdx < 0) {
766
- colIdx = this.getTableColumns().length + colIdx - 1;
767
-
782
+ colIdx = this.getTableColumns().length + colIdx;
768
783
  if (colIdx < 0) {
769
784
  return null;
770
785
  }
@@ -776,7 +791,7 @@ class SelectRange extends Module {
776
791
 
777
792
  row = this.table.rowManager.getRowFromPosition(rowIdx + 1);
778
793
 
779
- return row ? row.getCells(false, true).filter((cell) => cell.column.visible)[colIdx + 1] : null;
794
+ return row ? row.getCells(false, true).filter((cell) => cell.column.visible)[colIdx] : null;
780
795
  }
781
796
 
782
797
 
@@ -789,7 +804,7 @@ class SelectRange extends Module {
789
804
  }
790
805
 
791
806
  getColumnByRangePos(pos) {
792
- return this.getTableColumns()[pos + 1];
807
+ return this.getTableColumns()[pos];
793
808
  }
794
809
 
795
810
  getTableRows() {
@@ -776,6 +776,13 @@ $rangeHeaderTextHighlightBackground: #000000 !default; //header text color when
776
776
  }
777
777
 
778
778
 
779
+ &.tabulator-range-selected{
780
+ .tabulator-cell.tabulator-range-row-header{
781
+ background-color: $rangeHeaderSelectedBackground;
782
+ color: $rangeHeaderSelectedTextColor;
783
+ }
784
+ }
785
+
779
786
  //row resize handles
780
787
  .tabulator-row-resize-handle{
781
788
  position:absolute;
@@ -904,13 +911,6 @@ $rangeHeaderTextHighlightBackground: #000000 !default; //header text color when
904
911
  }
905
912
  }
906
913
 
907
- &.tabulator-range-row-header{
908
- &.tabulator-range-selected{
909
- background-color: $rangeHeaderSelectedBackground;
910
- color: $rangeHeaderSelectedTextColor;
911
- }
912
- }
913
-
914
914
  &.tabulator-range-selected:not(.tabulator-range-only-cell-selected):not(.tabulator-range-row-header){
915
915
  background-color: $rowSelectedBackground;
916
916
  }