sheet-happens 0.0.18 → 0.0.19
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.d.ts +8 -2
- package/dist/index.js +160 -116
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +160 -116
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -68,11 +68,11 @@ var selBackColor = '#e9f0fd';
|
|
|
68
68
|
var knobSize = 6;
|
|
69
69
|
var gridColor = '#e2e3e3';
|
|
70
70
|
var knobAreaBorderColor = '#707070';
|
|
71
|
-
var
|
|
71
|
+
var kRowHeaderWidth = 50;
|
|
72
72
|
var rowHeaderBackgroundColor = '#f8f9fa';
|
|
73
73
|
var rowHeaderTextColor = '#666666';
|
|
74
74
|
var rowHeaderSelectedBackgroundColor = '#e8eaed';
|
|
75
|
-
var
|
|
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
|
|
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,
|
|
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
|
|
|
@@ -586,105 +593,119 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
586
593
|
}
|
|
587
594
|
}
|
|
588
595
|
|
|
589
|
-
|
|
590
|
-
|
|
596
|
+
if (!sheetStyle.hideRowHeaders) {
|
|
597
|
+
context.fillStyle = rowHeaderBackgroundColor;
|
|
598
|
+
context.fillRect(0, 0, sheetStyle.rowHeaderWidth, context.canvas.height);
|
|
591
599
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
600
|
+
if (selectionActive) {
|
|
601
|
+
context.fillStyle = rowHeaderSelectedBackgroundColor;
|
|
602
|
+
context.fillRect(0, p1.y, sheetStyle.rowHeaderWidth, p2.y - p1.y);
|
|
603
|
+
}
|
|
595
604
|
}
|
|
596
605
|
|
|
597
|
-
|
|
598
|
-
|
|
606
|
+
if (!sheetStyle.hideColumnHeaders) {
|
|
607
|
+
context.fillStyle = columnHeaderBackgroundColor;
|
|
608
|
+
context.fillRect(0, 0, context.canvas.width, sheetStyle.columnHeaderHeight);
|
|
599
609
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
610
|
+
if (selectionActive) {
|
|
611
|
+
context.fillStyle = columnHeaderSelectedBackgroundColor;
|
|
612
|
+
context.fillRect(p1.x, 0, p2.x - p1.x, sheetStyle.columnHeaderHeight);
|
|
613
|
+
}
|
|
603
614
|
}
|
|
604
615
|
|
|
605
616
|
context.strokeStyle = gridColor;
|
|
606
617
|
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;
|
|
618
|
+
var startX = sheetStyle.rowHeaderWidth;
|
|
619
|
+
var startY = sheetStyle.columnHeaderHeight;
|
|
611
620
|
var first = true;
|
|
621
|
+
var yGridlineEnd = sheetStyle.hideGridlines ? sheetStyle.columnHeaderHeight : context.canvas.height;
|
|
612
622
|
|
|
613
623
|
for (var _iterator3 = _createForOfIteratorHelperLoose(columnSizes.index), _step3; !(_step3 = _iterator3()).done;) {
|
|
614
|
-
var
|
|
624
|
+
var _col = _step3.value;
|
|
615
625
|
context.beginPath();
|
|
616
626
|
context.moveTo(startX, 0);
|
|
617
627
|
|
|
618
628
|
if (first) {
|
|
619
|
-
|
|
629
|
+
if (!sheetStyle.hideRowHeaders) {
|
|
630
|
+
context.lineTo(startX, context.canvas.height);
|
|
631
|
+
}
|
|
632
|
+
|
|
620
633
|
first = false;
|
|
621
634
|
} else {
|
|
622
635
|
context.lineTo(startX, yGridlineEnd);
|
|
623
636
|
}
|
|
624
637
|
|
|
625
638
|
context.stroke();
|
|
626
|
-
startX += cellWidth(
|
|
639
|
+
startX += cellWidth(_col);
|
|
627
640
|
}
|
|
628
641
|
|
|
642
|
+
var xGridlineEnd = sheetStyle.hideGridlines ? sheetStyle.rowHeaderWidth : context.canvas.width;
|
|
629
643
|
first = true;
|
|
630
644
|
|
|
631
645
|
for (var _iterator4 = _createForOfIteratorHelperLoose(rowSizes.index), _step4; !(_step4 = _iterator4()).done;) {
|
|
632
|
-
var
|
|
646
|
+
var _row = _step4.value;
|
|
633
647
|
context.beginPath();
|
|
634
648
|
context.moveTo(0, startY);
|
|
635
649
|
|
|
636
650
|
if (first) {
|
|
637
|
-
|
|
651
|
+
if (!sheetStyle.hideColumnHeaders) {
|
|
652
|
+
context.lineTo(context.canvas.width, startY);
|
|
653
|
+
}
|
|
654
|
+
|
|
638
655
|
first = false;
|
|
639
656
|
} else {
|
|
640
657
|
context.lineTo(xGridlineEnd, startY);
|
|
641
658
|
}
|
|
642
659
|
|
|
643
660
|
context.stroke();
|
|
644
|
-
startY += cellHeight(
|
|
661
|
+
startY += cellHeight(_row);
|
|
645
662
|
}
|
|
646
663
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
var
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
664
|
+
if (!sheetStyle.hideRowHeaders) {
|
|
665
|
+
startY = sheetStyle.columnHeaderHeight;
|
|
666
|
+
context.textBaseline = 'middle';
|
|
667
|
+
context.textAlign = 'center';
|
|
668
|
+
context.font = defaultCellStyle.fontSize + 'px ' + defaultCellStyle.fontFamily;
|
|
669
|
+
context.fillStyle = rowHeaderTextColor;
|
|
670
|
+
|
|
671
|
+
for (var _iterator5 = _createForOfIteratorHelperLoose(rowSizes.index), _step5; !(_step5 = _iterator5()).done;) {
|
|
672
|
+
var row = _step5.value;
|
|
673
|
+
var cellContent = row + 1;
|
|
674
|
+
var chStyle = {};
|
|
675
|
+
|
|
676
|
+
if (rowSelectionActive && sely1 <= row && sely2 >= row) {
|
|
677
|
+
chStyle = _extends({}, chStyle, {
|
|
678
|
+
backgroundColor: rowColHeaderSelectionColor
|
|
679
|
+
});
|
|
680
|
+
}
|
|
663
681
|
|
|
664
|
-
|
|
665
|
-
|
|
682
|
+
drawCell(context, '' + cellContent, chStyle, defaultColumnHeaderStyle, 0, startY, sheetStyle.rowHeaderWidth, cellHeight(row));
|
|
683
|
+
startY += cellHeight(row);
|
|
684
|
+
}
|
|
666
685
|
}
|
|
667
686
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
687
|
+
if (!sheetStyle.hideColumnHeaders) {
|
|
688
|
+
startX = sheetStyle.rowHeaderWidth;
|
|
689
|
+
context.textBaseline = 'middle';
|
|
690
|
+
context.textAlign = 'center';
|
|
671
691
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
692
|
+
for (var _iterator6 = _createForOfIteratorHelperLoose(columnSizes.index), _step6; !(_step6 = _iterator6()).done;) {
|
|
693
|
+
var col = _step6.value;
|
|
694
|
+
var cw = cellWidth(col);
|
|
695
|
+
var ch = columnHeaders(col);
|
|
696
|
+
var chcontent = ch !== null ? ch : excelHeaderString(col + 1);
|
|
677
697
|
|
|
678
|
-
|
|
698
|
+
var _chStyle = columnHeaderStyle(col);
|
|
679
699
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
700
|
+
if (colSelectionActive && selx1 <= col && selx2 >= col) {
|
|
701
|
+
_chStyle = _extends({}, _chStyle, {
|
|
702
|
+
backgroundColor: rowColHeaderSelectionColor
|
|
703
|
+
});
|
|
704
|
+
}
|
|
685
705
|
|
|
686
|
-
|
|
687
|
-
|
|
706
|
+
drawCell(context, chcontent, _chStyle, defaultColumnHeaderStyle, startX, 0, cw, sheetStyle.columnHeaderHeight);
|
|
707
|
+
startX += cw;
|
|
708
|
+
}
|
|
688
709
|
}
|
|
689
710
|
|
|
690
711
|
if (selectionActive) {
|
|
@@ -728,8 +749,8 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
728
749
|
ky2 = knobArea.y1;
|
|
729
750
|
}
|
|
730
751
|
|
|
731
|
-
var knobPoint1 = cellToAbsCoordinate(kx1, ky1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
732
|
-
var knobPoint2 = cellToAbsCoordinate(kx2 + 1, ky2 + 1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
752
|
+
var knobPoint1 = cellToAbsCoordinate(kx1, ky1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
753
|
+
var knobPoint2 = cellToAbsCoordinate(kx2 + 1, ky2 + 1, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
733
754
|
context.strokeStyle = knobAreaBorderColor;
|
|
734
755
|
context.setLineDash([3, 3]);
|
|
735
756
|
context.lineWidth = 1;
|
|
@@ -753,11 +774,11 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
753
774
|
}
|
|
754
775
|
|
|
755
776
|
context.textBaseline = 'middle';
|
|
756
|
-
var yCoord = columnHeaderHeight;
|
|
777
|
+
var yCoord = sheetStyle.columnHeaderHeight;
|
|
757
778
|
|
|
758
779
|
for (var _iterator7 = _createForOfIteratorHelperLoose(rowSizes.index), _step7; !(_step7 = _iterator7()).done;) {
|
|
759
780
|
var _y = _step7.value;
|
|
760
|
-
var xCoord = rowHeaderWidth;
|
|
781
|
+
var xCoord = sheetStyle.rowHeaderWidth;
|
|
761
782
|
|
|
762
783
|
var _ch = cellHeight(_y);
|
|
763
784
|
|
|
@@ -782,7 +803,7 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
782
803
|
}
|
|
783
804
|
|
|
784
805
|
function Sheet(props) {
|
|
785
|
-
var _props$inputComponent;
|
|
806
|
+
var _props$sheetStyle9, _props$sheetStyle10, _props$sheetStyle11, _props$sheetStyle12, _props$sheetStyle13, _props$sheetStyle14, _props$inputComponent;
|
|
786
807
|
|
|
787
808
|
var canvasRef = useRef(null);
|
|
788
809
|
var overlayRef = useRef(null);
|
|
@@ -883,8 +904,6 @@ function Sheet(props) {
|
|
|
883
904
|
_useResizeObserver$he = _useResizeObserver.height,
|
|
884
905
|
canvasHeight = _useResizeObserver$he === void 0 ? 3000 : _useResizeObserver$he;
|
|
885
906
|
|
|
886
|
-
var freezeColumns = props.freezeColumns || 0;
|
|
887
|
-
var freezeRows = props.freezeRows || 0;
|
|
888
907
|
var cellWidth = useMemo(function () {
|
|
889
908
|
return createRowOrColumnPropFunction(props.cellWidth, 100);
|
|
890
909
|
}, [props.cellWidth]);
|
|
@@ -915,6 +934,20 @@ function Sheet(props) {
|
|
|
915
934
|
var cellStyle = useMemo(function () {
|
|
916
935
|
return createCellPropFunction(props.cellStyle, defaultCellStyle);
|
|
917
936
|
}, [props.cellStyle]);
|
|
937
|
+
var sheetStyle = useMemo(function () {
|
|
938
|
+
var _props$sheetStyle, _props$sheetStyle2, _props$sheetStyle3, _props$sheetStyle4, _props$sheetStyle5, _props$sheetStyle6, _props$sheetStyle7, _props$sheetStyle8;
|
|
939
|
+
|
|
940
|
+
return {
|
|
941
|
+
freezeColumns: ((_props$sheetStyle = props.sheetStyle) === null || _props$sheetStyle === void 0 ? void 0 : _props$sheetStyle.freezeColumns) || 0,
|
|
942
|
+
freezeRows: ((_props$sheetStyle2 = props.sheetStyle) === null || _props$sheetStyle2 === void 0 ? void 0 : _props$sheetStyle2.freezeRows) || 0,
|
|
943
|
+
hideColumnHeaders: ((_props$sheetStyle3 = props.sheetStyle) === null || _props$sheetStyle3 === void 0 ? void 0 : _props$sheetStyle3.hideColumnHeaders) || false,
|
|
944
|
+
hideRowHeaders: ((_props$sheetStyle4 = props.sheetStyle) === null || _props$sheetStyle4 === void 0 ? void 0 : _props$sheetStyle4.hideRowHeaders) || false,
|
|
945
|
+
hideGridlines: ((_props$sheetStyle5 = props.sheetStyle) === null || _props$sheetStyle5 === void 0 ? void 0 : _props$sheetStyle5.hideGridlines) || false,
|
|
946
|
+
columnHeaderHeight: (_props$sheetStyle6 = props.sheetStyle) !== null && _props$sheetStyle6 !== void 0 && _props$sheetStyle6.hideColumnHeaders ? 1 : kColumnHeaderHeight,
|
|
947
|
+
rowHeaderWidth: (_props$sheetStyle7 = props.sheetStyle) !== null && _props$sheetStyle7 !== void 0 && _props$sheetStyle7.hideRowHeaders ? 1 : kRowHeaderWidth,
|
|
948
|
+
hideScrollBars: ((_props$sheetStyle8 = props.sheetStyle) === null || _props$sheetStyle8 === void 0 ? void 0 : _props$sheetStyle8.hideScrollBars) || false
|
|
949
|
+
};
|
|
950
|
+
}, [(_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
951
|
useEffect(function () {
|
|
919
952
|
var currEditKey = editKeys ? editKeys(editCell.x, editCell.y) : '';
|
|
920
953
|
|
|
@@ -927,11 +960,11 @@ function Sheet(props) {
|
|
|
927
960
|
}
|
|
928
961
|
}, [editKeys]);
|
|
929
962
|
var columnSizes = useMemo(function () {
|
|
930
|
-
return calculateRowsOrColsSizes(freezeColumns, cellWidth, rowHeaderWidth, dataOffset.x, canvasWidth);
|
|
931
|
-
}, [
|
|
963
|
+
return calculateRowsOrColsSizes(sheetStyle.freezeColumns, cellWidth, sheetStyle.rowHeaderWidth, dataOffset.x, canvasWidth);
|
|
964
|
+
}, [sheetStyle, cellWidth, dataOffset.x, canvasWidth]);
|
|
932
965
|
var rowSizes = useMemo(function () {
|
|
933
|
-
return calculateRowsOrColsSizes(freezeRows, cellHeight, columnHeaderHeight, dataOffset.y, canvasHeight);
|
|
934
|
-
}, [
|
|
966
|
+
return calculateRowsOrColsSizes(sheetStyle.freezeRows, cellHeight, sheetStyle.columnHeaderHeight, dataOffset.y, canvasHeight);
|
|
967
|
+
}, [sheetStyle, cellHeight, dataOffset.y, canvasHeight]);
|
|
935
968
|
|
|
936
969
|
var changeSelection = function changeSelection(x1, y1, x2, y2, scrollToP2) {
|
|
937
970
|
if (scrollToP2 === void 0) {
|
|
@@ -957,7 +990,7 @@ function Sheet(props) {
|
|
|
957
990
|
|
|
958
991
|
if (x2 !== -1 && (!columnSizes.index.includes(x2) || columnSizes.index[columnSizes.index.length - 1] === x2)) {
|
|
959
992
|
var lastVisibleColumnIndex = columnSizes.index[columnSizes.index.length - 1];
|
|
960
|
-
var firstVisibleColumnIndex = columnSizes.index[freezeColumns];
|
|
993
|
+
var firstVisibleColumnIndex = columnSizes.index[sheetStyle.freezeColumns];
|
|
961
994
|
var increment = 0;
|
|
962
995
|
|
|
963
996
|
if (x2 >= lastVisibleColumnIndex) {
|
|
@@ -966,13 +999,13 @@ function Sheet(props) {
|
|
|
966
999
|
increment = x2 - firstVisibleColumnIndex;
|
|
967
1000
|
}
|
|
968
1001
|
|
|
969
|
-
var newX = Math.max(dataOffset.x, freezeColumns) + increment;
|
|
1002
|
+
var newX = Math.max(dataOffset.x, sheetStyle.freezeColumns) + increment;
|
|
970
1003
|
newDataOffset.x = newX;
|
|
971
1004
|
newScrollLeft = newX * scrollSpeed;
|
|
972
1005
|
}
|
|
973
1006
|
|
|
974
1007
|
if (y2 !== -1 && (!rowSizes.index.includes(y2) || rowSizes.index[rowSizes.index.length - 1] === y2)) {
|
|
975
|
-
var firstVisibleRowIndex = rowSizes.index[freezeRows];
|
|
1008
|
+
var firstVisibleRowIndex = rowSizes.index[sheetStyle.freezeRows];
|
|
976
1009
|
var lastVisibleRowIndex = rowSizes.index[rowSizes.index.length - 1];
|
|
977
1010
|
var _increment = 0;
|
|
978
1011
|
|
|
@@ -982,7 +1015,7 @@ function Sheet(props) {
|
|
|
982
1015
|
_increment = y2 - firstVisibleRowIndex;
|
|
983
1016
|
}
|
|
984
1017
|
|
|
985
|
-
var newY = Math.max(dataOffset.y, freezeRows) + _increment;
|
|
1018
|
+
var newY = Math.max(dataOffset.y, sheetStyle.freezeRows) + _increment;
|
|
986
1019
|
|
|
987
1020
|
newDataOffset.y = newY;
|
|
988
1021
|
newScrollTop = newY * scrollSpeed;
|
|
@@ -1041,7 +1074,7 @@ function Sheet(props) {
|
|
|
1041
1074
|
sely2 = selection.y1;
|
|
1042
1075
|
}
|
|
1043
1076
|
|
|
1044
|
-
var c = cellToAbsCoordinate(0, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
1077
|
+
var c = cellToAbsCoordinate(0, sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
1045
1078
|
return {
|
|
1046
1079
|
x: c.x + knobSize * 0.5,
|
|
1047
1080
|
y: c.y + cellHeight(sely2)
|
|
@@ -1055,7 +1088,7 @@ function Sheet(props) {
|
|
|
1055
1088
|
selx2 = selection.x1;
|
|
1056
1089
|
}
|
|
1057
1090
|
|
|
1058
|
-
var _c = cellToAbsCoordinate(selx2, 0, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
1091
|
+
var _c = cellToAbsCoordinate(selx2, 0, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
1059
1092
|
|
|
1060
1093
|
return {
|
|
1061
1094
|
x: _c.x + cellWidth(selx2),
|
|
@@ -1076,7 +1109,7 @@ function Sheet(props) {
|
|
|
1076
1109
|
_sely = selection.y1;
|
|
1077
1110
|
}
|
|
1078
1111
|
|
|
1079
|
-
var _c2 = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
1112
|
+
var _c2 = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
1080
1113
|
|
|
1081
1114
|
return {
|
|
1082
1115
|
x: _c2.x + cellWidth(_selx),
|
|
@@ -1088,7 +1121,7 @@ function Sheet(props) {
|
|
|
1088
1121
|
x: -1,
|
|
1089
1122
|
y: -1
|
|
1090
1123
|
};
|
|
1091
|
-
}, [selection, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight]);
|
|
1124
|
+
}, [selection, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle]);
|
|
1092
1125
|
var hitMap = useMemo(function () {
|
|
1093
1126
|
var hitM = {};
|
|
1094
1127
|
var canvas = canvasRef.current;
|
|
@@ -1098,8 +1131,8 @@ function Sheet(props) {
|
|
|
1098
1131
|
}
|
|
1099
1132
|
|
|
1100
1133
|
resizeCanvas(canvas);
|
|
1101
|
-
var yCoord = columnHeaderHeight;
|
|
1102
|
-
var xCoord = rowHeaderWidth;
|
|
1134
|
+
var yCoord = sheetStyle.columnHeaderHeight;
|
|
1135
|
+
var xCoord = sheetStyle.rowHeaderWidth;
|
|
1103
1136
|
|
|
1104
1137
|
for (var _iterator10 = _createForOfIteratorHelperLoose(columnSizes.index), _step10; !(_step10 = _iterator10()).done;) {
|
|
1105
1138
|
var x = _step10.value;
|
|
@@ -1119,7 +1152,7 @@ function Sheet(props) {
|
|
|
1119
1152
|
|
|
1120
1153
|
var w = obj.content instanceof HTMLImageElement ? obj.width || cellW : 0;
|
|
1121
1154
|
var absX1 = applyAlignment(xCoord, cellW, finalStyle, w, obj.horiozntalAlign) + obj.x;
|
|
1122
|
-
var absY1 = columnHeaderHeight * 0.5 + obj.y;
|
|
1155
|
+
var absY1 = sheetStyle.columnHeaderHeight * 0.5 + obj.y;
|
|
1123
1156
|
var absX2 = absX1 + (obj.width || 0);
|
|
1124
1157
|
var absY2 = absY1 + (obj.height || 0);
|
|
1125
1158
|
var hitTarget = {
|
|
@@ -1158,7 +1191,7 @@ function Sheet(props) {
|
|
|
1158
1191
|
|
|
1159
1192
|
for (var _iterator11 = _createForOfIteratorHelperLoose(rowSizes.index), _step11; !(_step11 = _iterator11()).done;) {
|
|
1160
1193
|
var y = _step11.value;
|
|
1161
|
-
xCoord = rowHeaderWidth;
|
|
1194
|
+
xCoord = sheetStyle.rowHeaderWidth;
|
|
1162
1195
|
|
|
1163
1196
|
for (var _iterator13 = _createForOfIteratorHelperLoose(columnSizes.index), _step13; !(_step13 = _iterator13()).done;) {
|
|
1164
1197
|
var _x2 = _step13.value;
|
|
@@ -1237,7 +1270,7 @@ function Sheet(props) {
|
|
|
1237
1270
|
}
|
|
1238
1271
|
|
|
1239
1272
|
return hitM;
|
|
1240
|
-
}, [displayData, props.cellWidth, props.cellHeight, canvasRef, columnSizes, rowSizes, dataOffset.x, dataOffset.y]);
|
|
1273
|
+
}, [displayData, props.cellWidth, props.cellHeight, canvasRef, columnSizes, rowSizes, dataOffset.x, dataOffset.y, sheetStyle]);
|
|
1241
1274
|
useEffect(function () {
|
|
1242
1275
|
var canvas = canvasRef.current;
|
|
1243
1276
|
|
|
@@ -1252,12 +1285,12 @@ function Sheet(props) {
|
|
|
1252
1285
|
}
|
|
1253
1286
|
|
|
1254
1287
|
var animationFrameId = window.requestAnimationFrame(function () {
|
|
1255
|
-
renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates,
|
|
1288
|
+
renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle);
|
|
1256
1289
|
});
|
|
1257
1290
|
return function () {
|
|
1258
1291
|
window.cancelAnimationFrame(animationFrameId);
|
|
1259
1292
|
};
|
|
1260
|
-
}, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates,
|
|
1293
|
+
}, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle]);
|
|
1261
1294
|
|
|
1262
1295
|
var setFocusToTextArea = function setFocusToTextArea() {
|
|
1263
1296
|
if (copyPasteTextAreaRef.current) {
|
|
@@ -1659,7 +1692,7 @@ function Sheet(props) {
|
|
|
1659
1692
|
}
|
|
1660
1693
|
}
|
|
1661
1694
|
|
|
1662
|
-
if (y < columnHeaderHeight) {
|
|
1695
|
+
if (!sheetStyle.hideColumnHeaders && y < sheetStyle.columnHeaderHeight) {
|
|
1663
1696
|
for (var colIdx = 0; colIdx < columnSizes.index.length; colIdx++) {
|
|
1664
1697
|
var start = columnSizes.start[colIdx];
|
|
1665
1698
|
var end = columnSizes.end[colIdx];
|
|
@@ -1692,7 +1725,7 @@ function Sheet(props) {
|
|
|
1692
1725
|
}
|
|
1693
1726
|
}
|
|
1694
1727
|
|
|
1695
|
-
if (x < rowHeaderWidth) {
|
|
1728
|
+
if (!sheetStyle.hideRowHeaders && x < sheetStyle.rowHeaderWidth) {
|
|
1696
1729
|
for (var rowIdx = 0; rowIdx < rowSizes.index.length; rowIdx++) {
|
|
1697
1730
|
var _start = rowSizes.start[rowIdx];
|
|
1698
1731
|
var _end = rowSizes.end[rowIdx];
|
|
@@ -1749,7 +1782,7 @@ function Sheet(props) {
|
|
|
1749
1782
|
|
|
1750
1783
|
var scrollToP2 = true;
|
|
1751
1784
|
|
|
1752
|
-
if (x < rowHeaderWidth) {
|
|
1785
|
+
if (!sheetStyle.hideRowHeaders && x < sheetStyle.rowHeaderWidth) {
|
|
1753
1786
|
scrollToP2 = false;
|
|
1754
1787
|
setRowSelectionInProgress(true);
|
|
1755
1788
|
sel1.x = -1;
|
|
@@ -1758,7 +1791,7 @@ function Sheet(props) {
|
|
|
1758
1791
|
setRowSelectionInProgress(false);
|
|
1759
1792
|
}
|
|
1760
1793
|
|
|
1761
|
-
if (y < columnHeaderHeight) {
|
|
1794
|
+
if (!sheetStyle.hideColumnHeaders && y < sheetStyle.columnHeaderHeight) {
|
|
1762
1795
|
scrollToP2 = false;
|
|
1763
1796
|
setColumnSelectionInProgress(true);
|
|
1764
1797
|
sel1.y = -1;
|
|
@@ -1950,8 +1983,8 @@ function Sheet(props) {
|
|
|
1950
1983
|
}
|
|
1951
1984
|
}
|
|
1952
1985
|
|
|
1953
|
-
if (props.onCellWidthChange && y < columnHeaderHeight) {
|
|
1954
|
-
var xx = rowHeaderWidth;
|
|
1986
|
+
if (!sheetStyle.hideColumnHeaders && props.onCellWidthChange && y < sheetStyle.columnHeaderHeight) {
|
|
1987
|
+
var xx = sheetStyle.rowHeaderWidth;
|
|
1955
1988
|
|
|
1956
1989
|
for (var _iterator21 = _createForOfIteratorHelperLoose(columnSizes.index), _step21; !(_step21 = _iterator21()).done;) {
|
|
1957
1990
|
var col = _step21.value;
|
|
@@ -1965,8 +1998,8 @@ function Sheet(props) {
|
|
|
1965
1998
|
}
|
|
1966
1999
|
}
|
|
1967
2000
|
|
|
1968
|
-
if (props.onCellHeightChange && x < rowHeaderWidth) {
|
|
1969
|
-
var yy = columnHeaderHeight;
|
|
2001
|
+
if (!sheetStyle.hideRowHeaders && props.onCellHeightChange && x < sheetStyle.rowHeaderWidth) {
|
|
2002
|
+
var yy = sheetStyle.columnHeaderHeight;
|
|
1970
2003
|
|
|
1971
2004
|
for (var _iterator22 = _createForOfIteratorHelperLoose(rowSizes.index), _step22; !(_step22 = _iterator22()).done;) {
|
|
1972
2005
|
var row = _step22.value;
|
|
@@ -2310,7 +2343,7 @@ function Sheet(props) {
|
|
|
2310
2343
|
y2 = _ref2[1];
|
|
2311
2344
|
}
|
|
2312
2345
|
|
|
2313
|
-
if (!(y > columnHeaderHeight && x > rowHeaderWidth)) {
|
|
2346
|
+
if (!(y > sheetStyle.columnHeaderHeight && x > sheetStyle.rowHeaderWidth)) {
|
|
2314
2347
|
return;
|
|
2315
2348
|
}
|
|
2316
2349
|
|
|
@@ -2338,7 +2371,7 @@ function Sheet(props) {
|
|
|
2338
2371
|
var editTextTextAlign = 'right';
|
|
2339
2372
|
|
|
2340
2373
|
if (editMode) {
|
|
2341
|
-
editTextPosition = cellToAbsCoordinate(editCell.x, editCell.y, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight);
|
|
2374
|
+
editTextPosition = cellToAbsCoordinate(editCell.x, editCell.y, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
2342
2375
|
var style = cellStyle(editCell.x, editCell.y);
|
|
2343
2376
|
editTextPosition.x += 1;
|
|
2344
2377
|
editTextPosition.y += 1;
|
|
@@ -2368,17 +2401,36 @@ function Sheet(props) {
|
|
|
2368
2401
|
var input = (_props$inputComponent = props.inputComponent) === null || _props$inputComponent === void 0 ? void 0 : _props$inputComponent.call(props, editCell.x, editCell.y, _extends({}, inputProps, {
|
|
2369
2402
|
onChange: setEditValue
|
|
2370
2403
|
}), commitEditingCell);
|
|
2404
|
+
var overlayDivClassName = styles.sheetscroll;
|
|
2405
|
+
var overlayDivStyles = {
|
|
2406
|
+
position: 'absolute',
|
|
2407
|
+
width: '100%',
|
|
2408
|
+
height: '100%',
|
|
2409
|
+
top: 0,
|
|
2410
|
+
left: 0,
|
|
2411
|
+
overflow: 'scroll',
|
|
2412
|
+
borderBottom: '1px solid #ddd'
|
|
2413
|
+
};
|
|
2414
|
+
var canvasStyles = {
|
|
2415
|
+
width: 'calc(100% - 14px)',
|
|
2416
|
+
height: 'calc(100% - 15px)',
|
|
2417
|
+
outline: '1px solid #ddd'
|
|
2418
|
+
};
|
|
2419
|
+
|
|
2420
|
+
if (sheetStyle.hideScrollBars) {
|
|
2421
|
+
delete canvasStyles['outline'];
|
|
2422
|
+
delete overlayDivStyles['borderBottom'];
|
|
2423
|
+
overlayDivClassName = '';
|
|
2424
|
+
canvasStyles.width = 'calc(100%)';
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2371
2427
|
return React.createElement("div", {
|
|
2372
2428
|
style: {
|
|
2373
2429
|
position: 'relative',
|
|
2374
2430
|
height: '100%'
|
|
2375
2431
|
}
|
|
2376
2432
|
}, React.createElement("canvas", {
|
|
2377
|
-
style:
|
|
2378
|
-
width: 'calc(100% - 14px)',
|
|
2379
|
-
height: 'calc(100% - 15px)',
|
|
2380
|
-
outline: '1px solid #ddd'
|
|
2381
|
-
},
|
|
2433
|
+
style: canvasStyles,
|
|
2382
2434
|
ref: canvasRef
|
|
2383
2435
|
}), React.createElement("div", {
|
|
2384
2436
|
ref: overlayRef,
|
|
@@ -2388,16 +2440,8 @@ function Sheet(props) {
|
|
|
2388
2440
|
onMouseLeave: onMouseLeave,
|
|
2389
2441
|
onContextMenu: onContextMenu,
|
|
2390
2442
|
onScroll: onScroll,
|
|
2391
|
-
className:
|
|
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
|
-
}
|
|
2443
|
+
className: overlayDivClassName,
|
|
2444
|
+
style: overlayDivStyles
|
|
2401
2445
|
}, React.createElement("div", {
|
|
2402
2446
|
style: {
|
|
2403
2447
|
position: 'absolute',
|