sheet-happens 0.0.13 → 0.0.14

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/dist/index.js CHANGED
@@ -84,6 +84,8 @@ var scrollSpeed = 30;
84
84
  var resizeColumnRowMouseThreshold = 4;
85
85
  var minimumColumnWidth = 50;
86
86
  var minimumRowHeight = 22;
87
+ var rowColHeaderSelectionColor = '#AAAAAA';
88
+ var maxSearchableRowOrCol = 65536;
87
89
  var defaultCellStyle = {
88
90
  textAlign: 'left',
89
91
  fontSize: 13,
@@ -374,7 +376,124 @@ function cellToAbsCoordinate(cellX, cellY, rowSizes, columnSizes, dataOffset, ce
374
376
  };
375
377
  }
376
378
 
377
- function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset) {
379
+ function findApproxMaxEditDataIndex(editData) {
380
+ var x = 0;
381
+ var y = 0;
382
+ var howManyEmpty = 0;
383
+ var growthIncrement = 10;
384
+ var growthIncrementFactor = 1.5;
385
+
386
+ while (howManyEmpty < 4) {
387
+ var allEmpty = true;
388
+
389
+ for (var yy = 0; yy < 10; yy++) {
390
+ var data = editData(x, yy);
391
+
392
+ if (data !== null && data !== undefined && data !== '') {
393
+ allEmpty = false;
394
+ break;
395
+ }
396
+ }
397
+
398
+ if (allEmpty) {
399
+ howManyEmpty += 1;
400
+ }
401
+
402
+ x += growthIncrement;
403
+ growthIncrement = Math.floor(growthIncrement * growthIncrementFactor);
404
+ }
405
+
406
+ howManyEmpty = 0;
407
+ growthIncrement = 10;
408
+ growthIncrementFactor = 1.5;
409
+
410
+ while (howManyEmpty < 4) {
411
+ var _allEmpty = true;
412
+
413
+ for (var xx = 0; xx < 10; xx++) {
414
+ var _data = editData(xx, y);
415
+
416
+ if (_data !== null && _data !== undefined && _data !== '') {
417
+ _allEmpty = false;
418
+ break;
419
+ }
420
+ }
421
+
422
+ if (_allEmpty) {
423
+ howManyEmpty += 1;
424
+ }
425
+
426
+ y += growthIncrement;
427
+ growthIncrement = Math.floor(growthIncrement * growthIncrementFactor);
428
+ }
429
+
430
+ return {
431
+ x: x,
432
+ y: y
433
+ };
434
+ }
435
+
436
+ function findInDisplayData(displayData, start, direction) {
437
+ var i = _extends({}, start);
438
+
439
+ var increment = {
440
+ x: 0,
441
+ y: 0
442
+ };
443
+
444
+ if (direction === 'up') {
445
+ increment.y = -1;
446
+ } else if (direction === 'down') {
447
+ increment.y = 1;
448
+ } else if (direction === 'left') {
449
+ increment.x = -1;
450
+ } else if (direction === 'right') {
451
+ increment.x = 1;
452
+ }
453
+
454
+ var max = {
455
+ x: maxSearchableRowOrCol,
456
+ y: maxSearchableRowOrCol
457
+ };
458
+
459
+ if (i.x > max.x) {
460
+ i.x = max.x;
461
+ }
462
+
463
+ if (i.y > max.y) {
464
+ i.y = max.y;
465
+ }
466
+
467
+ var first = displayData(i.x + increment.x, i.y + increment.y);
468
+ var firstFilled = first !== '' && first !== null && first !== undefined;
469
+
470
+ if (!firstFilled) {
471
+ i.x += increment.x;
472
+ i.y += increment.y;
473
+ }
474
+
475
+ while (i.x <= max.x && i.y <= max.y && i.x >= 0 && i.y >= 0) {
476
+ var data = displayData(i.x, i.y);
477
+
478
+ if (firstFilled && (data === '' || data === null || data === undefined)) {
479
+ return {
480
+ x: i.x - increment.x,
481
+ y: i.y - increment.y
482
+ };
483
+ }
484
+
485
+ if (!firstFilled && data !== '' && data !== null && data !== undefined) {
486
+ return _extends({}, i);
487
+ }
488
+
489
+ i.x += increment.x;
490
+ i.y += increment.y;
491
+ }
492
+
493
+ return i;
494
+ }
495
+
496
+ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates) {
378
497
  resizeCanvas(context.canvas);
379
498
  context.clearRect(0, 0, context.canvas.width, context.canvas.height);
380
499
  context.fillStyle = 'white';
@@ -417,7 +536,9 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
417
536
  sely2 = selection.y1;
418
537
  }
419
538
 
420
- var selectionActive = selx1 !== -1 && selx2 !== -1 && sely1 !== -1 && sely2 !== -1;
539
+ var selectionActive = selx1 !== -1 && selx2 !== -1 || sely1 !== -1 && sely2 !== -1;
540
+ var rowSelectionActive = selx1 === -1 && selx2 === -1 && sely1 !== -1 && sely2 !== -1;
541
+ var colSelectionActive = selx1 !== -1 && selx2 !== -1 && sely1 === -1 && sely2 === -1;
421
542
  var p1 = cellToAbsCoordinate(selx1, sely1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
422
543
  var p2 = cellToAbsCoordinate(selx2, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
423
544
  p2.x += cellWidth(selx2);
@@ -449,7 +570,16 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
449
570
 
450
571
  if (selectionActive) {
451
572
  context.fillStyle = selBackColor;
452
- context.fillRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
573
+ var p1x = Math.max(-100, p1.x);
574
+ var p1y = Math.max(-100, p1.y);
575
+
576
+ if (rowSelectionActive) {
577
+ context.fillRect(p1x, p1y, 100000, p2.y - p1.y);
578
+ } else if (colSelectionActive) {
579
+ context.fillRect(p1x, p1y, p2.x - p1.x, 100000);
580
+ } else {
581
+ context.fillRect(p1x, p1y, p2.x - p1.x, p2.y - p1.y);
582
+ }
453
583
  }
454
584
 
455
585
  context.fillStyle = rowHeaderBackgroundColor;
@@ -500,10 +630,16 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
500
630
 
501
631
  for (var _iterator5 = _createForOfIteratorHelperLoose(rowSizes.index), _step5; !(_step5 = _iterator5()).done;) {
502
632
  var _row = _step5.value;
503
- var xx = rowHeaderWidth * 0.5;
504
- var yy = startY + cellHeight(_row) * 0.5;
505
633
  var cellContent = _row + 1;
506
- context.fillText('' + cellContent, xx, yy);
634
+ var chStyle = {};
635
+
636
+ if (rowSelectionActive && sely1 <= _row && sely2 >= _row) {
637
+ chStyle = _extends({}, chStyle, {
638
+ backgroundColor: rowColHeaderSelectionColor
639
+ });
640
+ }
641
+
642
+ drawCell(context, '' + cellContent, chStyle, defaultColumnHeaderStyle, 0, startY, rowHeaderWidth, cellHeight(_row));
507
643
  startY += cellHeight(_row);
508
644
  }
509
645
 
@@ -516,16 +652,37 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
516
652
  var cw = cellWidth(_col);
517
653
  var ch = columnHeaders(_col);
518
654
  var chcontent = ch !== null ? ch : excelHeaderString(_col + 1);
519
- var chStyle = columnHeaderStyle(_col);
520
- drawCell(context, chcontent, chStyle, defaultColumnHeaderStyle, startX, 0, cw, columnHeaderHeight);
655
+
656
+ var _chStyle = columnHeaderStyle(_col);
657
+
658
+ if (colSelectionActive && selx1 <= _col && selx2 >= _col) {
659
+ _chStyle = _extends({}, _chStyle, {
660
+ backgroundColor: rowColHeaderSelectionColor
661
+ });
662
+ }
663
+
664
+ drawCell(context, chcontent, _chStyle, defaultColumnHeaderStyle, startX, 0, cw, columnHeaderHeight);
521
665
  startX += cw;
522
666
  }
523
667
 
524
668
  if (selectionActive) {
525
669
  context.strokeStyle = selBorderColor;
526
670
  context.lineWidth = 1;
671
+
672
+ var _p1x = Math.max(-100, p1.x);
673
+
674
+ var _p1y = Math.max(-100, p1.y);
675
+
527
676
  context.beginPath();
528
- context.rect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
677
+
678
+ if (rowSelectionActive) {
679
+ context.rect(_p1x, _p1y, 100000, p2.y - p1.y);
680
+ } else if (colSelectionActive) {
681
+ context.rect(_p1x, _p1y, p2.x - p1.x, 100000);
682
+ } else {
683
+ context.rect(_p1x, _p1y, p2.x - p1.x, p2.y - p1.y);
684
+ }
685
+
529
686
  context.stroke();
530
687
  }
531
688
 
@@ -552,14 +709,22 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
552
709
  context.setLineDash([3, 3]);
553
710
  context.lineWidth = 1;
554
711
  context.beginPath();
555
- context.rect(knobPoint1.x, knobPoint1.y - 1, knobPoint2.x - knobPoint1.x, knobPoint2.y - knobPoint1.y);
712
+
713
+ if (rowSelectionActive) {
714
+ context.rect(knobPoint1.x, knobPoint1.y - 1, 100000, knobPoint2.y - knobPoint1.y);
715
+ } else if (colSelectionActive) {
716
+ context.rect(knobPoint1.x, knobPoint1.y - 1, knobPoint2.x - knobPoint1.x, 100000);
717
+ } else {
718
+ context.rect(knobPoint1.x, knobPoint1.y - 1, knobPoint2.x - knobPoint1.x, knobPoint2.y - knobPoint1.y);
719
+ }
720
+
556
721
  context.stroke();
557
722
  context.setLineDash([]);
558
723
  }
559
724
 
560
725
  if (selectionActive && !hideKnob) {
561
726
  context.fillStyle = selBorderColor;
562
- context.fillRect(p2.x - knobSize * 0.5, p2.y - knobSize * 0.5, knobSize, knobSize);
727
+ context.fillRect(knobCoordinates.x - knobSize * 0.5, knobCoordinates.y - knobSize * 0.5, knobSize, knobSize);
563
728
  }
564
729
 
565
730
  context.textBaseline = 'middle';
@@ -748,12 +913,14 @@ function Sheet(props) {
748
913
  scrollToP2 = true;
749
914
  }
750
915
 
751
- setSelection({
752
- x1: x1,
753
- y1: y1,
754
- x2: x2,
755
- y2: y2
756
- });
916
+ if (selection.x1 !== x1 || selection.x2 !== x2 || selection.y1 !== y1 || selection.y2 !== y2) {
917
+ setSelection({
918
+ x1: x1,
919
+ y1: y1,
920
+ x2: x2,
921
+ y2: y2
922
+ });
923
+ }
757
924
 
758
925
  if (scrollToP2) {
759
926
  var newDataOffset = {
@@ -763,15 +930,32 @@ function Sheet(props) {
763
930
  var newScrollLeft = -1;
764
931
  var newScrollTop = -1;
765
932
 
766
- if (!columnSizes.index.includes(x2) || columnSizes.index[columnSizes.index.length - 1] === x2) {
767
- var increment = columnSizes.index[columnSizes.index.length - 1] <= x2 ? 1 : -1;
933
+ if (x2 !== -1 && (!columnSizes.index.includes(x2) || columnSizes.index[columnSizes.index.length - 1] === x2)) {
934
+ var lastVisibleColumnIndex = columnSizes.index[columnSizes.index.length - 1];
935
+ var firstVisibleColumnIndex = columnSizes.index[freezeColumns];
936
+ var increment = 0;
937
+
938
+ if (x2 >= lastVisibleColumnIndex) {
939
+ increment = 1 + x2 - lastVisibleColumnIndex;
940
+ } else if (x2 < firstVisibleColumnIndex) {
941
+ increment = x2 - firstVisibleColumnIndex;
942
+ }
943
+
768
944
  var newX = Math.max(dataOffset.x, freezeColumns) + increment;
769
945
  newDataOffset.x = newX;
770
946
  newScrollLeft = newX * scrollSpeed;
771
947
  }
772
948
 
773
- if (!rowSizes.index.includes(y2) || rowSizes.index[rowSizes.index.length - 1] === y2) {
774
- var _increment = rowSizes.index[rowSizes.index.length - 1] <= y2 ? 1 : -1;
949
+ if (y2 !== -1 && (!rowSizes.index.includes(y2) || rowSizes.index[rowSizes.index.length - 1] === y2)) {
950
+ var firstVisibleRowIndex = rowSizes.index[freezeRows];
951
+ var lastVisibleRowIndex = rowSizes.index[rowSizes.index.length - 1];
952
+ var _increment = 0;
953
+
954
+ if (y2 >= lastVisibleRowIndex) {
955
+ _increment = 1 + y2 - lastVisibleRowIndex;
956
+ } else if (y2 < firstVisibleRowIndex) {
957
+ _increment = y2 - firstVisibleRowIndex;
958
+ }
775
959
 
776
960
  var newY = Math.max(dataOffset.y, freezeRows) + _increment;
777
961
 
@@ -784,6 +968,12 @@ function Sheet(props) {
784
968
  x: newDataOffset.x,
785
969
  y: newDataOffset.y
786
970
  });
971
+
972
+ var newMaxScroll = _extends({}, maxScroll);
973
+
974
+ newMaxScroll.x = Math.max(newMaxScroll.x, newScrollLeft);
975
+ newMaxScroll.y = Math.max(newMaxScroll.y, newScrollTop);
976
+ setMaxScroll(newMaxScroll);
787
977
  setTimeout(function () {
788
978
  if (overlayRef.current) {
789
979
  if (newScrollLeft !== -1) {
@@ -819,23 +1009,53 @@ function Sheet(props) {
819
1009
  };
820
1010
 
821
1011
  var knobCoordinates = React.useMemo(function () {
822
- if (selection.x2 !== -1 && selection.y2 !== -1) {
1012
+ if (selection.x1 === -1 && selection.x2 === -1 && selection.y1 !== -1 && selection.y2 !== -1) {
1013
+ var sely2 = selection.y2;
1014
+
1015
+ if (selection.y1 > selection.y2) {
1016
+ sely2 = selection.y1;
1017
+ }
1018
+
1019
+ var c = cellToAbsCoordinate(0, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1020
+ return {
1021
+ x: c.x + knobSize * 0.5,
1022
+ y: c.y + cellHeight(sely2)
1023
+ };
1024
+ }
1025
+
1026
+ if (selection.x1 !== -1 && selection.x2 !== -1 && selection.y1 === -1 && selection.y2 === -1) {
823
1027
  var selx2 = selection.x2;
824
1028
 
825
1029
  if (selection.x1 > selection.x2) {
826
1030
  selx2 = selection.x1;
827
1031
  }
828
1032
 
829
- var sely2 = selection.y2;
1033
+ var _c = cellToAbsCoordinate(selx2, 0, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1034
+
1035
+ return {
1036
+ x: _c.x + cellWidth(selx2),
1037
+ y: _c.y + knobSize * 0.5
1038
+ };
1039
+ }
1040
+
1041
+ if (selection.x2 !== -1 && selection.y2 !== -1) {
1042
+ var _selx = selection.x2;
1043
+
1044
+ if (selection.x1 > selection.x2) {
1045
+ _selx = selection.x1;
1046
+ }
1047
+
1048
+ var _sely = selection.y2;
830
1049
 
831
1050
  if (selection.y1 > selection.y2) {
832
- sely2 = selection.y1;
1051
+ _sely = selection.y1;
833
1052
  }
834
1053
 
835
- var c = cellToAbsCoordinate(selx2, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1054
+ var _c2 = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1055
+
836
1056
  return {
837
- x: c.x + cellWidth(selx2),
838
- y: c.y + cellHeight(sely2)
1057
+ x: _c2.x + cellWidth(_selx),
1058
+ y: _c2.y + cellHeight(_sely)
839
1059
  };
840
1060
  }
841
1061
 
@@ -1007,12 +1227,12 @@ function Sheet(props) {
1007
1227
  }
1008
1228
 
1009
1229
  var animationFrameId = window.requestAnimationFrame(function () {
1010
- renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset);
1230
+ renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates);
1011
1231
  });
1012
1232
  return function () {
1013
1233
  window.cancelAnimationFrame(animationFrameId);
1014
1234
  };
1015
- }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset]);
1235
+ }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates]);
1016
1236
 
1017
1237
  var setFocusToTextArea = function setFocusToTextArea() {
1018
1238
  if (copyPasteTextAreaRef.current) {
@@ -1026,7 +1246,10 @@ function Sheet(props) {
1026
1246
  React.useEffect(function () {
1027
1247
  if (!editMode) {
1028
1248
  setCopyPasteText();
1029
-
1249
+ }
1250
+ }, [selection, editData]);
1251
+ React.useEffect(function () {
1252
+ if (!editMode) {
1030
1253
  if (document.activeElement === copyPasteTextAreaRef.current) {
1031
1254
  setFocusToTextArea();
1032
1255
  } else {
@@ -1180,18 +1403,26 @@ function Sheet(props) {
1180
1403
  pasteLocX = selection.x1;
1181
1404
  }
1182
1405
 
1183
- if (selection.y1 !== -1 && selection.y2 === -1) {
1184
- pasteLocY = selection.y1;
1185
- }
1186
-
1187
1406
  if (selection.x1 !== -1 && selection.x2 !== -1) {
1188
1407
  pasteLocX = Math.min(selection.x1, selection.x2);
1189
1408
  }
1190
1409
 
1410
+ if (selection.x1 === -1 && selection.x2 === -1 && selection.y1 !== -1 && selection.y2 !== -1) {
1411
+ pasteLocX = 0;
1412
+ }
1413
+
1414
+ if (selection.y1 !== -1 && selection.y2 === -1) {
1415
+ pasteLocY = selection.y1;
1416
+ }
1417
+
1191
1418
  if (selection.y1 !== -1 && selection.y2 !== -1) {
1192
1419
  pasteLocY = Math.min(selection.y1, selection.y2);
1193
1420
  }
1194
1421
 
1422
+ if (selection.y1 === -1 && selection.y2 === -1 && selection.x2 !== -1 && selection.x2 !== -1) {
1423
+ pasteLocY = 0;
1424
+ }
1425
+
1195
1426
  if (pasteLocX === -1 || pasteLocY === -1) {
1196
1427
  return;
1197
1428
  }
@@ -1225,7 +1456,7 @@ function Sheet(props) {
1225
1456
  };
1226
1457
 
1227
1458
  var setCopyPasteText = function setCopyPasteText() {
1228
- if (selection.x1 === -1 || selection.y1 === -1 || selection.x2 === -1 || selection.y2 === -1) {
1459
+ if (selection.x1 === -1 && selection.y1 === -1 && selection.x2 === -1 && selection.y2 === -1) {
1229
1460
  return;
1230
1461
  }
1231
1462
 
@@ -1245,25 +1476,46 @@ function Sheet(props) {
1245
1476
  dx2 = selection.x1;
1246
1477
  }
1247
1478
 
1248
- var rows = [];
1479
+ var max = findApproxMaxEditDataIndex(editData);
1480
+
1481
+ if (dx1 === -1 && dx2 === -1) {
1482
+ dx1 = 0;
1483
+ dx2 = max.x;
1484
+ }
1485
+
1486
+ if (dy1 === -1 && dy2 === -1) {
1487
+ dy1 = 0;
1488
+ dy2 = max.y;
1489
+ }
1490
+
1491
+ var cptext = '';
1492
+ var cptextTemp = '';
1249
1493
 
1250
1494
  for (var y = dy1; y <= dy2; y++) {
1251
- var row = [];
1495
+ var nonEmpty = false;
1252
1496
 
1253
1497
  for (var x = dx1; x <= dx2; x++) {
1254
1498
  var value = editData(x, y);
1255
1499
 
1256
1500
  if (value !== null && value !== undefined) {
1257
- row.push(value);
1258
- } else {
1259
- row.push('');
1501
+ cptextTemp += value;
1502
+ nonEmpty = true;
1503
+ }
1504
+
1505
+ if (x !== dx2) {
1506
+ cptextTemp += '\t';
1260
1507
  }
1261
1508
  }
1262
1509
 
1263
- rows.push(row.join('\t'));
1264
- }
1510
+ if (y !== dy2) {
1511
+ cptextTemp += '\n';
1512
+ }
1265
1513
 
1266
- var cptext = rows.join('\n');
1514
+ if (nonEmpty) {
1515
+ cptext += cptextTemp;
1516
+ cptextTemp = '';
1517
+ }
1518
+ }
1267
1519
 
1268
1520
  if (copyPasteTextAreaRef.current) {
1269
1521
  copyPasteTextAreaRef.current.value = cptext;
@@ -1275,7 +1527,7 @@ function Sheet(props) {
1275
1527
  props.onChange([{
1276
1528
  x: editCell.x,
1277
1529
  y: editCell.y,
1278
- value: value != null ? value : editValue
1530
+ value: value !== undefined ? value : editValue
1279
1531
  }]);
1280
1532
  }
1281
1533
 
@@ -1388,10 +1640,25 @@ function Sheet(props) {
1388
1640
 
1389
1641
  if (Math.abs(start - x) < resizeColumnRowMouseThreshold || Math.abs(end - x) < resizeColumnRowMouseThreshold) {
1390
1642
  window.document.body.style.cursor = 'col-resize';
1643
+ var indices = [];
1644
+
1645
+ if (selection.x1 !== -1 && selection.x2 !== -1 && selection.y1 === -1 && selection.y2 === -1) {
1646
+ var min = Math.min(selection.x1, selection.x2);
1647
+ var max = Math.max(selection.x1, selection.x2);
1648
+
1649
+ for (var i = min; i <= max; i++) {
1650
+ indices.push(i);
1651
+ }
1652
+ }
1653
+
1654
+ if (indices.length === 0) {
1655
+ indices.push(index);
1656
+ }
1657
+
1391
1658
  setColumnResize({
1392
1659
  startX: end,
1393
1660
  oldWidth: cellWidth(index),
1394
- colIdx: index
1661
+ colIndices: indices
1395
1662
  });
1396
1663
  return;
1397
1664
  }
@@ -1406,10 +1673,26 @@ function Sheet(props) {
1406
1673
 
1407
1674
  if (Math.abs(_start - y) < resizeColumnRowMouseThreshold || Math.abs(_end - y) < resizeColumnRowMouseThreshold) {
1408
1675
  window.document.body.style.cursor = 'row-resize';
1676
+ var _indices = [];
1677
+
1678
+ if (selection.x1 === -1 && selection.x2 === -1 && selection.y1 !== -1 && selection.y2 !== -1) {
1679
+ var _min = Math.min(selection.y1, selection.y2);
1680
+
1681
+ var _max = Math.max(selection.y1, selection.y2);
1682
+
1683
+ for (var _i5 = _min; _i5 <= _max; _i5++) {
1684
+ _indices.push(_i5);
1685
+ }
1686
+ }
1687
+
1688
+ if (_indices.length === 0) {
1689
+ _indices.push(_index);
1690
+ }
1691
+
1409
1692
  setRowResize({
1410
1693
  startY: _end,
1411
1694
  oldHeight: cellHeight(_index),
1412
- rowIdx: _index
1695
+ rowIndices: _indices
1413
1696
  });
1414
1697
  return;
1415
1698
  }
@@ -1440,17 +1723,19 @@ function Sheet(props) {
1440
1723
  var scrollToP2 = true;
1441
1724
 
1442
1725
  if (x < rowHeaderWidth) {
1443
- sel2.x = dataOffset.x + 100;
1444
1726
  scrollToP2 = false;
1445
1727
  setRowSelectionInProgress(true);
1728
+ sel1.x = -1;
1729
+ sel2.x = -1;
1446
1730
  } else {
1447
1731
  setRowSelectionInProgress(false);
1448
1732
  }
1449
1733
 
1450
1734
  if (y < columnHeaderHeight) {
1451
- sel2.y = dataOffset.y + 100;
1452
1735
  scrollToP2 = false;
1453
1736
  setColumnSelectionInProgress(true);
1737
+ sel1.y = -1;
1738
+ sel2.y = -1;
1454
1739
  } else {
1455
1740
  setColumnSelectionInProgress(false);
1456
1741
  }
@@ -1511,6 +1796,11 @@ function Sheet(props) {
1511
1796
  fy2 = sy1 - 1;
1512
1797
  }
1513
1798
 
1799
+ if (fx1 === -1 && fx2 === -1) {
1800
+ fx1 = 0;
1801
+ fx2 = maxSearchableRowOrCol;
1802
+ }
1803
+
1514
1804
  var srcY = sy1;
1515
1805
 
1516
1806
  for (var y = fy1; y <= fy2; y++) {
@@ -1536,6 +1826,11 @@ function Sheet(props) {
1536
1826
  fx2 = sx1 - 1;
1537
1827
  }
1538
1828
 
1829
+ if (fy1 === -1 && fy2 === -1) {
1830
+ fy1 = 0;
1831
+ fy2 = maxSearchableRowOrCol;
1832
+ }
1833
+
1539
1834
  var srcX = sx1;
1540
1835
 
1541
1836
  for (var _x3 = fx1; _x3 <= fx2; _x3++) {
@@ -1662,7 +1957,7 @@ function Sheet(props) {
1662
1957
  if (columnResize) {
1663
1958
  if (props.onCellWidthChange) {
1664
1959
  var newWidth = Math.max(columnResize.oldWidth + x - columnResize.startX, minimumColumnWidth);
1665
- props.onCellWidthChange(columnResize.colIdx, newWidth);
1960
+ props.onCellWidthChange(columnResize.colIndices, newWidth);
1666
1961
  }
1667
1962
 
1668
1963
  return;
@@ -1671,7 +1966,7 @@ function Sheet(props) {
1671
1966
  if (rowResize) {
1672
1967
  if (props.onCellHeightChange) {
1673
1968
  var newHeight = Math.max(rowResize.oldHeight + y - rowResize.startY, minimumRowHeight);
1674
- props.onCellHeightChange(rowResize.rowIdx, newHeight);
1969
+ props.onCellHeightChange(rowResize.rowIndices, newHeight);
1675
1970
  }
1676
1971
 
1677
1972
  return;
@@ -1681,9 +1976,9 @@ function Sheet(props) {
1681
1976
  var sel2 = absCoordianteToCell(x, y, rowSizes, columnSizes);
1682
1977
 
1683
1978
  if (rowSelectionInProgress) {
1684
- changeSelection(selection.x1, selection.y1, selection.x2, sel2.y, false);
1979
+ changeSelection(-1, selection.y1, -1, sel2.y, false);
1685
1980
  } else if (columnSelectionInProgress) {
1686
- changeSelection(selection.x1, selection.y1, sel2.x, selection.y2, false);
1981
+ changeSelection(selection.x1, -1, sel2.x, -1, false);
1687
1982
  } else {
1688
1983
  changeSelection(selection.x1, selection.y1, sel2.x, sel2.y);
1689
1984
  }
@@ -1714,7 +2009,7 @@ function Sheet(props) {
1714
2009
  if (cell.y < y1) yCellDiff = cell.y - y1;
1715
2010
  if (cell.y > y2) yCellDiff = y2 - cell.y;
1716
2011
 
1717
- if (xCellDiff > yCellDiff) {
2012
+ if (x1 === -1 && x2 === -1 || xCellDiff > yCellDiff) {
1718
2013
  if (cell.y < y1) {
1719
2014
  y1 = cell.y;
1720
2015
  } else {
@@ -1847,6 +2142,16 @@ function Sheet(props) {
1847
2142
  y2 = selection.y1;
1848
2143
  }
1849
2144
 
2145
+ if (x1 === -1 && x2 === -1 && y1 !== -1 && y2 !== -1) {
2146
+ x1 = 0;
2147
+ x2 = maxSearchableRowOrCol;
2148
+ }
2149
+
2150
+ if (x1 !== -1 && x2 !== -1 && y1 === -1 && y2 === -1) {
2151
+ y1 = 0;
2152
+ y2 = maxSearchableRowOrCol;
2153
+ }
2154
+
1850
2155
  var changes = [];
1851
2156
 
1852
2157
  for (var y = y1; y <= y2; y++) {
@@ -1893,17 +2198,35 @@ function Sheet(props) {
1893
2198
  x: selection.x2,
1894
2199
  y: selection.y2
1895
2200
  };
2201
+ var incr = {
2202
+ x: 0,
2203
+ y: 0
2204
+ };
2205
+ var direction = 'right';
1896
2206
 
1897
2207
  if (e.key === 'ArrowRight' || e.key === 'Tab') {
1898
- sel2.x += 1;
2208
+ incr.x = 1;
2209
+ direction = 'right';
1899
2210
  } else if (e.key === 'ArrowLeft') {
1900
- sel2.x -= 1;
2211
+ incr.x = -1;
2212
+ direction = 'left';
1901
2213
  } else if (e.key === 'ArrowUp') {
1902
- sel2.y -= 1;
2214
+ incr.y = -1;
2215
+ direction = 'up';
1903
2216
  } else if (e.key === 'ArrowDown') {
1904
- sel2.y += 1;
2217
+ incr.y = 1;
2218
+ direction = 'down';
1905
2219
  }
1906
2220
 
2221
+ if (e.metaKey || e.ctrlKey) {
2222
+ var val = findInDisplayData(displayData, sel2, direction);
2223
+ incr.x = val.x - sel2.x;
2224
+ incr.y = val.y - sel2.y;
2225
+ }
2226
+
2227
+ sel2.x += incr.x;
2228
+ sel2.y += incr.y;
2229
+
1907
2230
  if (sel2.x < 0) {
1908
2231
  sel2.x = 0;
1909
2232
  }
@@ -2073,13 +2396,17 @@ function Sheet(props) {
2073
2396
  opacity: 0.01
2074
2397
  },
2075
2398
  ref: copyPasteTextAreaRef,
2399
+ autoComplete: "off",
2400
+ autoCorrect: "off",
2401
+ autoCapitalize: "off",
2402
+ spellCheck: "false",
2076
2403
  onFocus: function onFocus(e) {
2077
2404
  return e.target.select();
2078
2405
  },
2079
2406
  tabIndex: 0,
2080
2407
  onKeyDown: onGridKeyDown,
2081
2408
  onKeyUp: onGridKeyUp
2082
- }), editMode && (input != null ? input : React__default.createElement("input", Object.assign({}, inputProps, {
2409
+ }), editMode && (input !== undefined ? input : React__default.createElement("input", Object.assign({}, inputProps, {
2083
2410
  type: "text",
2084
2411
  onFocus: function onFocus(e) {
2085
2412
  return e.target.select();