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.
@@ -1,4 +1,4 @@
1
- /* Tabulator v6.2.0 (c) Oliver Folkerd 2024 */
1
+ /* Tabulator v6.2.1 (c) Oliver Folkerd 2024 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -401,7 +401,8 @@ let Popup$1 = class Popup extends CoreFeature{
401
401
  }
402
402
 
403
403
  //move menu to start on bottom edge if it is too close to the edge of the screen
404
- if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) {
404
+ let offsetHeight = Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0);
405
+ if((y + this.element.offsetHeight) > offsetHeight) {
405
406
  if(parentEl){
406
407
  switch(position){
407
408
  case "bottom":
@@ -413,7 +414,7 @@ let Popup$1 = class Popup extends CoreFeature{
413
414
  }
414
415
 
415
416
  }else {
416
- this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px";
417
+ this.element.style.height = offsetHeight + "px";
417
418
  }
418
419
  }
419
420
  }
@@ -14598,6 +14599,13 @@ class MoveColumns extends Module{
14598
14599
  headerElement = this.table.columnManager.getContentsElement(),
14599
14600
  headersElement = this.table.columnManager.getHeadersElement();
14600
14601
 
14602
+ //Prevent moving columns when range selection is active
14603
+ if(this.table.modules.selectRange && this.table.modules.selectRange.columnSelection){
14604
+ if(this.table.modules.selectRange.mousedown && this.table.modules.selectRange.selecting === "column"){
14605
+ return;
14606
+ }
14607
+ }
14608
+
14601
14609
  this.moving = column;
14602
14610
  this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;
14603
14611
 
@@ -14627,6 +14635,8 @@ class MoveColumns extends Module{
14627
14635
  }
14628
14636
 
14629
14637
  this.moveHover(e);
14638
+
14639
+ this.dispatch("column-moving", e, this.moving);
14630
14640
  }
14631
14641
 
14632
14642
  _bindMouseMove(){
@@ -14683,7 +14693,7 @@ class MoveColumns extends Module{
14683
14693
  if(this.toCol){
14684
14694
  this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
14685
14695
  }
14686
-
14696
+
14687
14697
  this.moving = false;
14688
14698
  this.toCol = false;
14689
14699
  this.toColAfter = false;
@@ -19388,7 +19398,7 @@ class RangeComponent {
19388
19398
  }
19389
19399
 
19390
19400
  getCells() {
19391
- return this._range.getCells(true);
19401
+ return this._range.getCells(true, true);
19392
19402
  }
19393
19403
 
19394
19404
  getStructuredCells() {
@@ -20106,6 +20116,8 @@ class SelectRange extends Module {
20106
20116
  this.subscribe("column-mousedown", this.handleColumnMouseDown.bind(this));
20107
20117
  this.subscribe("column-mousemove", this.handleColumnMouseMove.bind(this));
20108
20118
  this.subscribe("column-resized", this.handleColumnResized.bind(this));
20119
+ this.subscribe("column-moving", this.handleColumnMoving.bind(this));
20120
+ this.subscribe("column-moved", this.handleColumnMoved.bind(this));
20109
20121
  this.subscribe("column-width", this.layoutChange.bind(this));
20110
20122
  this.subscribe("column-height", this.layoutChange.bind(this));
20111
20123
  this.subscribe("column-resized", this.layoutChange.bind(this));
@@ -20259,6 +20271,8 @@ class SelectRange extends Module {
20259
20271
 
20260
20272
  initializeFocus(cell){
20261
20273
  var range;
20274
+
20275
+ this.restoreFocus();
20262
20276
 
20263
20277
  try{
20264
20278
  if (document.selection) { // IE
@@ -20308,10 +20322,26 @@ class SelectRange extends Module {
20308
20322
  });
20309
20323
  }
20310
20324
 
20325
+ handleColumnMoving(_event, column) {
20326
+ this.resetRanges().setBounds(column);
20327
+ this.overlay.style.visibility = "hidden";
20328
+ }
20329
+
20330
+ handleColumnMoved(from, _to, _after) {
20331
+ this.activeRange.setBounds(from);
20332
+ this.layoutElement();
20333
+ }
20334
+
20311
20335
  handleColumnMouseDown(event, column) {
20312
20336
  if (event.button === 2 && (this.selecting === "column" || this.selecting === "all") && this.activeRange.occupiesColumn(column)) {
20313
20337
  return;
20314
20338
  }
20339
+
20340
+ //If columns are movable, allow dragging columns only if they are not
20341
+ //selected. Dragging selected columns should move the columns instead.
20342
+ if(this.table.options.movableColumns && this.selecting === "column" && this.activeRange.occupiesColumn(column)){
20343
+ return;
20344
+ }
20315
20345
 
20316
20346
  this.mousedown = true;
20317
20347
 
@@ -20386,15 +20416,13 @@ class SelectRange extends Module {
20386
20416
  ///////////////////////////////////
20387
20417
 
20388
20418
  keyNavigate(dir, e){
20389
- if(this.navigate(false, false, dir)){
20390
- e.preventDefault();
20391
- }
20419
+ if(this.navigate(false, false, dir));
20420
+ e.preventDefault();
20392
20421
  }
20393
20422
 
20394
20423
  keyNavigateRange(e, dir, jump, expand){
20395
- if(this.navigate(jump, expand, dir)){
20396
- e.preventDefault();
20397
- }
20424
+ if(this.navigate(jump, expand, dir));
20425
+ e.preventDefault();
20398
20426
  }
20399
20427
 
20400
20428
  navigate(jump, expand, dir) {
@@ -20461,6 +20489,10 @@ class SelectRange extends Module {
20461
20489
  break;
20462
20490
  }
20463
20491
  }
20492
+
20493
+ if(this.rowHeader && nextCol === 0) {
20494
+ nextCol = 1;
20495
+ }
20464
20496
 
20465
20497
  moved = nextCol !== rangeEdge.col || nextRow !== rangeEdge.row;
20466
20498
 
@@ -20507,100 +20539,108 @@ class SelectRange extends Module {
20507
20539
  this.layoutElement();
20508
20540
  }
20509
20541
 
20510
- findJumpCell(cells, reverse, emptyStart, emptySide){
20511
- var nextCell;
20512
-
20542
+ findJumpRow(column, rows, reverse, emptyStart, emptySide){
20513
20543
  if(reverse){
20514
- cells = cells.reverse();
20544
+ rows = rows.reverse();
20515
20545
  }
20516
-
20517
- for(let currentCell of cells){
20518
- let currentValue = currentCell.getValue();
20546
+
20547
+ return this.findJumpItem(emptyStart, emptySide, rows, function(row){return row.getData()[column.getField()];});
20548
+ }
20549
+
20550
+ findJumpCol(row, columns, reverse, emptyStart, emptySide){
20551
+ if(reverse){
20552
+ columns = columns.reverse();
20553
+ }
20554
+
20555
+ return this.findJumpItem(emptyStart, emptySide, columns, function(column){return row.getData()[column.getField()];});
20556
+ }
20557
+
20558
+ findJumpItem(emptyStart, emptySide, items, valueResolver){
20559
+ var nextItem;
20560
+
20561
+ for(let currentItem of items){
20562
+ let currentValue = valueResolver(currentItem);
20519
20563
 
20520
20564
  if(emptyStart){
20521
- nextCell = currentCell;
20565
+ nextItem = currentItem;
20522
20566
  if(currentValue){
20523
20567
  break;
20524
20568
  }
20525
20569
  }else {
20526
20570
  if(emptySide){
20527
- nextCell = currentCell;
20571
+ nextItem = currentItem;
20528
20572
 
20529
20573
  if(currentValue){
20530
20574
  break;
20531
20575
  }
20532
20576
  }else {
20533
20577
  if(currentValue){
20534
- nextCell = currentCell;
20578
+ nextItem = currentItem;
20535
20579
  }else {
20536
20580
  break;
20537
20581
  }
20538
20582
  }
20539
20583
  }
20540
20584
  }
20541
-
20542
- return nextCell;
20585
+
20586
+ return nextItem;
20543
20587
  }
20544
-
20588
+
20545
20589
  findJumpCellLeft(rowPos, colPos){
20546
20590
  var row = this.getRowByRangePos(rowPos),
20547
- cells = row.cells.filter((cell) => cell.column.visible),
20548
- isStartingCellEmpty = !cells[colPos].getValue(),
20549
- isLeftOfStartingCellEmpty = cells[colPos] ? !cells[colPos].getValue() : false,
20550
- jumpCol = colPos,
20551
- targetCells = this.rowHeader ? cells.slice(1, colPos) : cells.slice(0, colPos),
20552
- nextCell = this.findJumpCell(targetCells, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
20591
+ columns = this.getTableColumns(),
20592
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
20593
+ isLeftOfStartingCellEmpty = columns[colPos - 1] ? this.isEmpty(row.getData()[columns[colPos - 1].getField()]) : false,
20594
+ targetCols = this.rowHeader ? columns.slice(1, colPos) : columns.slice(0, colPos),
20595
+ jumpCol = this.findJumpCol(row, targetCols, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
20553
20596
 
20554
- if(nextCell){
20555
- jumpCol = nextCell.column.getPosition() - 1;
20597
+ if(jumpCol){
20598
+ return jumpCol.getPosition() - 1;
20556
20599
  }
20557
20600
 
20558
- return jumpCol;
20601
+ return colPos;
20559
20602
  }
20560
20603
 
20561
20604
  findJumpCellRight(rowPos, colPos){
20562
20605
  var row = this.getRowByRangePos(rowPos),
20563
- cells = row.cells.filter((cell) => cell.column.visible),
20564
- isStartingCellEmpty = !cells[colPos].getValue(),
20565
- isRightOfStartingCellEmpty = cells[colPos + 1] ? !cells[colPos + 1].getValue() : false,
20566
- jumpCol = colPos,
20567
- nextCell = this.findJumpCell(cells.slice(colPos + 1, cells.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
20606
+ columns = this.getTableColumns(),
20607
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
20608
+ isRightOfStartingCellEmpty = columns[colPos + 1] ? this.isEmpty(row.getData()[columns[colPos + 1].getField()]) : false,
20609
+ jumpCol = this.findJumpCol(row, columns.slice(colPos + 1, columns.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
20568
20610
 
20569
- if(nextCell){
20570
- jumpCol = nextCell.column.getPosition() - 1;
20611
+ if(jumpCol){
20612
+ return jumpCol.getPosition() - 1;
20571
20613
  }
20572
20614
 
20573
- return jumpCol;
20615
+ return colPos;
20574
20616
  }
20575
20617
 
20576
20618
  findJumpCellUp(rowPos, colPos) {
20577
20619
  var column = this.getColumnByRangePos(colPos),
20578
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
20579
- isStartingCellEmpty = !cells[rowPos].getValue(),
20580
- isTopOfStartingCellEmpty = cells[rowPos - 1] ? !cells[rowPos - 1].getValue() : false,
20581
- jumpRow = rowPos,
20582
- nextCell = this.findJumpCell(cells.slice(0, jumpRow), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
20620
+ rows = this.getTableRows(),
20621
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
20622
+ isTopOfStartingCellEmpty = rows[rowPos - 1] ? this.isEmpty(rows[rowPos - 1].getData()[column.getField()]) : false,
20623
+ jumpRow = this.findJumpRow(column, rows.slice(0, rowPos), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
20583
20624
 
20584
- if(nextCell){
20585
- jumpRow = nextCell.row.position - 1;
20625
+ if(jumpRow){
20626
+ return jumpRow.position - 1;
20586
20627
  }
20587
20628
 
20588
- return jumpRow;
20629
+ return rowPos;
20589
20630
  }
20590
20631
 
20591
20632
  findJumpCellDown(rowPos, colPos) {
20592
20633
  var column = this.getColumnByRangePos(colPos),
20593
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
20594
- isStartingCellEmpty = !cells[rowPos].getValue(),
20595
- isBottomOfStartingCellEmpty = cells[rowPos + 1] ? !cells[rowPos + 1].getValue() : false,
20596
- jumpRow = rowPos,
20597
- nextCell = this.findJumpCell(cells.slice(jumpRow + 1, cells.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
20634
+ rows = this.getTableRows(),
20635
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
20636
+ isBottomOfStartingCellEmpty = rows[rowPos + 1] ? this.isEmpty(rows[rowPos + 1].getData()[column.getField()]) : false,
20637
+ jumpRow = this.findJumpRow(column, rows.slice(rowPos + 1, rows.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
20598
20638
 
20599
- if(nextCell){
20600
- jumpRow = nextCell.row.position - 1;
20639
+ if(jumpRow){
20640
+ return jumpRow.position - 1;
20601
20641
  }
20602
20642
 
20603
- return jumpRow;
20643
+ return rowPos;
20604
20644
  }
20605
20645
 
20606
20646
  ///////////////////////////////////
@@ -20901,6 +20941,10 @@ class SelectRange extends Module {
20901
20941
  selectedColumns(component) {
20902
20942
  return component ? this.activeRange.getColumns().map((col) => col.getComponent()) : this.activeRange.getColumns();
20903
20943
  }
20944
+
20945
+ isEmpty(value) {
20946
+ return value === null || value === undefined || value === "";
20947
+ }
20904
20948
  }
20905
20949
 
20906
20950
  //sort numbers