sheet-happens 0.0.48 → 0.0.50

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.
@@ -1200,7 +1200,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
1200
1200
  var _getScrollPosition5 = getScrollPosition(e),
1201
1201
  currentScroll = _getScrollPosition5[0];
1202
1202
 
1203
- var newWidth = Math.max(size + x - anchor + scroll - currentScroll, SIZES.minimumWidth * indices.length);
1203
+ var newWidth = Math.round(Math.max(size + x - anchor + scroll - currentScroll, SIZES.minimumWidth * indices.length));
1204
1204
  onInvalidateColumn === null || onInvalidateColumn === void 0 ? void 0 : onInvalidateColumn(indices[0] - 1);
1205
1205
  onCellWidthChange(indices, indices.map(function (_) {
1206
1206
  return Math.round(newWidth / indices.length);
@@ -1220,7 +1220,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
1220
1220
  var _getScrollPosition6 = getScrollPosition(e),
1221
1221
  _currentScroll = _getScrollPosition6[1];
1222
1222
 
1223
- var newHeight = Math.max(_size4 + y - _anchor + _scroll4 - _currentScroll, SIZES.minimumHeight * _indices5.length);
1223
+ var newHeight = Math.round(Math.max(_size4 + y - _anchor + _scroll4 - _currentScroll, SIZES.minimumHeight * _indices5.length));
1224
1224
  onInvalidateRow === null || onInvalidateRow === void 0 ? void 0 : onInvalidateRow(_indices5[0] - 1);
1225
1225
  onCellHeightChange(_indices5, _indices5.map(function (_) {
1226
1226
  return newHeight / _indices5.length;
@@ -1641,6 +1641,7 @@ var useKeyboard = function useKeyboard(arrowKeyCommitMode, overlayRef, cellReadO
1641
1641
  return;
1642
1642
  }
1643
1643
 
1644
+ if (e.key === 'Enter') e.preventDefault();
1644
1645
  onEdit === null || onEdit === void 0 ? void 0 : onEdit(cell, e.key !== 'Enter');
1645
1646
  return;
1646
1647
  }
@@ -1755,18 +1756,18 @@ var clipDataOffset = function clipDataOffset(view, offset, freeze, maxCells, cel
1755
1756
 
1756
1757
  var _getViewExtent = getViewExtent(view, [newX, newY], freeze, cellLayout),
1757
1758
  _getViewExtent$edge = _getViewExtent.edge,
1758
- rightEdge = _getViewExtent$edge[0],
1759
- bottomEdge = _getViewExtent$edge[1],
1759
+ leftEdge = _getViewExtent$edge[0],
1760
+ topEdge = _getViewExtent$edge[1],
1760
1761
  _getViewExtent$viewpo = _getViewExtent.viewport,
1761
1762
  scrollW = _getViewExtent$viewpo[0],
1762
1763
  scrollH = _getViewExtent$viewpo[1];
1763
1764
 
1764
- if (rightEdge > maxColumns) {
1765
+ if (leftEdge >= maxColumns) {
1765
1766
  var remainder = columnToAbsolute(maxColumns) - columnToAbsolute(newX + freezeX);
1766
1767
  newX = Math.max(0, absoluteToColumn(columnToAbsolute(newX + freezeX) - scrollW + remainder) - freezeX + 1);
1767
1768
  }
1768
1769
 
1769
- if (bottomEdge > maxRows) {
1770
+ if (topEdge >= maxRows) {
1770
1771
  var _remainder = rowToAbsolute(maxRows) - rowToAbsolute(newY + freezeY);
1771
1772
 
1772
1773
  newY = Math.max(0, absoluteToRow(rowToAbsolute(newY + freezeY) - scrollH + _remainder) - freezeY + 1);
@@ -1776,10 +1777,6 @@ var clipDataOffset = function clipDataOffset(view, offset, freeze, maxCells, cel
1776
1777
  };
1777
1778
  var getViewExtent = function getViewExtent(view, offset, freeze, cellLayout) {
1778
1779
  var cellToAbsolute = cellLayout.cellToAbsolute,
1779
- absoluteToColumn = cellLayout.absoluteToColumn,
1780
- columnToAbsolute = cellLayout.columnToAbsolute,
1781
- absoluteToRow = cellLayout.absoluteToRow,
1782
- rowToAbsolute = cellLayout.rowToAbsolute,
1783
1780
  getIndentX = cellLayout.getIndentX,
1784
1781
  getIndentY = cellLayout.getIndentY;
1785
1782
  var x = offset[0],
@@ -1795,10 +1792,8 @@ var getViewExtent = function getViewExtent(view, offset, freeze, cellLayout) {
1795
1792
  var scrollH = h - frozenY - getIndentY();
1796
1793
  var leftEdge = x + freeze[0];
1797
1794
  var topEdge = y + freeze[1];
1798
- var rightEdge = absoluteToColumn(columnToAbsolute(leftEdge) + scrollW);
1799
- var bottomEdge = absoluteToRow(rowToAbsolute(topEdge) + scrollH);
1800
1795
  return {
1801
- edge: [rightEdge, bottomEdge],
1796
+ edge: [leftEdge, topEdge],
1802
1797
  viewport: [scrollW, scrollH]
1803
1798
  };
1804
1799
  };
@@ -2848,7 +2843,7 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
2848
2843
  var clickables = [];
2849
2844
  var freeze = [freezeColumns, freezeRows];
2850
2845
  var indent = [rowHeaderWidth, columnHeaderHeight];
2851
- resizeCanvas(canvas);
2846
+ var pixelRatio = resizeCanvas(canvas);
2852
2847
  context.clearRect(0, 0, width, height);
2853
2848
  context.fillStyle = 'white';
2854
2849
  context.fillRect(0, 0, width, height);
@@ -2993,7 +2988,7 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
2993
2988
 
2994
2989
  var _bottom2 = rowToPixel(row, 1);
2995
2990
 
2996
- clickables.push.apply(clickables, renderCell(context, content, resolvedStyle, 0, _top2, rowHeaderWidth, _bottom2 - _top2));
2991
+ clickables.push.apply(clickables, renderCell(context, content, resolvedStyle, 0, _top2, rowHeaderWidth, _bottom2 - _top2, pixelRatio));
2997
2992
  }
2998
2993
  }
2999
2994
 
@@ -3023,7 +3018,7 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
3023
3018
 
3024
3019
  var _content = (_columnHeaders = columnHeaders(column, _style)) != null ? _columnHeaders : excelHeaderString(column + 1);
3025
3020
 
3026
- clickables.push.apply(clickables, renderCell(context, _content, _style, _left2, 0, _right2 - _left2, columnHeaderHeight));
3021
+ clickables.push.apply(clickables, renderCell(context, _content, _style, _left2, 0, _right2 - _left2, columnHeaderHeight, pixelRatio));
3027
3022
  }
3028
3023
  }
3029
3024
 
@@ -3193,14 +3188,14 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
3193
3188
  var cellContent = displayData(_x, _y, _style2);
3194
3189
 
3195
3190
  if (cellContent !== null && cellContent !== undefined) {
3196
- clickables.push.apply(clickables, renderCell(context, cellContent, _style2, _left9, _top9, _right10 - _left9, _bottom10 - _top9));
3191
+ clickables.push.apply(clickables, renderCell(context, cellContent, _style2, _left9, _top9, _right10 - _left9, _bottom10 - _top9, pixelRatio));
3197
3192
  }
3198
3193
  }
3199
3194
  }
3200
3195
 
3201
3196
  return clickables;
3202
3197
  };
3203
- var renderCell = function renderCell(context, cellContent, style, xCoord, yCoord, cellWidth, cellHeight) {
3198
+ var renderCell = function renderCell(context, cellContent, style, xCoord, yCoord, cellWidth, cellHeight, pixelRatio) {
3204
3199
  var clickables = [];
3205
3200
 
3206
3201
  if (cellContent === null) {
@@ -3210,7 +3205,7 @@ var renderCell = function renderCell(context, cellContent, style, xCoord, yCoord
3210
3205
  context.fillStyle = style.color;
3211
3206
  context.font = style.weight + ' ' + style.fontSize + 'px ' + style.fontFamily;
3212
3207
  context.textAlign = style.textAlign;
3213
- var yy = Math.floor(yCoord + cellHeight * 0.5);
3208
+ var yy = Math.round((yCoord + cellHeight * 0.5) * pixelRatio) / pixelRatio;
3214
3209
  context.save();
3215
3210
  context.beginPath();
3216
3211
  context.rect(xCoord, yCoord, cellWidth, cellHeight);
@@ -3416,11 +3411,9 @@ var resizeCanvas = function resizeCanvas(canvas) {
3416
3411
  canvas.height = newCanvasHeight;
3417
3412
  context.scale(ratio, ratio);
3418
3413
  }
3419
-
3420
- return true;
3421
3414
  }
3422
3415
 
3423
- return false;
3416
+ return ratio;
3424
3417
  };
3425
3418
 
3426
3419
  var excelHeaderString = function excelHeaderString(num) {