sheet-happens 0.0.38 → 0.0.40
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/coordinate.d.ts +1 -0
- package/dist/index.js +56 -12
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +56 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/scroll.d.ts +1 -1
- package/dist/sheet.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -348,6 +348,11 @@ var orientSelection = function orientSelection(normalized, to) {
|
|
|
348
348
|
var swapY = (ay - hy || 1) * (bottom - top || 1) < 0;
|
|
349
349
|
return [[swapX ? right : left, swapY ? bottom : top], [swapX ? left : right, swapY ? top : bottom]];
|
|
350
350
|
};
|
|
351
|
+
var clipSelection = function clipSelection(selection, max) {
|
|
352
|
+
var anchor = selection[0],
|
|
353
|
+
head = selection[1];
|
|
354
|
+
return [minXY(anchor, max), minXY(head, max)];
|
|
355
|
+
};
|
|
351
356
|
|
|
352
357
|
var LIMIT = 1000;
|
|
353
358
|
|
|
@@ -708,7 +713,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
708
713
|
|
|
709
714
|
if (isColumnSelection(selection) && isInRange(x, _start, _end) && (isInRange(index, minX, maxX) || selectedColumnGroups !== null && selectedColumnGroups !== void 0 && selectedColumnGroups.has(columnGroupKeys(index))) && canOrderColumn(index)) {
|
|
710
715
|
window.document.body.style.cursor = 'grabbing';
|
|
711
|
-
var indices =
|
|
716
|
+
var indices = Array.from(new Set([].concat(selectedColumns, selectedColumnGroups ? columns.filter(function (index) {
|
|
712
717
|
return selectedColumnGroups.has(columnGroupKeys(index));
|
|
713
718
|
}) : [])).values());
|
|
714
719
|
indices.sort(function (a, b) {
|
|
@@ -796,7 +801,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
796
801
|
if (isRowSelection(selection) && isInRange(y, _start3, _end3) && (isInRange(_index2, minY, maxY) || selectedRowGroups !== null && selectedRowGroups !== void 0 && selectedRowGroups.has(rowGroupKeys(_index2))) && canOrderRow(_index2)) {
|
|
797
802
|
window.document.body.style.cursor = 'grabbing';
|
|
798
803
|
|
|
799
|
-
var _indices2 =
|
|
804
|
+
var _indices2 = Array.from(new Set([].concat(selectedRows, selectedRowGroups ? rows.map(function (_, i) {
|
|
800
805
|
return i;
|
|
801
806
|
}).filter(function (index) {
|
|
802
807
|
return selectedRowGroups.has(rowGroupKeys(index));
|
|
@@ -1484,17 +1489,25 @@ var useScroll = function useScroll(offset, maxScroll, cellLayout, onOffsetChange
|
|
|
1484
1489
|
}
|
|
1485
1490
|
}, [cellLayout, onOffsetChange, onMaxScrollChange]);
|
|
1486
1491
|
};
|
|
1487
|
-
var scrollToCell = function scrollToCell(element, cell, view, freeze, offset, maxScroll, cellLayout, callback) {
|
|
1492
|
+
var scrollToCell = function scrollToCell(element, cell, view, freeze, offset, maxCells, maxScroll, cellLayout, callback) {
|
|
1488
1493
|
var x = cell[0],
|
|
1489
1494
|
y = cell[1];
|
|
1490
1495
|
var w = view[0],
|
|
1491
1496
|
h = view[1];
|
|
1492
1497
|
var offsetX = offset[0],
|
|
1493
1498
|
offsetY = offset[1];
|
|
1499
|
+
var maxColumns = maxCells[0],
|
|
1500
|
+
maxRows = maxCells[1];
|
|
1494
1501
|
var cellToAbsolute = cellLayout.cellToAbsolute,
|
|
1495
1502
|
cellToPixel = cellLayout.cellToPixel,
|
|
1496
1503
|
columnToPixel = cellLayout.columnToPixel,
|
|
1497
|
-
rowToPixel = cellLayout.rowToPixel
|
|
1504
|
+
rowToPixel = cellLayout.rowToPixel,
|
|
1505
|
+
absoluteToColumn = cellLayout.absoluteToColumn,
|
|
1506
|
+
columnToAbsolute = cellLayout.columnToAbsolute,
|
|
1507
|
+
absoluteToRow = cellLayout.absoluteToRow,
|
|
1508
|
+
rowToAbsolute = cellLayout.rowToAbsolute,
|
|
1509
|
+
getIndentX = cellLayout.getIndentX,
|
|
1510
|
+
getIndentY = cellLayout.getIndentY;
|
|
1498
1511
|
|
|
1499
1512
|
var _cellToAbsolute2 = cellToAbsolute(freeze),
|
|
1500
1513
|
frozenX = _cellToAbsolute2[0],
|
|
@@ -1513,10 +1526,25 @@ var scrollToCell = function scrollToCell(element, cell, view, freeze, offset, ma
|
|
|
1513
1526
|
|
|
1514
1527
|
if (left <= frozenX) {
|
|
1515
1528
|
newX = x - freeze[0];
|
|
1529
|
+
var scrollW = w - frozenX - getIndentX();
|
|
1530
|
+
var rightEdge = absoluteToColumn(columnToAbsolute(newX) + scrollW);
|
|
1531
|
+
|
|
1532
|
+
if (rightEdge > maxColumns) {
|
|
1533
|
+
var remainder = columnToAbsolute(maxColumns) - columnToAbsolute(newX);
|
|
1534
|
+
newX = absoluteToColumn(columnToAbsolute(newX) - scrollW + remainder) + 1;
|
|
1535
|
+
}
|
|
1516
1536
|
}
|
|
1517
1537
|
|
|
1518
1538
|
if (top <= frozenY) {
|
|
1519
1539
|
newY = y - freeze[1];
|
|
1540
|
+
var scrollH = h - frozenY - getIndentY();
|
|
1541
|
+
var bottomEdge = absoluteToRow(rowToAbsolute(newY) + scrollH);
|
|
1542
|
+
|
|
1543
|
+
if (bottomEdge > maxRows) {
|
|
1544
|
+
var _remainder = rowToAbsolute(maxRows) - rowToAbsolute(newY);
|
|
1545
|
+
|
|
1546
|
+
newY = absoluteToRow(rowToAbsolute(newY) - scrollH + _remainder) + 1;
|
|
1547
|
+
}
|
|
1520
1548
|
}
|
|
1521
1549
|
|
|
1522
1550
|
if (right > w) {
|
|
@@ -3022,7 +3050,7 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
3022
3050
|
if (scrollTo) {
|
|
3023
3051
|
var anchor = newSelection[0],
|
|
3024
3052
|
head = newSelection[1];
|
|
3025
|
-
scrollToCell(overlay, toHead ? head : anchor, [canvasWidth, canvasHeight], [freezeColumns, freezeRows], dataOffset, maxScroll, cellLayout, function (dataOffset, maxScroll) {
|
|
3053
|
+
scrollToCell(overlay, toHead ? head : anchor, [canvasWidth, canvasHeight], [freezeColumns, freezeRows], dataOffset, [maxColumns, maxRows], maxScroll, cellLayout, function (dataOffset, maxScroll) {
|
|
3026
3054
|
setDataOffset(dataOffset);
|
|
3027
3055
|
setMaxScroll(maxScroll);
|
|
3028
3056
|
});
|
|
@@ -3080,6 +3108,22 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
3080
3108
|
setLastEditKey(editKeys.apply(void 0, editCell));
|
|
3081
3109
|
};
|
|
3082
3110
|
|
|
3111
|
+
var _props$maxColumns = props.maxColumns,
|
|
3112
|
+
maxColumns = _props$maxColumns === void 0 ? Infinity : _props$maxColumns,
|
|
3113
|
+
_props$maxRows = props.maxRows,
|
|
3114
|
+
maxRows = _props$maxRows === void 0 ? Infinity : _props$maxRows;
|
|
3115
|
+
useLayoutEffect(function () {
|
|
3116
|
+
var _normalizeSelection2 = normalizeSelection(selection),
|
|
3117
|
+
_normalizeSelection2$ = _normalizeSelection2[1],
|
|
3118
|
+
maxX = _normalizeSelection2$[0],
|
|
3119
|
+
maxY = _normalizeSelection2$[1];
|
|
3120
|
+
|
|
3121
|
+
var overflowX = maxX > maxColumns;
|
|
3122
|
+
var overflowY = maxY > maxRows;
|
|
3123
|
+
if (!overflowX && !overflowY) return;
|
|
3124
|
+
var corner = [maxColumns - 1, maxRows - 1];
|
|
3125
|
+
changeSelection(clipSelection(selection, corner), true);
|
|
3126
|
+
}, [maxRows, maxColumns]);
|
|
3083
3127
|
var hitmapRef = useRef(NO_CLICKABLES);
|
|
3084
3128
|
var textAreaRef = useRef(null);
|
|
3085
3129
|
useClipboardCopy(textAreaRef, selection, editMode, editData);
|
|
@@ -3145,13 +3189,13 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
3145
3189
|
}
|
|
3146
3190
|
|
|
3147
3191
|
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
3148
|
-
var
|
|
3149
|
-
|
|
3150
|
-
x1 =
|
|
3151
|
-
y1 =
|
|
3152
|
-
|
|
3153
|
-
x2 =
|
|
3154
|
-
y2 =
|
|
3192
|
+
var _normalizeSelection3 = normalizeSelection(selection),
|
|
3193
|
+
_normalizeSelection3$ = _normalizeSelection3[0],
|
|
3194
|
+
x1 = _normalizeSelection3$[0],
|
|
3195
|
+
y1 = _normalizeSelection3$[1],
|
|
3196
|
+
_normalizeSelection3$2 = _normalizeSelection3[1],
|
|
3197
|
+
x2 = _normalizeSelection3$2[0],
|
|
3198
|
+
y2 = _normalizeSelection3$2[1];
|
|
3155
3199
|
|
|
3156
3200
|
if (isRowSelection(selection)) {
|
|
3157
3201
|
x1 = 0;
|