sheet-happens 0.0.17 → 0.0.18

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 CHANGED
@@ -45,6 +45,7 @@ export interface SheetProps {
45
45
  displayData?: CellProperty<CellContentType>;
46
46
  editData?: CellProperty<string>;
47
47
  editKeys?: CellProperty<string>;
48
+ hideGridlines?: boolean;
48
49
  inputComponent?: (x: number, y: number, props: SheetInputProps, commitEditingCell?: () => void) => ReactElement | undefined;
49
50
  onSelectionChanged?: (x1: number, y1: number, x2: number, y2: number) => void;
50
51
  onRightClick?: (e: SheetMouseEvent) => void;
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ var scrollSpeed = 30;
84
84
  var resizeColumnRowMouseThreshold = 4;
85
85
  var minimumColumnWidth = 50;
86
86
  var minimumRowHeight = 22;
87
- var rowColHeaderSelectionColor = '#AAAAAA';
87
+ var rowColHeaderSelectionColor = '#cccccc';
88
88
  var maxSearchableRowOrCol = 65536;
89
89
  var defaultCellStyle = {
90
90
  textAlign: 'left',
@@ -114,14 +114,7 @@ function resizeCanvas(canvas) {
114
114
  width = _canvas$getBoundingCl.width,
115
115
  height = _canvas$getBoundingCl.height;
116
116
 
117
- var _window = window,
118
- _window$devicePixelRa = _window.devicePixelRatio,
119
- ratio = _window$devicePixelRa === void 0 ? 1 : _window$devicePixelRa;
120
-
121
- if (ratio < 1) {
122
- ratio = 1;
123
- }
124
-
117
+ var ratio = 2;
125
118
  var newCanvasWidth = Math.round(width * ratio);
126
119
  var newCanvasHeight = Math.round(height * ratio);
127
120
 
@@ -503,7 +496,7 @@ function findInDisplayData(displayData, start, direction) {
503
496
  return i;
504
497
  }
505
498
 
506
- function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates) {
499
+ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, hideGridlines) {
507
500
  resizeCanvas(context.canvas);
508
501
  context.clearRect(0, 0, context.canvas.width, context.canvas.height);
509
502
  context.fillStyle = 'white';
@@ -615,23 +608,41 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
615
608
  context.strokeStyle = gridColor;
616
609
  context.lineWidth = 1;
617
610
  var startX = rowHeaderWidth;
611
+ var startY = columnHeaderHeight;
612
+ var xGridlineEnd = hideGridlines ? rowHeaderWidth : context.canvas.width;
613
+ var yGridlineEnd = hideGridlines ? columnHeaderHeight : context.canvas.height;
614
+ var first = true;
618
615
 
619
616
  for (var _iterator3 = _createForOfIteratorHelperLoose(columnSizes.index), _step3; !(_step3 = _iterator3()).done;) {
620
617
  var col = _step3.value;
621
618
  context.beginPath();
622
619
  context.moveTo(startX, 0);
623
- context.lineTo(startX, context.canvas.height);
620
+
621
+ if (first) {
622
+ context.lineTo(startX, context.canvas.height);
623
+ first = false;
624
+ } else {
625
+ context.lineTo(startX, yGridlineEnd);
626
+ }
627
+
624
628
  context.stroke();
625
629
  startX += cellWidth(col);
626
630
  }
627
631
 
628
- var startY = columnHeaderHeight;
632
+ first = true;
629
633
 
630
634
  for (var _iterator4 = _createForOfIteratorHelperLoose(rowSizes.index), _step4; !(_step4 = _iterator4()).done;) {
631
635
  var row = _step4.value;
632
636
  context.beginPath();
633
637
  context.moveTo(0, startY);
634
- context.lineTo(context.canvas.width, startY);
638
+
639
+ if (first) {
640
+ context.lineTo(context.canvas.width, startY);
641
+ first = false;
642
+ } else {
643
+ context.lineTo(xGridlineEnd, startY);
644
+ }
645
+
635
646
  context.stroke();
636
647
  startY += cellHeight(row);
637
648
  }
@@ -1244,12 +1255,12 @@ function Sheet(props) {
1244
1255
  }
1245
1256
 
1246
1257
  var animationFrameId = window.requestAnimationFrame(function () {
1247
- renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates);
1258
+ renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, props.hideGridlines || false);
1248
1259
  });
1249
1260
  return function () {
1250
1261
  window.cancelAnimationFrame(animationFrameId);
1251
1262
  };
1252
- }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates]);
1263
+ }, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, props.hideGridlines]);
1253
1264
 
1254
1265
  var setFocusToTextArea = function setFocusToTextArea() {
1255
1266
  if (copyPasteTextAreaRef.current) {