sheet-happens 0.0.20 → 0.0.22
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 +16 -0
- package/dist/index.js +159 -66
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +159 -66
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,10 +11,24 @@ export interface SheetInputProps {
|
|
|
11
11
|
onChange: (valiue: string) => void;
|
|
12
12
|
style: InputStyle;
|
|
13
13
|
}
|
|
14
|
+
interface SelectionSpan {
|
|
15
|
+
x1: number;
|
|
16
|
+
y1: number;
|
|
17
|
+
x2: number;
|
|
18
|
+
y2: number;
|
|
19
|
+
}
|
|
20
|
+
interface Selection {
|
|
21
|
+
span: SelectionSpan;
|
|
22
|
+
color: string;
|
|
23
|
+
}
|
|
14
24
|
export interface Change {
|
|
15
25
|
x: number;
|
|
16
26
|
y: number;
|
|
17
27
|
value: string | number | null;
|
|
28
|
+
source?: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
};
|
|
18
32
|
}
|
|
19
33
|
export interface CellContentItem {
|
|
20
34
|
content: HTMLImageElement | string | number;
|
|
@@ -52,6 +66,8 @@ export interface SheetProps {
|
|
|
52
66
|
editData?: CellProperty<string>;
|
|
53
67
|
editKeys?: CellProperty<string>;
|
|
54
68
|
sheetStyle?: SheetStyle;
|
|
69
|
+
dontCommitEditOnSelectionChange?: boolean;
|
|
70
|
+
secondarySelections?: Selection[];
|
|
55
71
|
inputComponent?: (x: number, y: number, props: SheetInputProps, commitEditingCell?: () => void) => ReactElement | undefined;
|
|
56
72
|
onSelectionChanged?: (x1: number, y1: number, x2: number, y2: number) => void;
|
|
57
73
|
onRightClick?: (e: SheetMouseEvent) => void;
|
package/dist/index.js
CHANGED
|
@@ -335,6 +335,26 @@ function absCoordianteToCell(absX, absY, rowSizes, columnSizes) {
|
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
function normalizeSelection(selection) {
|
|
339
|
+
var selx1 = selection.x1;
|
|
340
|
+
var selx2 = selection.x2;
|
|
341
|
+
|
|
342
|
+
if (selection.x1 > selection.x2) {
|
|
343
|
+
selx1 = selection.x2;
|
|
344
|
+
selx2 = selection.x1;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var sely1 = selection.y1;
|
|
348
|
+
var sely2 = selection.y2;
|
|
349
|
+
|
|
350
|
+
if (selection.y1 > selection.y2) {
|
|
351
|
+
sely1 = selection.y2;
|
|
352
|
+
sely2 = selection.y1;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return [selx1, sely1, selx2, sely2];
|
|
356
|
+
}
|
|
357
|
+
|
|
338
358
|
function cellToAbsCoordinate(cellX, cellY, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle) {
|
|
339
359
|
var absX = sheetStyle.rowHeaderWidth;
|
|
340
360
|
var indX = columnSizes.index.findIndex(function (i) {
|
|
@@ -503,7 +523,7 @@ function findInDisplayData(displayData, start, direction) {
|
|
|
503
523
|
return i;
|
|
504
524
|
}
|
|
505
525
|
|
|
506
|
-
function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle) {
|
|
526
|
+
function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, secondarySelections, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle) {
|
|
507
527
|
resizeCanvas(context.canvas);
|
|
508
528
|
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
509
529
|
context.fillStyle = 'white';
|
|
@@ -514,8 +534,8 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
514
534
|
var y = _step2.value;
|
|
515
535
|
var xCoord1 = sheetStyle.rowHeaderWidth;
|
|
516
536
|
|
|
517
|
-
for (var
|
|
518
|
-
var x =
|
|
537
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose(columnSizes.index), _step9; !(_step9 = _iterator9()).done;) {
|
|
538
|
+
var x = _step9.value;
|
|
519
539
|
var style = cellStyle(x, y);
|
|
520
540
|
|
|
521
541
|
if (style.fillColor) {
|
|
@@ -530,21 +550,12 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
530
550
|
}
|
|
531
551
|
|
|
532
552
|
var hideKnob = false;
|
|
533
|
-
var selx1 = selection.x1;
|
|
534
|
-
var selx2 = selection.x2;
|
|
535
553
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
var sely1 = selection.y1;
|
|
542
|
-
var sely2 = selection.y2;
|
|
543
|
-
|
|
544
|
-
if (selection.y1 > selection.y2) {
|
|
545
|
-
sely1 = selection.y2;
|
|
546
|
-
sely2 = selection.y1;
|
|
547
|
-
}
|
|
554
|
+
var _normalizeSelection = normalizeSelection(selection),
|
|
555
|
+
selx1 = _normalizeSelection[0],
|
|
556
|
+
sely1 = _normalizeSelection[1],
|
|
557
|
+
selx2 = _normalizeSelection[2],
|
|
558
|
+
sely2 = _normalizeSelection[3];
|
|
548
559
|
|
|
549
560
|
var selectionActive = selx1 !== -1 && selx2 !== -1 || sely1 !== -1 && sely2 !== -1;
|
|
550
561
|
var rowSelectionActive = selx1 === -1 && selx2 === -1 && sely1 !== -1 && sely2 !== -1;
|
|
@@ -727,6 +738,70 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
727
738
|
context.stroke();
|
|
728
739
|
}
|
|
729
740
|
|
|
741
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose(secondarySelections), _step7; !(_step7 = _iterator7()).done;) {
|
|
742
|
+
var secondarySelection = _step7.value;
|
|
743
|
+
|
|
744
|
+
var _normalizeSelection2 = normalizeSelection(secondarySelection.span),
|
|
745
|
+
_selx = _normalizeSelection2[0],
|
|
746
|
+
_sely = _normalizeSelection2[1],
|
|
747
|
+
_selx2 = _normalizeSelection2[2],
|
|
748
|
+
_sely2 = _normalizeSelection2[3];
|
|
749
|
+
|
|
750
|
+
var secondarySelectionActive = _selx !== -1 && _selx2 !== -1 || _sely !== -1 && _sely2 !== -1;
|
|
751
|
+
|
|
752
|
+
if (!secondarySelectionActive) {
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
var rowSecondarySelectionActive = _selx === -1 && _selx2 === -1 && _sely !== -1 && _sely2 !== -1;
|
|
757
|
+
var colSecondarySelectionActive = _selx !== -1 && _selx2 !== -1 && _sely === -1 && _sely2 === -1;
|
|
758
|
+
|
|
759
|
+
var _p = cellToAbsCoordinate(_selx, _sely, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
760
|
+
|
|
761
|
+
var _p2 = cellToAbsCoordinate(_selx2, _sely2, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
762
|
+
|
|
763
|
+
_p2.x += cellWidth(_selx2);
|
|
764
|
+
_p2.y += cellHeight(_sely2);
|
|
765
|
+
|
|
766
|
+
if (_p.x >= _p2.x) {
|
|
767
|
+
_p2.x = _p.x;
|
|
768
|
+
var _currentCol = _selx;
|
|
769
|
+
|
|
770
|
+
while (columnSizes.index.includes(_currentCol)) {
|
|
771
|
+
_p2.x += cellWidth(_currentCol);
|
|
772
|
+
_currentCol++;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (_p.y >= _p2.y) {
|
|
777
|
+
_p2.y = _p.y;
|
|
778
|
+
var _currentRow = _sely;
|
|
779
|
+
|
|
780
|
+
while (rowSizes.index.includes(_currentRow)) {
|
|
781
|
+
_p2.y += cellHeight(_currentRow);
|
|
782
|
+
_currentRow++;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
context.strokeStyle = secondarySelection.color;
|
|
787
|
+
context.lineWidth = 1;
|
|
788
|
+
context.beginPath();
|
|
789
|
+
|
|
790
|
+
if (rowSecondarySelectionActive) {
|
|
791
|
+
var _p1x2 = Math.max(-100, _p.x);
|
|
792
|
+
|
|
793
|
+
context.rect(_p1x2, _p.y, 100000, _p2.y - _p.y);
|
|
794
|
+
} else if (colSecondarySelectionActive) {
|
|
795
|
+
var _p1y2 = Math.max(-100, _p.y);
|
|
796
|
+
|
|
797
|
+
context.rect(_p.x, _p1y2, _p2.x - _p.x, 100000);
|
|
798
|
+
} else {
|
|
799
|
+
context.rect(_p.x, _p.y, _p2.x - _p.x, _p2.y - _p.y);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
context.stroke();
|
|
803
|
+
}
|
|
804
|
+
|
|
730
805
|
if (knobDragInProgress) {
|
|
731
806
|
var kx1 = knobArea.x1;
|
|
732
807
|
var kx2 = knobArea.x2;
|
|
@@ -771,14 +846,14 @@ function renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, ce
|
|
|
771
846
|
context.textBaseline = 'middle';
|
|
772
847
|
var yCoord = sheetStyle.columnHeaderHeight;
|
|
773
848
|
|
|
774
|
-
for (var
|
|
775
|
-
var _y =
|
|
849
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose(rowSizes.index), _step8; !(_step8 = _iterator8()).done;) {
|
|
850
|
+
var _y = _step8.value;
|
|
776
851
|
var xCoord = sheetStyle.rowHeaderWidth;
|
|
777
852
|
|
|
778
853
|
var _ch = cellHeight(_y);
|
|
779
854
|
|
|
780
|
-
for (var
|
|
781
|
-
var _x =
|
|
855
|
+
for (var _iterator10 = _createForOfIteratorHelperLoose(columnSizes.index), _step10; !(_step10 = _iterator10()).done;) {
|
|
856
|
+
var _x = _step10.value;
|
|
782
857
|
|
|
783
858
|
var _cellContent = displayData(_x, _y);
|
|
784
859
|
|
|
@@ -1092,23 +1167,23 @@ function Sheet(props) {
|
|
|
1092
1167
|
}
|
|
1093
1168
|
|
|
1094
1169
|
if (selection.x2 !== -1 && selection.y2 !== -1) {
|
|
1095
|
-
var
|
|
1170
|
+
var _selx3 = selection.x2;
|
|
1096
1171
|
|
|
1097
1172
|
if (selection.x1 > selection.x2) {
|
|
1098
|
-
|
|
1173
|
+
_selx3 = selection.x1;
|
|
1099
1174
|
}
|
|
1100
1175
|
|
|
1101
|
-
var
|
|
1176
|
+
var _sely3 = selection.y2;
|
|
1102
1177
|
|
|
1103
1178
|
if (selection.y1 > selection.y2) {
|
|
1104
|
-
|
|
1179
|
+
_sely3 = selection.y1;
|
|
1105
1180
|
}
|
|
1106
1181
|
|
|
1107
|
-
var _c2 = cellToAbsCoordinate(
|
|
1182
|
+
var _c2 = cellToAbsCoordinate(_selx3, _sely3, rowSizes, columnSizes, dataOffset, cellWidth, cellHeight, sheetStyle);
|
|
1108
1183
|
|
|
1109
1184
|
return {
|
|
1110
|
-
x: _c2.x + cellWidth(
|
|
1111
|
-
y: _c2.y + cellHeight(
|
|
1185
|
+
x: _c2.x + cellWidth(_selx3),
|
|
1186
|
+
y: _c2.y + cellHeight(_sely3)
|
|
1112
1187
|
};
|
|
1113
1188
|
}
|
|
1114
1189
|
|
|
@@ -1129,16 +1204,16 @@ function Sheet(props) {
|
|
|
1129
1204
|
var yCoord = sheetStyle.columnHeaderHeight;
|
|
1130
1205
|
var xCoord = sheetStyle.rowHeaderWidth;
|
|
1131
1206
|
|
|
1132
|
-
for (var
|
|
1133
|
-
var x =
|
|
1207
|
+
for (var _iterator11 = _createForOfIteratorHelperLoose(columnSizes.index), _step11; !(_step11 = _iterator11()).done;) {
|
|
1208
|
+
var x = _step11.value;
|
|
1134
1209
|
var ch = columnHeaders(x);
|
|
1135
1210
|
var cellW = cellWidth(x);
|
|
1136
1211
|
|
|
1137
1212
|
if (ch && typeof ch === 'object' && ch.items) {
|
|
1138
1213
|
var finalStyle = void 0;
|
|
1139
1214
|
|
|
1140
|
-
for (var
|
|
1141
|
-
var obj =
|
|
1215
|
+
for (var _iterator13 = _createForOfIteratorHelperLoose(ch.items), _step13; !(_step13 = _iterator13()).done;) {
|
|
1216
|
+
var obj = _step13.value;
|
|
1142
1217
|
|
|
1143
1218
|
if (obj.onClick) {
|
|
1144
1219
|
if (!finalStyle) {
|
|
@@ -1184,12 +1259,12 @@ function Sheet(props) {
|
|
|
1184
1259
|
xCoord += cellW;
|
|
1185
1260
|
}
|
|
1186
1261
|
|
|
1187
|
-
for (var
|
|
1188
|
-
var y =
|
|
1262
|
+
for (var _iterator12 = _createForOfIteratorHelperLoose(rowSizes.index), _step12; !(_step12 = _iterator12()).done;) {
|
|
1263
|
+
var y = _step12.value;
|
|
1189
1264
|
xCoord = sheetStyle.rowHeaderWidth;
|
|
1190
1265
|
|
|
1191
|
-
for (var
|
|
1192
|
-
var _x2 =
|
|
1266
|
+
for (var _iterator14 = _createForOfIteratorHelperLoose(columnSizes.index), _step14; !(_step14 = _iterator14()).done;) {
|
|
1267
|
+
var _x2 = _step14.value;
|
|
1193
1268
|
var cellContent = displayData(_x2, y);
|
|
1194
1269
|
|
|
1195
1270
|
var _cellW = cellWidth(_x2);
|
|
@@ -1205,8 +1280,8 @@ function Sheet(props) {
|
|
|
1205
1280
|
if (typeof cellContent === 'object' && cellContent.items) {
|
|
1206
1281
|
var _finalStyle = void 0;
|
|
1207
1282
|
|
|
1208
|
-
for (var
|
|
1209
|
-
var _obj =
|
|
1283
|
+
for (var _iterator15 = _createForOfIteratorHelperLoose(cellContent.items), _step15; !(_step15 = _iterator15()).done;) {
|
|
1284
|
+
var _obj = _step15.value;
|
|
1210
1285
|
|
|
1211
1286
|
if (_obj.onClick) {
|
|
1212
1287
|
if (!_finalStyle) {
|
|
@@ -1280,12 +1355,12 @@ function Sheet(props) {
|
|
|
1280
1355
|
}
|
|
1281
1356
|
|
|
1282
1357
|
var animationFrameId = window.requestAnimationFrame(function () {
|
|
1283
|
-
renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle);
|
|
1358
|
+
renderOnCanvas(context, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, props.secondarySelections || [], knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle);
|
|
1284
1359
|
});
|
|
1285
1360
|
return function () {
|
|
1286
1361
|
window.cancelAnimationFrame(animationFrameId);
|
|
1287
1362
|
};
|
|
1288
|
-
}, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle]);
|
|
1363
|
+
}, [canvasRef, rowSizes, columnSizes, cellStyle, cellWidth, cellHeight, selection, props.secondarySelections, knobDragInProgress, columnHeaders, columnHeaderStyle, knobArea, displayData, dataOffset, knobCoordinates, sheetStyle]);
|
|
1289
1364
|
|
|
1290
1365
|
var setFocusToTextArea = function setFocusToTextArea() {
|
|
1291
1366
|
if (copyPasteTextAreaRef.current) {
|
|
@@ -1345,8 +1420,8 @@ function Sheet(props) {
|
|
|
1345
1420
|
});
|
|
1346
1421
|
|
|
1347
1422
|
var findTable = function findTable(element) {
|
|
1348
|
-
for (var
|
|
1349
|
-
var child =
|
|
1423
|
+
for (var _iterator16 = _createForOfIteratorHelperLoose(element.children), _step16; !(_step16 = _iterator16()).done;) {
|
|
1424
|
+
var child = _step16.value;
|
|
1350
1425
|
|
|
1351
1426
|
if (child.nodeName === 'TABLE') {
|
|
1352
1427
|
return child;
|
|
@@ -1395,17 +1470,17 @@ function Sheet(props) {
|
|
|
1395
1470
|
return;
|
|
1396
1471
|
}
|
|
1397
1472
|
|
|
1398
|
-
for (var
|
|
1399
|
-
var tableChild =
|
|
1473
|
+
for (var _iterator17 = _createForOfIteratorHelperLoose(tableNode.children), _step17; !(_step17 = _iterator17()).done;) {
|
|
1474
|
+
var tableChild = _step17.value;
|
|
1400
1475
|
|
|
1401
1476
|
if (tableChild.nodeName === 'TBODY') {
|
|
1402
|
-
for (var
|
|
1403
|
-
var tr =
|
|
1477
|
+
for (var _iterator18 = _createForOfIteratorHelperLoose(tableChild.children), _step18; !(_step18 = _iterator18()).done;) {
|
|
1478
|
+
var tr = _step18.value;
|
|
1404
1479
|
x = pasteLocX;
|
|
1405
1480
|
|
|
1406
1481
|
if (tr.nodeName === 'TR') {
|
|
1407
|
-
for (var
|
|
1408
|
-
var td =
|
|
1482
|
+
for (var _iterator19 = _createForOfIteratorHelperLoose(tr.children), _step19; !(_step19 = _iterator19()).done;) {
|
|
1483
|
+
var td = _step19.value;
|
|
1409
1484
|
|
|
1410
1485
|
if (td.nodeName === 'TD') {
|
|
1411
1486
|
var str = '';
|
|
@@ -1673,8 +1748,8 @@ function Sheet(props) {
|
|
|
1673
1748
|
var hitTargetKeyY = Math.floor(y / yBinSize);
|
|
1674
1749
|
|
|
1675
1750
|
if (hitMap[hitTargetKeyX] && hitMap[hitTargetKeyX][hitTargetKeyY]) {
|
|
1676
|
-
for (var
|
|
1677
|
-
var hitTarget =
|
|
1751
|
+
for (var _iterator20 = _createForOfIteratorHelperLoose(hitMap[hitTargetKeyX][hitTargetKeyY]), _step20; !(_step20 = _iterator20()).done;) {
|
|
1752
|
+
var hitTarget = _step20.value;
|
|
1678
1753
|
|
|
1679
1754
|
if (hitTarget.x <= x && x <= hitTarget.x + hitTarget.w && hitTarget.y <= y && y <= hitTarget.y + hitTarget.h) {
|
|
1680
1755
|
setButtonClickMouseDownCoordinates({
|
|
@@ -1772,7 +1847,9 @@ function Sheet(props) {
|
|
|
1772
1847
|
} : _extends({}, sel2);
|
|
1773
1848
|
|
|
1774
1849
|
if (editMode) {
|
|
1775
|
-
|
|
1850
|
+
if (!props.dontCommitEditOnSelectionChange) {
|
|
1851
|
+
commitEditingCell();
|
|
1852
|
+
}
|
|
1776
1853
|
}
|
|
1777
1854
|
|
|
1778
1855
|
var scrollToP2 = true;
|
|
@@ -1797,11 +1874,14 @@ function Sheet(props) {
|
|
|
1797
1874
|
|
|
1798
1875
|
setSelectionInProgress(true);
|
|
1799
1876
|
changeSelection(sel1.x, sel1.y, sel2.x, sel2.y, scrollToP2);
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1877
|
+
|
|
1878
|
+
if (!props.dontCommitEditOnSelectionChange) {
|
|
1879
|
+
setEditCell({
|
|
1880
|
+
x: -1,
|
|
1881
|
+
y: -1
|
|
1882
|
+
});
|
|
1883
|
+
setEditKey('');
|
|
1884
|
+
}
|
|
1805
1885
|
};
|
|
1806
1886
|
|
|
1807
1887
|
var onMouseUp = function onMouseUp(e) {
|
|
@@ -1865,7 +1945,11 @@ function Sheet(props) {
|
|
|
1865
1945
|
changes.push({
|
|
1866
1946
|
x: x,
|
|
1867
1947
|
y: y,
|
|
1868
|
-
value: value
|
|
1948
|
+
value: value,
|
|
1949
|
+
source: {
|
|
1950
|
+
x: x,
|
|
1951
|
+
y: srcY
|
|
1952
|
+
}
|
|
1869
1953
|
});
|
|
1870
1954
|
}
|
|
1871
1955
|
|
|
@@ -1898,7 +1982,11 @@ function Sheet(props) {
|
|
|
1898
1982
|
changes.push({
|
|
1899
1983
|
x: _x3,
|
|
1900
1984
|
y: _y2,
|
|
1901
|
-
value: _value
|
|
1985
|
+
value: _value,
|
|
1986
|
+
source: {
|
|
1987
|
+
x: srcX,
|
|
1988
|
+
y: _y2
|
|
1989
|
+
}
|
|
1902
1990
|
});
|
|
1903
1991
|
}
|
|
1904
1992
|
|
|
@@ -1969,8 +2057,8 @@ function Sheet(props) {
|
|
|
1969
2057
|
var hitTargetKeyY = Math.floor(y / yBinSize);
|
|
1970
2058
|
|
|
1971
2059
|
if (hitMap[hitTargetKeyX] && hitMap[hitTargetKeyX][hitTargetKeyY]) {
|
|
1972
|
-
for (var
|
|
1973
|
-
var hitTarget =
|
|
2060
|
+
for (var _iterator21 = _createForOfIteratorHelperLoose(hitMap[hitTargetKeyX][hitTargetKeyY]), _step21; !(_step21 = _iterator21()).done;) {
|
|
2061
|
+
var hitTarget = _step21.value;
|
|
1974
2062
|
|
|
1975
2063
|
if (hitTarget.x <= x && x <= hitTarget.x + hitTarget.w && hitTarget.y <= y && y <= hitTarget.y + hitTarget.h) {
|
|
1976
2064
|
window.document.body.style.cursor = 'pointer';
|
|
@@ -1981,8 +2069,8 @@ function Sheet(props) {
|
|
|
1981
2069
|
if (!sheetStyle.hideColumnHeaders && props.onCellWidthChange && y < sheetStyle.columnHeaderHeight) {
|
|
1982
2070
|
var xx = sheetStyle.rowHeaderWidth;
|
|
1983
2071
|
|
|
1984
|
-
for (var
|
|
1985
|
-
var col =
|
|
2072
|
+
for (var _iterator22 = _createForOfIteratorHelperLoose(columnSizes.index), _step22; !(_step22 = _iterator22()).done;) {
|
|
2073
|
+
var col = _step22.value;
|
|
1986
2074
|
|
|
1987
2075
|
if (Math.abs(xx - x) < resizeColumnRowMouseThreshold) {
|
|
1988
2076
|
window.document.body.style.cursor = 'col-resize';
|
|
@@ -1996,8 +2084,8 @@ function Sheet(props) {
|
|
|
1996
2084
|
if (!sheetStyle.hideRowHeaders && props.onCellHeightChange && x < sheetStyle.rowHeaderWidth) {
|
|
1997
2085
|
var yy = sheetStyle.columnHeaderHeight;
|
|
1998
2086
|
|
|
1999
|
-
for (var
|
|
2000
|
-
var row =
|
|
2087
|
+
for (var _iterator23 = _createForOfIteratorHelperLoose(rowSizes.index), _step23; !(_step23 = _iterator23()).done;) {
|
|
2088
|
+
var row = _step23.value;
|
|
2001
2089
|
|
|
2002
2090
|
if (Math.abs(yy - y) < resizeColumnRowMouseThreshold) {
|
|
2003
2091
|
window.document.body.style.cursor = 'row-resize';
|
|
@@ -2104,8 +2192,8 @@ function Sheet(props) {
|
|
|
2104
2192
|
var hitTargetKeyY = Math.floor(y / yBinSize);
|
|
2105
2193
|
|
|
2106
2194
|
if (hitMap[hitTargetKeyX] && hitMap[hitTargetKeyX][hitTargetKeyY]) {
|
|
2107
|
-
for (var
|
|
2108
|
-
var hitTarget =
|
|
2195
|
+
for (var _iterator24 = _createForOfIteratorHelperLoose(hitMap[hitTargetKeyX][hitTargetKeyY]), _step24; !(_step24 = _iterator24()).done;) {
|
|
2196
|
+
var hitTarget = _step24.value;
|
|
2109
2197
|
|
|
2110
2198
|
if (hitTarget.x <= x && x <= hitTarget.x + hitTarget.w && hitTarget.y <= y && y <= hitTarget.y + hitTarget.h) {
|
|
2111
2199
|
return;
|
|
@@ -2115,6 +2203,11 @@ function Sheet(props) {
|
|
|
2115
2203
|
|
|
2116
2204
|
var editCell = absCoordianteToCell(x, y, rowSizes, columnSizes);
|
|
2117
2205
|
setArrowKeyCommitMode(false);
|
|
2206
|
+
|
|
2207
|
+
if (editMode) {
|
|
2208
|
+
commitEditingCell();
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2118
2211
|
startEditingCell(editCell);
|
|
2119
2212
|
};
|
|
2120
2213
|
|