sheet-happens 0.0.18 → 0.0.20

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.
@@ -68,11 +68,11 @@ var selBackColor = '#e9f0fd';
68
68
  var knobSize = 6;
69
69
  var gridColor = '#e2e3e3';
70
70
  var knobAreaBorderColor = '#707070';
71
- var rowHeaderWidth = 50;
71
+ var kRowHeaderWidth = 50;
72
72
  var rowHeaderBackgroundColor = '#f8f9fa';
73
73
  var rowHeaderTextColor = '#666666';
74
74
  var rowHeaderSelectedBackgroundColor = '#e8eaed';
75
- var columnHeaderHeight = 22;
75
+ var kColumnHeaderHeight = 22;
76
76
  var columnHeaderBackgroundColor = rowHeaderBackgroundColor;
77
77
  var columnHeaderSelectedBackgroundColor = rowHeaderSelectedBackgroundColor;
78
78
  var xBinSize = 10;
@@ -111,7 +111,14 @@ function resizeCanvas(canvas) {
111
111
  width = _canvas$getBoundingCl.width,
112
112
  height = _canvas$getBoundingCl.height;
113
113
 
114
- var ratio = 2;
114
+ var _window = window,
115
+ _window$devicePixelRa = _window.devicePixelRatio,
116
+ ratio = _window$devicePixelRa === void 0 ? 1 : _window$devicePixelRa;
117
+
118
+ if (ratio < 1) {
119
+ ratio = 1;
120
+ }
121
+
115
122
  var newCanvasWidth = Math.round(width * ratio);
116
123
  var newCanvasHeight = Math.round(height * ratio);
117
124
 
@@ -325,8 +332,8 @@ function absCoordianteToCell(absX, absY, rowSizes, columnSizes) {
325
332
  };
326
333
  }
327
334
 
328
- function cellToAbsCoordinate(cellX, cellY, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight) {
329
- var absX = rowHeaderWidth;
335
+ function cellToAbsCoordinate(cellX, cellY, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle) {
336
+ var absX = sheetStyle.rowHeaderWidth;
330
337
  var indX = columnSizes.index.findIndex(function (i) {
331
338
  return i === cellX;
332
339
  });
@@ -343,7 +350,7 @@ function cellToAbsCoordinate(cellX, cellY, rowSizes, columnSizes, dataOffset, ce
343
350
  }
344
351
  }
345
352
 
346
- var absY = columnHeaderHeight;
353
+ var absY = sheetStyle.columnHeaderHeight;
347
354
  var indY = rowSizes.index.findIndex(function (i) {
348
355
  return i === cellY;
349
356
  });
@@ -493,16 +500,16 @@ function findInDisplayData(displayData, start, direction) {
493
500
  return i;
494
501
  }
495
502
 
496
- function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, hideGridlines) {
503
+ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle) {
497
504
  resizeCanvas(context.canvas);
498
505
  context.clearRect(0, 0, context.canvas.width, context.canvas.height);
499
506
  context.fillStyle = 'white';
500
507
  context.fillRect(0, 0, context.canvas.width, context.canvas.height);
501
- var yCoord1 = columnHeaderHeight;
508
+ var yCoord1 = sheetStyle.columnHeaderHeight;
502
509
 
503
510
  for (var _iterator2 = _createForOfIteratorHelperLoose(rowSizes.index), _step2; !(_step2 = _iterator2()).done;) {
504
511
  var y = _step2.value;
505
- var xCoord1 = rowHeaderWidth;
512
+ var xCoord1 = sheetStyle.rowHeaderWidth;
506
513
 
507
514
  for (var _iterator8 = _createForOfIteratorHelperLoose(columnSizes.index), _step8; !(_step8 = _iterator8()).done;) {
508
515
  var x = _step8.value;
@@ -539,8 +546,8 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
539
546
  var selectionActive = selx1 !== -1 && selx2 !== -1 || sely1 !== -1 && sely2 !== -1;
540
547
  var rowSelectionActive = selx1 === -1 && selx2 === -1 && sely1 !== -1 && sely2 !== -1;
541
548
  var colSelectionActive = selx1 !== -1 && selx2 !== -1 && sely1 === -1 && sely2 === -1;
542
- var p1 = cellToAbsCoordinate(selx1, sely1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
543
- var p2 = cellToAbsCoordinate(selx2, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
549
+ var p1 = cellToAbsCoordinate(selx1, sely1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
550
+ var p2 = cellToAbsCoordinate(selx2, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
544
551
  p2.x += cellWidth(selx2);
545
552
  p2.y += cellHeight(sely2);
546
553
 
@@ -573,118 +580,128 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
573
580
 
574
581
  if (rowSelectionActive) {
575
582
  var p1x = Math.max(-100, p1.x);
576
- var p1y = Math.max(-100, p1.y);
577
- context.fillRect(p1x, p1y, 100000, p2.y - p1.y);
583
+ context.fillRect(p1x, p1.y, 100000, p2.y - p1.y);
578
584
  } else if (colSelectionActive) {
579
- var _p1x = Math.max(-100, p1.x);
580
-
581
- var _p1y = Math.max(-100, p1.y);
582
-
583
- context.fillRect(_p1x, _p1y, p2.x - p1.x, 100000);
585
+ var p1y = Math.max(0, p1.y);
586
+ context.fillRect(p1.x, p1y, p2.x - p1.x, 100000);
584
587
  } else {
585
588
  context.fillRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
586
589
  }
587
590
  }
588
591
 
589
- context.fillStyle = rowHeaderBackgroundColor;
590
- context.fillRect(0, 0, rowHeaderWidth, context.canvas.height);
592
+ if (!sheetStyle.hideRowHeaders) {
593
+ context.fillStyle = rowHeaderBackgroundColor;
594
+ context.fillRect(0, 0, sheetStyle.rowHeaderWidth, context.canvas.height);
591
595
 
592
- if (selectionActive) {
593
- context.fillStyle = rowHeaderSelectedBackgroundColor;
594
- context.fillRect(0, p1.y, rowHeaderWidth, p2.y - p1.y);
596
+ if (selectionActive) {
597
+ context.fillStyle = rowHeaderSelectedBackgroundColor;
598
+ context.fillRect(0, p1.y, sheetStyle.rowHeaderWidth, p2.y - p1.y);
599
+ }
595
600
  }
596
601
 
597
- context.fillStyle = columnHeaderBackgroundColor;
598
- context.fillRect(0, 0, context.canvas.width, columnHeaderHeight);
602
+ if (!sheetStyle.hideColumnHeaders) {
603
+ context.fillStyle = columnHeaderBackgroundColor;
604
+ context.fillRect(0, 0, context.canvas.width, sheetStyle.columnHeaderHeight);
599
605
 
600
- if (selectionActive) {
601
- context.fillStyle = columnHeaderSelectedBackgroundColor;
602
- context.fillRect(p1.x, 0, p2.x - p1.x, columnHeaderHeight);
606
+ if (selectionActive) {
607
+ context.fillStyle = columnHeaderSelectedBackgroundColor;
608
+ context.fillRect(p1.x, 0, p2.x - p1.x, sheetStyle.columnHeaderHeight);
609
+ }
603
610
  }
604
611
 
605
612
  context.strokeStyle = gridColor;
606
613
  context.lineWidth = 1;
607
- var startX = rowHeaderWidth;
608
- var startY = columnHeaderHeight;
609
- var xGridlineEnd = hideGridlines ? rowHeaderWidth : context.canvas.width;
610
- var yGridlineEnd = hideGridlines ? columnHeaderHeight : context.canvas.height;
614
+ var startX = sheetStyle.rowHeaderWidth;
615
+ var startY = sheetStyle.columnHeaderHeight;
611
616
  var first = true;
617
+ var yGridlineEnd = sheetStyle.hideGridlines ? sheetStyle.columnHeaderHeight : context.canvas.height;
612
618
 
613
619
  for (var _iterator3 = _createForOfIteratorHelperLoose(columnSizes.index), _step3; !(_step3 = _iterator3()).done;) {
614
- var col = _step3.value;
620
+ var _col = _step3.value;
615
621
  context.beginPath();
616
622
  context.moveTo(startX, 0);
617
623
 
618
624
  if (first) {
619
- context.lineTo(startX, context.canvas.height);
625
+ if (!sheetStyle.hideRowHeaders) {
626
+ context.lineTo(startX, context.canvas.height);
627
+ }
628
+
620
629
  first = false;
621
630
  } else {
622
631
  context.lineTo(startX, yGridlineEnd);
623
632
  }
624
633
 
625
634
  context.stroke();
626
- startX += cellWidth(col);
635
+ startX += cellWidth(_col);
627
636
  }
628
637
 
638
+ var xGridlineEnd = sheetStyle.hideGridlines ? sheetStyle.rowHeaderWidth : context.canvas.width;
629
639
  first = true;
630
640
 
631
641
  for (var _iterator4 = _createForOfIteratorHelperLoose(rowSizes.index), _step4; !(_step4 = _iterator4()).done;) {
632
- var row = _step4.value;
642
+ var _row = _step4.value;
633
643
  context.beginPath();
634
644
  context.moveTo(0, startY);
635
645
 
636
646
  if (first) {
637
- context.lineTo(context.canvas.width, startY);
647
+ if (!sheetStyle.hideColumnHeaders) {
648
+ context.lineTo(context.canvas.width, startY);
649
+ }
650
+
638
651
  first = false;
639
652
  } else {
640
653
  context.lineTo(xGridlineEnd, startY);
641
654
  }
642
655
 
643
656
  context.stroke();
644
- startY += cellHeight(row);
657
+ startY += cellHeight(_row);
645
658
  }
646
659
 
647
- startY = columnHeaderHeight;
648
- context.textBaseline = 'middle';
649
- context.textAlign = 'center';
650
- context.font = defaultCellStyle.fontSize + 'px ' + defaultCellStyle.fontFamily;
651
- context.fillStyle = rowHeaderTextColor;
652
-
653
- for (var _iterator5 = _createForOfIteratorHelperLoose(rowSizes.index), _step5; !(_step5 = _iterator5()).done;) {
654
- var _row = _step5.value;
655
- var cellContent = _row + 1;
656
- var chStyle = {};
657
-
658
- if (rowSelectionActive && sely1 <= _row && sely2 >= _row) {
659
- chStyle = _extends({}, chStyle, {
660
- backgroundColor: rowColHeaderSelectionColor
661
- });
662
- }
660
+ if (!sheetStyle.hideRowHeaders) {
661
+ startY = sheetStyle.columnHeaderHeight;
662
+ context.textBaseline = 'middle';
663
+ context.textAlign = 'center';
664
+ context.font = defaultCellStyle.fontSize + 'px ' + defaultCellStyle.fontFamily;
665
+ context.fillStyle = rowHeaderTextColor;
666
+
667
+ for (var _iterator5 = _createForOfIteratorHelperLoose(rowSizes.index), _step5; !(_step5 = _iterator5()).done;) {
668
+ var row = _step5.value;
669
+ var cellContent = row + 1;
670
+ var chStyle = {};
671
+
672
+ if (rowSelectionActive && sely1 <= row && sely2 >= row) {
673
+ chStyle = _extends({}, chStyle, {
674
+ backgroundColor: rowColHeaderSelectionColor
675
+ });
676
+ }
663
677
 
664
- drawCell(context, '' + cellContent, chStyle, defaultColumnHeaderStyle, 0, startY, rowHeaderWidth, cellHeight(_row));
665
- startY += cellHeight(_row);
678
+ drawCell(context, '' + cellContent, chStyle, defaultColumnHeaderStyle, 0, startY, sheetStyle.rowHeaderWidth, cellHeight(row));
679
+ startY += cellHeight(row);
680
+ }
666
681
  }
667
682
 
668
- startX = rowHeaderWidth;
669
- context.textBaseline = 'middle';
670
- context.textAlign = 'center';
683
+ if (!sheetStyle.hideColumnHeaders) {
684
+ startX = sheetStyle.rowHeaderWidth;
685
+ context.textBaseline = 'middle';
686
+ context.textAlign = 'center';
671
687
 
672
- for (var _iterator6 = _createForOfIteratorHelperLoose(columnSizes.index), _step6; !(_step6 = _iterator6()).done;) {
673
- var _col = _step6.value;
674
- var cw = cellWidth(_col);
675
- var ch = columnHeaders(_col);
676
- var chcontent = ch !== null ? ch : excelHeaderString(_col + 1);
688
+ for (var _iterator6 = _createForOfIteratorHelperLoose(columnSizes.index), _step6; !(_step6 = _iterator6()).done;) {
689
+ var col = _step6.value;
690
+ var cw = cellWidth(col);
691
+ var ch = columnHeaders(col);
692
+ var chcontent = ch !== null ? ch : excelHeaderString(col + 1);
677
693
 
678
- var _chStyle = columnHeaderStyle(_col);
694
+ var _chStyle = columnHeaderStyle(col);
679
695
 
680
- if (colSelectionActive && selx1 <= _col && selx2 >= _col) {
681
- _chStyle = _extends({}, _chStyle, {
682
- backgroundColor: rowColHeaderSelectionColor
683
- });
684
- }
696
+ if (colSelectionActive && selx1 <= col && selx2 >= col) {
697
+ _chStyle = _extends({}, _chStyle, {
698
+ backgroundColor: rowColHeaderSelectionColor
699
+ });
700
+ }
685
701
 
686
- drawCell(context, chcontent, _chStyle, defaultColumnHeaderStyle, startX, 0, cw, columnHeaderHeight);
687
- startX += cw;
702
+ drawCell(context, chcontent, _chStyle, defaultColumnHeaderStyle, startX, 0, cw, sheetStyle.columnHeaderHeight);
703
+ startX += cw;
704
+ }
688
705
  }
689
706
 
690
707
  if (selectionActive) {
@@ -693,17 +710,13 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
693
710
  context.beginPath();
694
711
 
695
712
  if (rowSelectionActive) {
696
- var _p1x2 = Math.max(-100, p1.x);
697
-
698
- var _p1y2 = Math.max(-100, p1.y);
713
+ var _p1x = Math.max(-100, p1.x);
699
714
 
700
- context.rect(_p1x2, _p1y2, 100000, p2.y - p1.y);
715
+ context.rect(_p1x, p1.y, 100000, p2.y - p1.y);
701
716
  } else if (colSelectionActive) {
702
- var _p1x3 = Math.max(-100, p1.x);
703
-
704
- var _p1y3 = Math.max(-100, p1.y);
717
+ var _p1y = Math.max(-100, p1.y);
705
718
 
706
- context.rect(_p1x3, _p1y3, p2.x - p1.x, 100000);
719
+ context.rect(p1.x, _p1y, p2.x - p1.x, 100000);
707
720
  } else {
708
721
  context.rect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
709
722
  }
@@ -728,8 +741,8 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
728
741
  ky2 = knobArea.y1;
729
742
  }
730
743
 
731
- var knobPoint1 = cellToAbsCoordinate(kx1, ky1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
732
- var knobPoint2 = cellToAbsCoordinate(kx2 + 1, ky2 + 1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
744
+ var knobPoint1 = cellToAbsCoordinate(kx1, ky1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
745
+ var knobPoint2 = cellToAbsCoordinate(kx2 + 1, ky2 + 1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
733
746
  context.strokeStyle = knobAreaBorderColor;
734
747
  context.setLineDash([3, 3]);
735
748
  context.lineWidth = 1;
@@ -753,11 +766,11 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
753
766
  }
754
767
 
755
768
  context.textBaseline = 'middle';
756
- var yCoord = columnHeaderHeight;
769
+ var yCoord = sheetStyle.columnHeaderHeight;
757
770
 
758
771
  for (var _iterator7 = _createForOfIteratorHelperLoose(rowSizes.index), _step7; !(_step7 = _iterator7()).done;) {
759
772
  var _y = _step7.value;
760
- var xCoord = rowHeaderWidth;
773
+ var xCoord = sheetStyle.rowHeaderWidth;
761
774
 
762
775
  var _ch = cellHeight(_y);
763
776
 
@@ -782,7 +795,7 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
782
795
  }
783
796
 
784
797
  function Sheet(props) {
785
- var _props$inputComponent;
798
+ var _props$sheetStyle9, _props$sheetStyle10, _props$sheetStyle11, _props$sheetStyle12, _props$sheetStyle13, _props$sheetStyle14, _props$inputComponent;
786
799
 
787
800
  var canvasRef = useRef(null);
788
801
  var overlayRef = useRef(null);
@@ -883,8 +896,6 @@ function Sheet(props) {
883
896
  _useResizeObserver$he = _useResizeObserver.height,
884
897
  canvasHeight = _useResizeObserver$he === void 0 ? 3000 : _useResizeObserver$he;
885
898
 
886
- var freezeColumns = props.freezeColumns || 0;
887
- var freezeRows = props.freezeRows || 0;
888
899
  var cellWidth = useMemo(function () {
889
900
  return createRowOrColumnPropFunction(props.cellWidth, 100);
890
901
  }, [props.cellWidth]);
@@ -915,6 +926,20 @@ function Sheet(props) {
915
926
  var cellStyle = useMemo(function () {
916
927
  return createCellPropFunction(props.cellStyle, defaultCellStyle);
917
928
  }, [props.cellStyle]);
929
+ var sheetStyle = useMemo(function () {
930
+ var _props$sheetStyle, _props$sheetStyle2, _props$sheetStyle3, _props$sheetStyle4, _props$sheetStyle5, _props$sheetStyle6, _props$sheetStyle7, _props$sheetStyle8;
931
+
932
+ return {
933
+ freezeColumns: ((_props$sheetStyle = props.sheetStyle) === null || _props$sheetStyle === void 0 ? void 0 : _props$sheetStyle.freezeColumns) || 0,
934
+ freezeRows: ((_props$sheetStyle2 = props.sheetStyle) === null || _props$sheetStyle2 === void 0 ? void 0 : _props$sheetStyle2.freezeRows) || 0,
935
+ hideColumnHeaders: ((_props$sheetStyle3 = props.sheetStyle) === null || _props$sheetStyle3 === void 0 ? void 0 : _props$sheetStyle3.hideColumnHeaders) || false,
936
+ hideRowHeaders: ((_props$sheetStyle4 = props.sheetStyle) === null || _props$sheetStyle4 === void 0 ? void 0 : _props$sheetStyle4.hideRowHeaders) || false,
937
+ hideGridlines: ((_props$sheetStyle5 = props.sheetStyle) === null || _props$sheetStyle5 === void 0 ? void 0 : _props$sheetStyle5.hideGridlines) || false,
938
+ columnHeaderHeight: (_props$sheetStyle6 = props.sheetStyle) !== null && _props$sheetStyle6 !== void 0 && _props$sheetStyle6.hideColumnHeaders ? 1 : kColumnHeaderHeight,
939
+ rowHeaderWidth: (_props$sheetStyle7 = props.sheetStyle) !== null && _props$sheetStyle7 !== void 0 && _props$sheetStyle7.hideRowHeaders ? 1 : kRowHeaderWidth,
940
+ hideScrollBars: ((_props$sheetStyle8 = props.sheetStyle) === null || _props$sheetStyle8 === void 0 ? void 0 : _props$sheetStyle8.hideScrollBars) || false
941
+ };
942
+ }, [(_props$sheetStyle9 = props.sheetStyle) === null || _props$sheetStyle9 === void 0 ? void 0 : _props$sheetStyle9.freezeColumns, (_props$sheetStyle10 = props.sheetStyle) === null || _props$sheetStyle10 === void 0 ? void 0 : _props$sheetStyle10.freezeRows, (_props$sheetStyle11 = props.sheetStyle) === null || _props$sheetStyle11 === void 0 ? void 0 : _props$sheetStyle11.hideColumnHeaders, (_props$sheetStyle12 = props.sheetStyle) === null || _props$sheetStyle12 === void 0 ? void 0 : _props$sheetStyle12.hideGridlines, (_props$sheetStyle13 = props.sheetStyle) === null || _props$sheetStyle13 === void 0 ? void 0 : _props$sheetStyle13.hideRowHeaders, (_props$sheetStyle14 = props.sheetStyle) === null || _props$sheetStyle14 === void 0 ? void 0 : _props$sheetStyle14.hideScrollBars]);
918
943
  useEffect(function () {
919
944
  var currEditKey = editKeys ? editKeys(editCell.x, editCell.y) : '';
920
945
 
@@ -927,11 +952,11 @@ function Sheet(props) {
927
952
  }
928
953
  }, [editKeys]);
929
954
  var columnSizes = useMemo(function () {
930
- return calculateRowsOrColsSizes(freezeColumns, cellWidth, rowHeaderWidth, dataOffset.x, canvasWidth);
931
- }, [props.freezeColumns, cellWidth, dataOffset.x, canvasWidth]);
955
+ return calculateRowsOrColsSizes(sheetStyle.freezeColumns, cellWidth, sheetStyle.rowHeaderWidth, dataOffset.x, canvasWidth);
956
+ }, [sheetStyle, cellWidth, dataOffset.x, canvasWidth]);
932
957
  var rowSizes = useMemo(function () {
933
- return calculateRowsOrColsSizes(freezeRows, cellHeight, columnHeaderHeight, dataOffset.y, canvasHeight);
934
- }, [props.freezeRows, cellHeight, dataOffset.y, canvasHeight]);
958
+ return calculateRowsOrColsSizes(sheetStyle.freezeRows, cellHeight, sheetStyle.columnHeaderHeight, dataOffset.y, canvasHeight);
959
+ }, [sheetStyle, cellHeight, dataOffset.y, canvasHeight]);
935
960
 
936
961
  var changeSelection = function changeSelection(x1, y1, x2, y2, scrollToP2) {
937
962
  if (scrollToP2 === void 0) {
@@ -957,7 +982,7 @@ function Sheet(props) {
957
982
 
958
983
  if (x2 !== -1 && (!columnSizes.index.includes(x2) || columnSizes.index[columnSizes.index.length - 1] === x2)) {
959
984
  var lastVisibleColumnIndex = columnSizes.index[columnSizes.index.length - 1];
960
- var firstVisibleColumnIndex = columnSizes.index[freezeColumns];
985
+ var firstVisibleColumnIndex = columnSizes.index[sheetStyle.freezeColumns];
961
986
  var increment = 0;
962
987
 
963
988
  if (x2 >= lastVisibleColumnIndex) {
@@ -966,13 +991,13 @@ function Sheet(props) {
966
991
  increment = x2 - firstVisibleColumnIndex;
967
992
  }
968
993
 
969
- var newX = Math.max(dataOffset.x, freezeColumns) + increment;
994
+ var newX = Math.max(dataOffset.x, sheetStyle.freezeColumns) + increment;
970
995
  newDataOffset.x = newX;
971
996
  newScrollLeft = newX * scrollSpeed;
972
997
  }
973
998
 
974
999
  if (y2 !== -1 && (!rowSizes.index.includes(y2) || rowSizes.index[rowSizes.index.length - 1] === y2)) {
975
- var firstVisibleRowIndex = rowSizes.index[freezeRows];
1000
+ var firstVisibleRowIndex = rowSizes.index[sheetStyle.freezeRows];
976
1001
  var lastVisibleRowIndex = rowSizes.index[rowSizes.index.length - 1];
977
1002
  var _increment = 0;
978
1003
 
@@ -982,7 +1007,7 @@ function Sheet(props) {
982
1007
  _increment = y2 - firstVisibleRowIndex;
983
1008
  }
984
1009
 
985
- var newY = Math.max(dataOffset.y, freezeRows) + _increment;
1010
+ var newY = Math.max(dataOffset.y, sheetStyle.freezeRows) + _increment;
986
1011
 
987
1012
  newDataOffset.y = newY;
988
1013
  newScrollTop = newY * scrollSpeed;
@@ -1041,7 +1066,7 @@ function Sheet(props) {
1041
1066
  sely2 = selection.y1;
1042
1067
  }
1043
1068
 
1044
- var c = cellToAbsCoordinate(0, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1069
+ var c = cellToAbsCoordinate(0, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
1045
1070
  return {
1046
1071
  x: c.x + knobSize * 0.5,
1047
1072
  y: c.y + cellHeight(sely2)
@@ -1055,7 +1080,7 @@ function Sheet(props) {
1055
1080
  selx2 = selection.x1;
1056
1081
  }
1057
1082
 
1058
- var _c = cellToAbsCoordinate(selx2, 0, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1083
+ var _c = cellToAbsCoordinate(selx2, 0, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
1059
1084
 
1060
1085
  return {
1061
1086
  x: _c.x + cellWidth(selx2),
@@ -1076,7 +1101,7 @@ function Sheet(props) {
1076
1101
  _sely = selection.y1;
1077
1102
  }
1078
1103
 
1079
- var _c2 = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
1104
+ var _c2 = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
1080
1105
 
1081
1106
  return {
1082
1107
  x: _c2.x + cellWidth(_selx),
@@ -1088,7 +1113,7 @@ function Sheet(props) {
1088
1113
  x: -1,
1089
1114
  y: -1
1090
1115
  };
1091
- }, [selection, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight]);
1116
+ }, [selection, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle]);
1092
1117
  var hitMap = useMemo(function () {
1093
1118
  var hitM = {};
1094
1119
  var canvas = canvasRef.current;
@@ -1098,8 +1123,8 @@ function Sheet(props) {
1098
1123
  }
1099
1124
 
1100
1125
  resizeCanvas(canvas);
1101
- var yCoord = columnHeaderHeight;
1102
- var xCoord = rowHeaderWidth;
1126
+ var yCoord = sheetStyle.columnHeaderHeight;
1127
+ var xCoord = sheetStyle.rowHeaderWidth;
1103
1128
 
1104
1129
  for (var _iterator10 = _createForOfIteratorHelperLoose(columnSizes.index), _step10; !(_step10 = _iterator10()).done;) {
1105
1130
  var x = _step10.value;
@@ -1119,7 +1144,7 @@ function Sheet(props) {
1119
1144
 
1120
1145
  var w = obj.content instanceof HTMLImageElement ? obj.width || cellW : 0;
1121
1146
  var absX1 = applyAlignment(xCoord, cellW, finalStyle, w, obj.horiozntalAlign) + obj.x;
1122
- var absY1 = columnHeaderHeight * 0.5 + obj.y;
1147
+ var absY1 = sheetStyle.columnHeaderHeight * 0.5 + obj.y;
1123
1148
  var absX2 = absX1 + (obj.width || 0);
1124
1149
  var absY2 = absY1 + (obj.height || 0);
1125
1150
  var hitTarget = {
@@ -1158,7 +1183,7 @@ function Sheet(props) {
1158
1183
 
1159
1184
  for (var _iterator11 = _createForOfIteratorHelperLoose(rowSizes.index), _step11; !(_step11 = _iterator11()).done;) {
1160
1185
  var y = _step11.value;
1161
- xCoord = rowHeaderWidth;
1186
+ xCoord = sheetStyle.rowHeaderWidth;
1162
1187
 
1163
1188
  for (var _iterator13 = _createForOfIteratorHelperLoose(columnSizes.index), _step13; !(_step13 = _iterator13()).done;) {
1164
1189
  var _x2 = _step13.value;
@@ -1237,7 +1262,7 @@ function Sheet(props) {
1237
1262
  }
1238
1263
 
1239
1264
  return hitM;
1240
- }, [displayData, props.cellWidth, props.cellHeight, canvasRef, columnSizes, rowSizes, dataOffset.x, dataOffset.y]);
1265
+ }, [displayData, props.cellWidth, props.cellHeight, canvasRef, columnSizes, rowSizes, dataOffset.x, dataOffset.y, sheetStyle]);
1241
1266
  useEffect(function () {
1242
1267
  var canvas = canvasRef.current;
1243
1268
 
@@ -1252,12 +1277,12 @@ function Sheet(props) {
1252
1277
  }
1253
1278
 
1254
1279
  var animationFrameId = window.requestAnimationFrame(function () {
1255
- renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, props.hideGridlines || false);
1280
+ renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle);
1256
1281
  });
1257
1282
  return function () {
1258
1283
  window.cancelAnimationFrame(animationFrameId);
1259
1284
  };
1260
- }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, props.hideGridlines]);
1285
+ }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle]);
1261
1286
 
1262
1287
  var setFocusToTextArea = function setFocusToTextArea() {
1263
1288
  if (copyPasteTextAreaRef.current) {
@@ -1300,12 +1325,12 @@ function Sheet(props) {
1300
1325
  var clipboardData = e.clipboardData || window.clipboardData;
1301
1326
  var types = clipboardData.types;
1302
1327
 
1303
- if (types.includes('text/rtf') && types.includes('text/plain') || types.includes('text/plain') && !types.includes('text/html')) {
1304
- var text = clipboardData.getData('text/plain');
1305
- parsePastedText(text);
1306
- } else if (types.includes('text/html')) {
1328
+ if (types.includes('text/html')) {
1307
1329
  var pastedHtml = clipboardData.getData('text/html');
1308
1330
  parsePastedHtml(pastedHtml);
1331
+ } else if (types.includes('text/plain')) {
1332
+ var text = clipboardData.getData('text/plain');
1333
+ parsePastedText(text);
1309
1334
  }
1310
1335
  };
1311
1336
 
@@ -1386,12 +1411,12 @@ function Sheet(props) {
1386
1411
  var p = td.children[0];
1387
1412
 
1388
1413
  if (p.children.length !== 0 && p.children[0].nodeName === 'FONT') {
1389
- str = p.children[0].innerHTML;
1414
+ str = p.children[0].textContent.trim();
1390
1415
  } else {
1391
- str = p.innerHTML;
1416
+ str = p.textContent.trim();
1392
1417
  }
1393
1418
  } else {
1394
- str = td.innerHTML;
1419
+ str = td.textContent.trim();
1395
1420
  }
1396
1421
 
1397
1422
  str = str.replaceAll('\n', '');
@@ -1659,7 +1684,7 @@ function Sheet(props) {
1659
1684
  }
1660
1685
  }
1661
1686
 
1662
- if (y < columnHeaderHeight) {
1687
+ if (!sheetStyle.hideColumnHeaders && y < sheetStyle.columnHeaderHeight) {
1663
1688
  for (var colIdx = 0; colIdx < columnSizes.index.length; colIdx++) {
1664
1689
  var start = columnSizes.start[colIdx];
1665
1690
  var end = columnSizes.end[colIdx];
@@ -1692,7 +1717,7 @@ function Sheet(props) {
1692
1717
  }
1693
1718
  }
1694
1719
 
1695
- if (x < rowHeaderWidth) {
1720
+ if (!sheetStyle.hideRowHeaders && x < sheetStyle.rowHeaderWidth) {
1696
1721
  for (var rowIdx = 0; rowIdx < rowSizes.index.length; rowIdx++) {
1697
1722
  var _start = rowSizes.start[rowIdx];
1698
1723
  var _end = rowSizes.end[rowIdx];
@@ -1749,7 +1774,7 @@ function Sheet(props) {
1749
1774
 
1750
1775
  var scrollToP2 = true;
1751
1776
 
1752
- if (x < rowHeaderWidth) {
1777
+ if (!sheetStyle.hideRowHeaders && x < sheetStyle.rowHeaderWidth) {
1753
1778
  scrollToP2 = false;
1754
1779
  setRowSelectionInProgress(true);
1755
1780
  sel1.x = -1;
@@ -1758,7 +1783,7 @@ function Sheet(props) {
1758
1783
  setRowSelectionInProgress(false);
1759
1784
  }
1760
1785
 
1761
- if (y < columnHeaderHeight) {
1786
+ if (!sheetStyle.hideColumnHeaders && y < sheetStyle.columnHeaderHeight) {
1762
1787
  scrollToP2 = false;
1763
1788
  setColumnSelectionInProgress(true);
1764
1789
  sel1.y = -1;
@@ -1950,8 +1975,8 @@ function Sheet(props) {
1950
1975
  }
1951
1976
  }
1952
1977
 
1953
- if (props.onCellWidthChange && y < columnHeaderHeight) {
1954
- var xx = rowHeaderWidth;
1978
+ if (!sheetStyle.hideColumnHeaders && props.onCellWidthChange && y < sheetStyle.columnHeaderHeight) {
1979
+ var xx = sheetStyle.rowHeaderWidth;
1955
1980
 
1956
1981
  for (var _iterator21 = _createForOfIteratorHelperLoose(columnSizes.index), _step21; !(_step21 = _iterator21()).done;) {
1957
1982
  var col = _step21.value;
@@ -1965,8 +1990,8 @@ function Sheet(props) {
1965
1990
  }
1966
1991
  }
1967
1992
 
1968
- if (props.onCellHeightChange && x < rowHeaderWidth) {
1969
- var yy = columnHeaderHeight;
1993
+ if (!sheetStyle.hideRowHeaders && props.onCellHeightChange && x < sheetStyle.rowHeaderWidth) {
1994
+ var yy = sheetStyle.columnHeaderHeight;
1970
1995
 
1971
1996
  for (var _iterator22 = _createForOfIteratorHelperLoose(rowSizes.index), _step22; !(_step22 = _iterator22()).done;) {
1972
1997
  var row = _step22.value;
@@ -2310,7 +2335,7 @@ function Sheet(props) {
2310
2335
  y2 = _ref2[1];
2311
2336
  }
2312
2337
 
2313
- if (!(y > columnHeaderHeight && x > rowHeaderWidth)) {
2338
+ if (!(y > sheetStyle.columnHeaderHeight && x > sheetStyle.rowHeaderWidth)) {
2314
2339
  return;
2315
2340
  }
2316
2341
 
@@ -2338,7 +2363,7 @@ function Sheet(props) {
2338
2363
  var editTextTextAlign = 'right';
2339
2364
 
2340
2365
  if (editMode) {
2341
- editTextPosition = cellToAbsCoordinate(editCell.x, editCell.y, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
2366
+ editTextPosition = cellToAbsCoordinate(editCell.x, editCell.y, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
2342
2367
  var style = cellStyle(editCell.x, editCell.y);
2343
2368
  editTextPosition.x += 1;
2344
2369
  editTextPosition.y += 1;
@@ -2368,17 +2393,36 @@ function Sheet(props) {
2368
2393
  var input = (_props$inputComponent = props.inputComponent) === null || _props$inputComponent === void 0 ? void 0 : _props$inputComponent.call(props, editCell.x, editCell.y, _extends({}, inputProps, {
2369
2394
  onChange: setEditValue
2370
2395
  }), commitEditingCell);
2396
+ var overlayDivClassName = styles.sheetscroll;
2397
+ var overlayDivStyles = {
2398
+ position: 'absolute',
2399
+ width: '100%',
2400
+ height: '100%',
2401
+ top: 0,
2402
+ left: 0,
2403
+ overflow: 'scroll',
2404
+ borderBottom: '1px solid #ddd'
2405
+ };
2406
+ var canvasStyles = {
2407
+ width: 'calc(100% - 14px)',
2408
+ height: 'calc(100% - 15px)',
2409
+ outline: '1px solid #ddd'
2410
+ };
2411
+
2412
+ if (sheetStyle.hideScrollBars) {
2413
+ delete canvasStyles['outline'];
2414
+ delete overlayDivStyles['borderBottom'];
2415
+ overlayDivClassName = '';
2416
+ canvasStyles.width = 'calc(100%)';
2417
+ }
2418
+
2371
2419
  return React.createElement("div", {
2372
2420
  style: {
2373
2421
  position: 'relative',
2374
2422
  height: '100%'
2375
2423
  }
2376
2424
  }, React.createElement("canvas", {
2377
- style: {
2378
- width: 'calc(100% - 14px)',
2379
- height: 'calc(100% - 15px)',
2380
- outline: '1px solid #ddd'
2381
- },
2425
+ style: canvasStyles,
2382
2426
  ref: canvasRef
2383
2427
  }), React.createElement("div", {
2384
2428
  ref: overlayRef,
@@ -2388,16 +2432,8 @@ function Sheet(props) {
2388
2432
  onMouseLeave: onMouseLeave,
2389
2433
  onContextMenu: onContextMenu,
2390
2434
  onScroll: onScroll,
2391
- className: styles.sheetscroll,
2392
- style: {
2393
- position: 'absolute',
2394
- width: '100%',
2395
- height: '100%',
2396
- top: 0,
2397
- left: 0,
2398
- overflow: 'scroll',
2399
- borderBottom: '1px solid #ddd'
2400
- }
2435
+ className: overlayDivClassName,
2436
+ style: overlayDivStyles
2401
2437
  }, React.createElement("div", {
2402
2438
  style: {
2403
2439
  position: 'absolute',