tabulator-tables 6.2.0 → 6.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.
@@ -15,7 +15,7 @@ jobs:
15
15
 
16
16
  - name: Get specific changed files in dist
17
17
  id: changed-files-specific
18
- uses: tj-actions/changed-files@v17.3
18
+ uses: tj-actions/changed-files@v41
19
19
  with:
20
20
  files: |
21
21
  dist
@@ -19,7 +19,7 @@ jobs:
19
19
  - name: Set up Node.js
20
20
  uses: actions/setup-node@v1
21
21
  with:
22
- node-version: 14
22
+ node-version: 18
23
23
 
24
24
  - name: Install dependencies
25
25
  run: npm ci
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tabulator",
3
3
  "main": "dist/js/tabulator.js",
4
- "version": "6.2.0",
4
+ "version": "6.2.1",
5
5
  "description": "Interactive table generation JavaScript library",
6
6
  "keywords": [
7
7
  "table",
@@ -1,4 +1,4 @@
1
- /* Tabulator v6.2.0 (c) Oliver Folkerd 2024 */
1
+ /* Tabulator v6.2.1 (c) Oliver Folkerd 2024 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -6954,7 +6954,8 @@
6954
6954
  }
6955
6955
 
6956
6956
  //move menu to start on bottom edge if it is too close to the edge of the screen
6957
- if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) {
6957
+ let offsetHeight = Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0);
6958
+ if((y + this.element.offsetHeight) > offsetHeight) {
6958
6959
  if(parentEl){
6959
6960
  switch(position){
6960
6961
  case "bottom":
@@ -6966,7 +6967,7 @@
6966
6967
  }
6967
6968
 
6968
6969
  }else {
6969
- this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px";
6970
+ this.element.style.height = offsetHeight + "px";
6970
6971
  }
6971
6972
  }
6972
6973
  }
@@ -20808,6 +20809,13 @@
20808
20809
  headerElement = this.table.columnManager.getContentsElement(),
20809
20810
  headersElement = this.table.columnManager.getHeadersElement();
20810
20811
 
20812
+ //Prevent moving columns when range selection is active
20813
+ if(this.table.modules.selectRange && this.table.modules.selectRange.columnSelection){
20814
+ if(this.table.modules.selectRange.mousedown && this.table.modules.selectRange.selecting === "column"){
20815
+ return;
20816
+ }
20817
+ }
20818
+
20811
20819
  this.moving = column;
20812
20820
  this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;
20813
20821
 
@@ -20837,6 +20845,8 @@
20837
20845
  }
20838
20846
 
20839
20847
  this.moveHover(e);
20848
+
20849
+ this.dispatch("column-moving", e, this.moving);
20840
20850
  }
20841
20851
 
20842
20852
  _bindMouseMove(){
@@ -20893,7 +20903,7 @@
20893
20903
  if(this.toCol){
20894
20904
  this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
20895
20905
  }
20896
-
20906
+
20897
20907
  this.moving = false;
20898
20908
  this.toCol = false;
20899
20909
  this.toColAfter = false;
@@ -25598,7 +25608,7 @@
25598
25608
  }
25599
25609
 
25600
25610
  getCells() {
25601
- return this._range.getCells(true);
25611
+ return this._range.getCells(true, true);
25602
25612
  }
25603
25613
 
25604
25614
  getStructuredCells() {
@@ -26316,6 +26326,8 @@
26316
26326
  this.subscribe("column-mousedown", this.handleColumnMouseDown.bind(this));
26317
26327
  this.subscribe("column-mousemove", this.handleColumnMouseMove.bind(this));
26318
26328
  this.subscribe("column-resized", this.handleColumnResized.bind(this));
26329
+ this.subscribe("column-moving", this.handleColumnMoving.bind(this));
26330
+ this.subscribe("column-moved", this.handleColumnMoved.bind(this));
26319
26331
  this.subscribe("column-width", this.layoutChange.bind(this));
26320
26332
  this.subscribe("column-height", this.layoutChange.bind(this));
26321
26333
  this.subscribe("column-resized", this.layoutChange.bind(this));
@@ -26469,6 +26481,8 @@
26469
26481
 
26470
26482
  initializeFocus(cell){
26471
26483
  var range;
26484
+
26485
+ this.restoreFocus();
26472
26486
 
26473
26487
  try{
26474
26488
  if (document.selection) { // IE
@@ -26518,10 +26532,26 @@
26518
26532
  });
26519
26533
  }
26520
26534
 
26535
+ handleColumnMoving(_event, column) {
26536
+ this.resetRanges().setBounds(column);
26537
+ this.overlay.style.visibility = "hidden";
26538
+ }
26539
+
26540
+ handleColumnMoved(from, _to, _after) {
26541
+ this.activeRange.setBounds(from);
26542
+ this.layoutElement();
26543
+ }
26544
+
26521
26545
  handleColumnMouseDown(event, column) {
26522
26546
  if (event.button === 2 && (this.selecting === "column" || this.selecting === "all") && this.activeRange.occupiesColumn(column)) {
26523
26547
  return;
26524
26548
  }
26549
+
26550
+ //If columns are movable, allow dragging columns only if they are not
26551
+ //selected. Dragging selected columns should move the columns instead.
26552
+ if(this.table.options.movableColumns && this.selecting === "column" && this.activeRange.occupiesColumn(column)){
26553
+ return;
26554
+ }
26525
26555
 
26526
26556
  this.mousedown = true;
26527
26557
 
@@ -26596,15 +26626,13 @@
26596
26626
  ///////////////////////////////////
26597
26627
 
26598
26628
  keyNavigate(dir, e){
26599
- if(this.navigate(false, false, dir)){
26600
- e.preventDefault();
26601
- }
26629
+ if(this.navigate(false, false, dir));
26630
+ e.preventDefault();
26602
26631
  }
26603
26632
 
26604
26633
  keyNavigateRange(e, dir, jump, expand){
26605
- if(this.navigate(jump, expand, dir)){
26606
- e.preventDefault();
26607
- }
26634
+ if(this.navigate(jump, expand, dir));
26635
+ e.preventDefault();
26608
26636
  }
26609
26637
 
26610
26638
  navigate(jump, expand, dir) {
@@ -26671,6 +26699,10 @@
26671
26699
  break;
26672
26700
  }
26673
26701
  }
26702
+
26703
+ if(this.rowHeader && nextCol === 0) {
26704
+ nextCol = 1;
26705
+ }
26674
26706
 
26675
26707
  moved = nextCol !== rangeEdge.col || nextRow !== rangeEdge.row;
26676
26708
 
@@ -26717,100 +26749,108 @@
26717
26749
  this.layoutElement();
26718
26750
  }
26719
26751
 
26720
- findJumpCell(cells, reverse, emptyStart, emptySide){
26721
- var nextCell;
26722
-
26752
+ findJumpRow(column, rows, reverse, emptyStart, emptySide){
26723
26753
  if(reverse){
26724
- cells = cells.reverse();
26754
+ rows = rows.reverse();
26725
26755
  }
26726
-
26727
- for(let currentCell of cells){
26728
- let currentValue = currentCell.getValue();
26756
+
26757
+ return this.findJumpItem(emptyStart, emptySide, rows, function(row){return row.getData()[column.getField()];});
26758
+ }
26759
+
26760
+ findJumpCol(row, columns, reverse, emptyStart, emptySide){
26761
+ if(reverse){
26762
+ columns = columns.reverse();
26763
+ }
26764
+
26765
+ return this.findJumpItem(emptyStart, emptySide, columns, function(column){return row.getData()[column.getField()];});
26766
+ }
26767
+
26768
+ findJumpItem(emptyStart, emptySide, items, valueResolver){
26769
+ var nextItem;
26770
+
26771
+ for(let currentItem of items){
26772
+ let currentValue = valueResolver(currentItem);
26729
26773
 
26730
26774
  if(emptyStart){
26731
- nextCell = currentCell;
26775
+ nextItem = currentItem;
26732
26776
  if(currentValue){
26733
26777
  break;
26734
26778
  }
26735
26779
  }else {
26736
26780
  if(emptySide){
26737
- nextCell = currentCell;
26781
+ nextItem = currentItem;
26738
26782
 
26739
26783
  if(currentValue){
26740
26784
  break;
26741
26785
  }
26742
26786
  }else {
26743
26787
  if(currentValue){
26744
- nextCell = currentCell;
26788
+ nextItem = currentItem;
26745
26789
  }else {
26746
26790
  break;
26747
26791
  }
26748
26792
  }
26749
26793
  }
26750
26794
  }
26751
-
26752
- return nextCell;
26795
+
26796
+ return nextItem;
26753
26797
  }
26754
-
26798
+
26755
26799
  findJumpCellLeft(rowPos, colPos){
26756
26800
  var row = this.getRowByRangePos(rowPos),
26757
- cells = row.cells.filter((cell) => cell.column.visible),
26758
- isStartingCellEmpty = !cells[colPos].getValue(),
26759
- isLeftOfStartingCellEmpty = cells[colPos] ? !cells[colPos].getValue() : false,
26760
- jumpCol = colPos,
26761
- targetCells = this.rowHeader ? cells.slice(1, colPos) : cells.slice(0, colPos),
26762
- nextCell = this.findJumpCell(targetCells, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
26801
+ columns = this.getTableColumns(),
26802
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
26803
+ isLeftOfStartingCellEmpty = columns[colPos - 1] ? this.isEmpty(row.getData()[columns[colPos - 1].getField()]) : false,
26804
+ targetCols = this.rowHeader ? columns.slice(1, colPos) : columns.slice(0, colPos),
26805
+ jumpCol = this.findJumpCol(row, targetCols, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
26763
26806
 
26764
- if(nextCell){
26765
- jumpCol = nextCell.column.getPosition() - 1;
26807
+ if(jumpCol){
26808
+ return jumpCol.getPosition() - 1;
26766
26809
  }
26767
26810
 
26768
- return jumpCol;
26811
+ return colPos;
26769
26812
  }
26770
26813
 
26771
26814
  findJumpCellRight(rowPos, colPos){
26772
26815
  var row = this.getRowByRangePos(rowPos),
26773
- cells = row.cells.filter((cell) => cell.column.visible),
26774
- isStartingCellEmpty = !cells[colPos].getValue(),
26775
- isRightOfStartingCellEmpty = cells[colPos + 1] ? !cells[colPos + 1].getValue() : false,
26776
- jumpCol = colPos,
26777
- nextCell = this.findJumpCell(cells.slice(colPos + 1, cells.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
26816
+ columns = this.getTableColumns(),
26817
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
26818
+ isRightOfStartingCellEmpty = columns[colPos + 1] ? this.isEmpty(row.getData()[columns[colPos + 1].getField()]) : false,
26819
+ jumpCol = this.findJumpCol(row, columns.slice(colPos + 1, columns.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
26778
26820
 
26779
- if(nextCell){
26780
- jumpCol = nextCell.column.getPosition() - 1;
26821
+ if(jumpCol){
26822
+ return jumpCol.getPosition() - 1;
26781
26823
  }
26782
26824
 
26783
- return jumpCol;
26825
+ return colPos;
26784
26826
  }
26785
26827
 
26786
26828
  findJumpCellUp(rowPos, colPos) {
26787
26829
  var column = this.getColumnByRangePos(colPos),
26788
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
26789
- isStartingCellEmpty = !cells[rowPos].getValue(),
26790
- isTopOfStartingCellEmpty = cells[rowPos - 1] ? !cells[rowPos - 1].getValue() : false,
26791
- jumpRow = rowPos,
26792
- nextCell = this.findJumpCell(cells.slice(0, jumpRow), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
26830
+ rows = this.getTableRows(),
26831
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
26832
+ isTopOfStartingCellEmpty = rows[rowPos - 1] ? this.isEmpty(rows[rowPos - 1].getData()[column.getField()]) : false,
26833
+ jumpRow = this.findJumpRow(column, rows.slice(0, rowPos), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
26793
26834
 
26794
- if(nextCell){
26795
- jumpRow = nextCell.row.position - 1;
26835
+ if(jumpRow){
26836
+ return jumpRow.position - 1;
26796
26837
  }
26797
26838
 
26798
- return jumpRow;
26839
+ return rowPos;
26799
26840
  }
26800
26841
 
26801
26842
  findJumpCellDown(rowPos, colPos) {
26802
26843
  var column = this.getColumnByRangePos(colPos),
26803
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
26804
- isStartingCellEmpty = !cells[rowPos].getValue(),
26805
- isBottomOfStartingCellEmpty = cells[rowPos + 1] ? !cells[rowPos + 1].getValue() : false,
26806
- jumpRow = rowPos,
26807
- nextCell = this.findJumpCell(cells.slice(jumpRow + 1, cells.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
26844
+ rows = this.getTableRows(),
26845
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
26846
+ isBottomOfStartingCellEmpty = rows[rowPos + 1] ? this.isEmpty(rows[rowPos + 1].getData()[column.getField()]) : false,
26847
+ jumpRow = this.findJumpRow(column, rows.slice(rowPos + 1, rows.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
26808
26848
 
26809
- if(nextCell){
26810
- jumpRow = nextCell.row.position - 1;
26849
+ if(jumpRow){
26850
+ return jumpRow.position - 1;
26811
26851
  }
26812
26852
 
26813
- return jumpRow;
26853
+ return rowPos;
26814
26854
  }
26815
26855
 
26816
26856
  ///////////////////////////////////
@@ -27111,6 +27151,10 @@
27111
27151
  selectedColumns(component) {
27112
27152
  return component ? this.activeRange.getColumns().map((col) => col.getComponent()) : this.activeRange.getColumns();
27113
27153
  }
27154
+
27155
+ isEmpty(value) {
27156
+ return value === null || value === undefined || value === "";
27157
+ }
27114
27158
  }
27115
27159
 
27116
27160
  //sort numbers