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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulator-tables",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -196,7 +196,8 @@ export default class Popup extends CoreFeature{
196
196
  }
197
197
 
198
198
  //move menu to start on bottom edge if it is too close to the edge of the screen
199
- if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) {
199
+ let offsetHeight = Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0);
200
+ if((y + this.element.offsetHeight) > offsetHeight) {
200
201
  if(parentEl){
201
202
  switch(position){
202
203
  case "bottom":
@@ -208,7 +209,7 @@ export default class Popup extends CoreFeature{
208
209
  }
209
210
 
210
211
  }else{
211
- this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px";
212
+ this.element.style.height = offsetHeight + "px";
212
213
  }
213
214
  }
214
215
  }
@@ -302,4 +303,4 @@ export default class Popup extends CoreFeature{
302
303
 
303
304
  return this.childPopup;
304
305
  }
305
- }
306
+ }
@@ -174,6 +174,13 @@ export default class MoveColumns extends Module{
174
174
  headerElement = this.table.columnManager.getContentsElement(),
175
175
  headersElement = this.table.columnManager.getHeadersElement();
176
176
 
177
+ //Prevent moving columns when range selection is active
178
+ if(this.table.modules.selectRange && this.table.modules.selectRange.columnSelection){
179
+ if(this.table.modules.selectRange.mousedown && this.table.modules.selectRange.selecting === "column"){
180
+ return;
181
+ }
182
+ }
183
+
177
184
  this.moving = column;
178
185
  this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;
179
186
 
@@ -203,6 +210,8 @@ export default class MoveColumns extends Module{
203
210
  }
204
211
 
205
212
  this.moveHover(e);
213
+
214
+ this.dispatch("column-moving", e, this.moving);
206
215
  }
207
216
 
208
217
  _bindMouseMove(){
@@ -259,7 +268,7 @@ export default class MoveColumns extends Module{
259
268
  if(this.toCol){
260
269
  this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);
261
270
  }
262
-
271
+
263
272
  this.moving = false;
264
273
  this.toCol = false;
265
274
  this.toColAfter = false;
@@ -22,7 +22,7 @@ export default class RangeComponent {
22
22
  }
23
23
 
24
24
  getCells() {
25
- return this._range.getCells(true);
25
+ return this._range.getCells(true, true);
26
26
  }
27
27
 
28
28
  getStructuredCells() {
@@ -98,6 +98,8 @@ export default class SelectRange extends Module {
98
98
  this.subscribe("column-mousedown", this.handleColumnMouseDown.bind(this));
99
99
  this.subscribe("column-mousemove", this.handleColumnMouseMove.bind(this));
100
100
  this.subscribe("column-resized", this.handleColumnResized.bind(this));
101
+ this.subscribe("column-moving", this.handleColumnMoving.bind(this));
102
+ this.subscribe("column-moved", this.handleColumnMoved.bind(this));
101
103
  this.subscribe("column-width", this.layoutChange.bind(this));
102
104
  this.subscribe("column-height", this.layoutChange.bind(this));
103
105
  this.subscribe("column-resized", this.layoutChange.bind(this));
@@ -255,6 +257,8 @@ export default class SelectRange extends Module {
255
257
 
256
258
  initializeFocus(cell){
257
259
  var range;
260
+
261
+ this.restoreFocus();
258
262
 
259
263
  try{
260
264
  if (document.selection) { // IE
@@ -304,10 +308,26 @@ export default class SelectRange extends Module {
304
308
  });
305
309
  }
306
310
 
311
+ handleColumnMoving(_event, column) {
312
+ this.resetRanges().setBounds(column);
313
+ this.overlay.style.visibility = "hidden";
314
+ }
315
+
316
+ handleColumnMoved(from, _to, _after) {
317
+ this.activeRange.setBounds(from);
318
+ this.layoutElement();
319
+ }
320
+
307
321
  handleColumnMouseDown(event, column) {
308
322
  if (event.button === 2 && (this.selecting === "column" || this.selecting === "all") && this.activeRange.occupiesColumn(column)) {
309
323
  return;
310
324
  }
325
+
326
+ //If columns are movable, allow dragging columns only if they are not
327
+ //selected. Dragging selected columns should move the columns instead.
328
+ if(this.table.options.movableColumns && this.selecting === "column" && this.activeRange.occupiesColumn(column)){
329
+ return;
330
+ }
311
331
 
312
332
  this.mousedown = true;
313
333
 
@@ -383,14 +403,16 @@ export default class SelectRange extends Module {
383
403
 
384
404
  keyNavigate(dir, e){
385
405
  if(this.navigate(false, false, dir)){
386
- e.preventDefault();
406
+ // e.preventDefault();
387
407
  }
408
+ e.preventDefault();
388
409
  }
389
410
 
390
411
  keyNavigateRange(e, dir, jump, expand){
391
412
  if(this.navigate(jump, expand, dir)){
392
- e.preventDefault();
413
+ // e.preventDefault();
393
414
  }
415
+ e.preventDefault();
394
416
  }
395
417
 
396
418
  navigate(jump, expand, dir) {
@@ -457,6 +479,10 @@ export default class SelectRange extends Module {
457
479
  break;
458
480
  }
459
481
  }
482
+
483
+ if(this.rowHeader && nextCol === 0) {
484
+ nextCol = 1;
485
+ }
460
486
 
461
487
  moved = nextCol !== rangeEdge.col || nextRow !== rangeEdge.row;
462
488
 
@@ -503,100 +529,108 @@ export default class SelectRange extends Module {
503
529
  this.layoutElement();
504
530
  }
505
531
 
506
- findJumpCell(cells, reverse, emptyStart, emptySide){
507
- var nextCell;
508
-
532
+ findJumpRow(column, rows, reverse, emptyStart, emptySide){
509
533
  if(reverse){
510
- cells = cells.reverse();
534
+ rows = rows.reverse();
511
535
  }
512
-
513
- for(let currentCell of cells){
514
- let currentValue = currentCell.getValue();
536
+
537
+ return this.findJumpItem(emptyStart, emptySide, rows, function(row){return row.getData()[column.getField()];});
538
+ }
539
+
540
+ findJumpCol(row, columns, reverse, emptyStart, emptySide){
541
+ if(reverse){
542
+ columns = columns.reverse();
543
+ }
544
+
545
+ return this.findJumpItem(emptyStart, emptySide, columns, function(column){return row.getData()[column.getField()];});
546
+ }
547
+
548
+ findJumpItem(emptyStart, emptySide, items, valueResolver){
549
+ var nextItem;
550
+
551
+ for(let currentItem of items){
552
+ let currentValue = valueResolver(currentItem);
515
553
 
516
554
  if(emptyStart){
517
- nextCell = currentCell;
555
+ nextItem = currentItem;
518
556
  if(currentValue){
519
557
  break;
520
558
  }
521
559
  }else{
522
560
  if(emptySide){
523
- nextCell = currentCell;
561
+ nextItem = currentItem;
524
562
 
525
563
  if(currentValue){
526
564
  break;
527
565
  }
528
566
  }else{
529
567
  if(currentValue){
530
- nextCell = currentCell;
568
+ nextItem = currentItem;
531
569
  }else{
532
570
  break;
533
571
  }
534
572
  }
535
573
  }
536
574
  }
537
-
538
- return nextCell;
575
+
576
+ return nextItem;
539
577
  }
540
-
578
+
541
579
  findJumpCellLeft(rowPos, colPos){
542
580
  var row = this.getRowByRangePos(rowPos),
543
- cells = row.cells.filter((cell) => cell.column.visible),
544
- isStartingCellEmpty = !cells[colPos].getValue(),
545
- isLeftOfStartingCellEmpty = cells[colPos] ? !cells[colPos].getValue() : false,
546
- jumpCol = colPos,
547
- targetCells = this.rowHeader ? cells.slice(1, colPos) : cells.slice(0, colPos),
548
- nextCell = this.findJumpCell(targetCells, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
581
+ columns = this.getTableColumns(),
582
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
583
+ isLeftOfStartingCellEmpty = columns[colPos - 1] ? this.isEmpty(row.getData()[columns[colPos - 1].getField()]) : false,
584
+ targetCols = this.rowHeader ? columns.slice(1, colPos) : columns.slice(0, colPos),
585
+ jumpCol = this.findJumpCol(row, targetCols, true, isStartingCellEmpty, isLeftOfStartingCellEmpty);
549
586
 
550
- if(nextCell){
551
- jumpCol = nextCell.column.getPosition() - 1;
587
+ if(jumpCol){
588
+ return jumpCol.getPosition() - 1;
552
589
  }
553
590
 
554
- return jumpCol;
591
+ return colPos;
555
592
  }
556
593
 
557
594
  findJumpCellRight(rowPos, colPos){
558
595
  var row = this.getRowByRangePos(rowPos),
559
- cells = row.cells.filter((cell) => cell.column.visible),
560
- isStartingCellEmpty = !cells[colPos].getValue(),
561
- isRightOfStartingCellEmpty = cells[colPos + 1] ? !cells[colPos + 1].getValue() : false,
562
- jumpCol = colPos,
563
- nextCell = this.findJumpCell(cells.slice(colPos + 1, cells.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
596
+ columns = this.getTableColumns(),
597
+ isStartingCellEmpty = this.isEmpty(row.getData()[columns[colPos].getField()]),
598
+ isRightOfStartingCellEmpty = columns[colPos + 1] ? this.isEmpty(row.getData()[columns[colPos + 1].getField()]) : false,
599
+ jumpCol = this.findJumpCol(row, columns.slice(colPos + 1, columns.length), false, isStartingCellEmpty, isRightOfStartingCellEmpty);
564
600
 
565
- if(nextCell){
566
- jumpCol = nextCell.column.getPosition() - 1;
601
+ if(jumpCol){
602
+ return jumpCol.getPosition() - 1;
567
603
  }
568
604
 
569
- return jumpCol;
605
+ return colPos;
570
606
  }
571
607
 
572
608
  findJumpCellUp(rowPos, colPos) {
573
609
  var column = this.getColumnByRangePos(colPos),
574
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
575
- isStartingCellEmpty = !cells[rowPos].getValue(),
576
- isTopOfStartingCellEmpty = cells[rowPos - 1] ? !cells[rowPos - 1].getValue() : false,
577
- jumpRow = rowPos,
578
- nextCell = this.findJumpCell(cells.slice(0, jumpRow), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
610
+ rows = this.getTableRows(),
611
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
612
+ isTopOfStartingCellEmpty = rows[rowPos - 1] ? this.isEmpty(rows[rowPos - 1].getData()[column.getField()]) : false,
613
+ jumpRow = this.findJumpRow(column, rows.slice(0, rowPos), true, isStartingCellEmpty, isTopOfStartingCellEmpty);
579
614
 
580
- if(nextCell){
581
- jumpRow = nextCell.row.position - 1;
615
+ if(jumpRow){
616
+ return jumpRow.position - 1;
582
617
  }
583
618
 
584
- return jumpRow;
619
+ return rowPos;
585
620
  }
586
621
 
587
622
  findJumpCellDown(rowPos, colPos) {
588
623
  var column = this.getColumnByRangePos(colPos),
589
- cells = column.cells.filter((cell) => this.table.rowManager.activeRows.includes(cell.row)),
590
- isStartingCellEmpty = !cells[rowPos].getValue(),
591
- isBottomOfStartingCellEmpty = cells[rowPos + 1] ? !cells[rowPos + 1].getValue() : false,
592
- jumpRow = rowPos,
593
- nextCell = this.findJumpCell(cells.slice(jumpRow + 1, cells.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
624
+ rows = this.getTableRows(),
625
+ isStartingCellEmpty = this.isEmpty(rows[rowPos].getData()[column.getField()]),
626
+ isBottomOfStartingCellEmpty = rows[rowPos + 1] ? this.isEmpty(rows[rowPos + 1].getData()[column.getField()]) : false,
627
+ jumpRow = this.findJumpRow(column, rows.slice(rowPos + 1, rows.length), false, isStartingCellEmpty, isBottomOfStartingCellEmpty);
594
628
 
595
- if(nextCell){
596
- jumpRow = nextCell.row.position - 1;
629
+ if(jumpRow){
630
+ return jumpRow.position - 1;
597
631
  }
598
632
 
599
- return jumpRow;
633
+ return rowPos;
600
634
  }
601
635
 
602
636
  ///////////////////////////////////
@@ -897,4 +931,8 @@ export default class SelectRange extends Module {
897
931
  selectedColumns(component) {
898
932
  return component ? this.activeRange.getColumns().map((col) => col.getComponent()) : this.activeRange.getColumns();
899
933
  }
900
- }
934
+
935
+ isEmpty(value) {
936
+ return value === null || value === undefined || value === "";
937
+ }
938
+ }