sheet-happens 0.0.36 → 0.0.38
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/constants.d.ts +9 -0
- package/dist/coordinate.d.ts +7 -0
- package/dist/group.d.ts +3 -0
- package/dist/index.css +12 -9
- package/dist/index.js +443 -175
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +443 -175
- package/dist/index.modern.js.map +1 -1
- package/dist/mouse.d.ts +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/sheet.d.ts +4 -1
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -75,7 +75,7 @@ var MAX_SEARCHABLE_INDEX = 65536;
|
|
|
75
75
|
var MAX_XY = [MAX_SEARCHABLE_INDEX, MAX_SEARCHABLE_INDEX];
|
|
76
76
|
var COLORS = {
|
|
77
77
|
selectionBorder: '#1a66ff',
|
|
78
|
-
selectionBackground: '#
|
|
78
|
+
selectionBackground: '#d8e6ff80',
|
|
79
79
|
gridLine: '#0000001f',
|
|
80
80
|
dragGhost: '#1a66ff30',
|
|
81
81
|
dropTarget: '#1a66ff',
|
|
@@ -85,7 +85,10 @@ var COLORS = {
|
|
|
85
85
|
headerActive: '#e8f0ff',
|
|
86
86
|
headerActiveText: '#1a66ff',
|
|
87
87
|
headerSelected: '#1a66ff',
|
|
88
|
-
|
|
88
|
+
headerSelectedGroup: '#1a66ff70',
|
|
89
|
+
headerSelectedText: '#ffffff',
|
|
90
|
+
headerSelectedGroupText: '#ffffff',
|
|
91
|
+
shadowColor: '#000000'
|
|
89
92
|
};
|
|
90
93
|
var SIZES = {
|
|
91
94
|
knobArea: 6,
|
|
@@ -95,7 +98,9 @@ var SIZES = {
|
|
|
95
98
|
minimumHeight: 22,
|
|
96
99
|
resizeZone: 4,
|
|
97
100
|
scrollZone: 50,
|
|
98
|
-
scrollSpeed: 30
|
|
101
|
+
scrollSpeed: 30,
|
|
102
|
+
shadowBlur: 12,
|
|
103
|
+
shadowOpacity: 0.05
|
|
99
104
|
};
|
|
100
105
|
var DEFAULT_CELL_STYLE = {
|
|
101
106
|
textAlign: 'left',
|
|
@@ -126,11 +131,15 @@ var HEADER_SELECTED_STYLE = {
|
|
|
126
131
|
backgroundColor: COLORS.headerSelected,
|
|
127
132
|
color: COLORS.headerSelectedText
|
|
128
133
|
};
|
|
134
|
+
var HEADER_GROUP_SELECTED_STYLE = {
|
|
135
|
+
backgroundColor: COLORS.headerSelectedGroup,
|
|
136
|
+
color: COLORS.headerSelectedGroupText
|
|
137
|
+
};
|
|
129
138
|
var ARROW_KEYS = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
ArrowRight: 'right',
|
|
140
|
+
ArrowLeft: 'left',
|
|
141
|
+
ArrowUp: 'up',
|
|
142
|
+
ArrowDown: 'down'
|
|
134
143
|
};
|
|
135
144
|
|
|
136
145
|
var clamp = function clamp(x, min, max) {
|
|
@@ -173,6 +182,9 @@ var mulXY = function mulXY(a, b) {
|
|
|
173
182
|
var maxXY = function maxXY(a, b) {
|
|
174
183
|
return [Math.max(a[0], b[0]), Math.max(a[1], b[1])];
|
|
175
184
|
};
|
|
185
|
+
var minXY = function minXY(a, b) {
|
|
186
|
+
return [Math.min(a[0], b[0]), Math.min(a[1], b[1])];
|
|
187
|
+
};
|
|
176
188
|
var clampXY = function clampXY(p, min, max) {
|
|
177
189
|
if (max === void 0) {
|
|
178
190
|
max = [Infinity, Infinity];
|
|
@@ -197,6 +209,50 @@ var isSameSelection = function isSameSelection(a, b) {
|
|
|
197
209
|
b2 = b[1];
|
|
198
210
|
return isSameXY(a1, b1) && isSameXY(a2, b2);
|
|
199
211
|
};
|
|
212
|
+
var forRange = function forRange(min, max, callback) {
|
|
213
|
+
for (var i = min; i <= max; ++i) {
|
|
214
|
+
callback(i);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var forSelectionColumns = function forSelectionColumns(selection) {
|
|
218
|
+
return function (callback) {
|
|
219
|
+
var _normalizeSelection = normalizeSelection(selection),
|
|
220
|
+
_normalizeSelection$ = _normalizeSelection[0],
|
|
221
|
+
left = _normalizeSelection$[0],
|
|
222
|
+
_normalizeSelection$2 = _normalizeSelection[1],
|
|
223
|
+
right = _normalizeSelection$2[0];
|
|
224
|
+
|
|
225
|
+
forRange(left, right, callback);
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
var forSelectionRows = function forSelectionRows(selection) {
|
|
229
|
+
return function (callback) {
|
|
230
|
+
var _normalizeSelection2 = normalizeSelection(selection),
|
|
231
|
+
_normalizeSelection2$ = _normalizeSelection2[0],
|
|
232
|
+
top = _normalizeSelection2$[1],
|
|
233
|
+
_normalizeSelection2$2 = _normalizeSelection2[1],
|
|
234
|
+
bottom = _normalizeSelection2$2[1];
|
|
235
|
+
|
|
236
|
+
forRange(top, bottom, callback);
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
var forToMap = function forToMap(forLoop) {
|
|
241
|
+
return function (map) {
|
|
242
|
+
var out = [];
|
|
243
|
+
forLoop(function () {
|
|
244
|
+
return out.push(map.apply(void 0, arguments));
|
|
245
|
+
});
|
|
246
|
+
return out;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
var mapSelectionColumns = function mapSelectionColumns(selection) {
|
|
251
|
+
return forToMap(forSelectionColumns(selection));
|
|
252
|
+
};
|
|
253
|
+
var mapSelectionRows = function mapSelectionRows(selection) {
|
|
254
|
+
return forToMap(forSelectionRows(selection));
|
|
255
|
+
};
|
|
200
256
|
var isMaybeRowSelection = function isMaybeRowSelection(selection) {
|
|
201
257
|
var _selection$ = selection[0],
|
|
202
258
|
left = _selection$[0],
|
|
@@ -248,39 +304,86 @@ var isEmptySelection = function isEmptySelection(selection) {
|
|
|
248
304
|
return left === -1 && right === -1 && top === -1 && bottom === -1;
|
|
249
305
|
};
|
|
250
306
|
var isPointInsideSelection = function isPointInsideSelection(selection, point) {
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
left =
|
|
254
|
-
top =
|
|
255
|
-
|
|
256
|
-
right =
|
|
257
|
-
bottom =
|
|
307
|
+
var _normalizeSelection3 = normalizeSelection(selection),
|
|
308
|
+
_normalizeSelection3$ = _normalizeSelection3[0],
|
|
309
|
+
left = _normalizeSelection3$[0],
|
|
310
|
+
top = _normalizeSelection3$[1],
|
|
311
|
+
_normalizeSelection3$2 = _normalizeSelection3[1],
|
|
312
|
+
right = _normalizeSelection3$2[0],
|
|
313
|
+
bottom = _normalizeSelection3$2[1];
|
|
258
314
|
|
|
259
315
|
var x = point[0],
|
|
260
316
|
y = point[1];
|
|
261
317
|
return x >= left && x <= right && y >= top && y <= bottom;
|
|
262
318
|
};
|
|
319
|
+
var validateSelection = function validateSelection(selection) {
|
|
320
|
+
var anchor = selection[0],
|
|
321
|
+
head = selection[1];
|
|
322
|
+
anchor = anchor.slice();
|
|
323
|
+
head = head.slice();
|
|
324
|
+
var min = minXY(anchor, head);
|
|
325
|
+
if (min[0] === -1) anchor[0] = head[0] = -1;
|
|
326
|
+
if (min[1] === -1) anchor[1] = head[1] = -1;
|
|
327
|
+
return [anchor, head];
|
|
328
|
+
};
|
|
263
329
|
var normalizeSelection = function normalizeSelection(selection) {
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
330
|
+
var anchor = selection[0],
|
|
331
|
+
head = selection[1];
|
|
332
|
+
return [minXY(anchor, head), maxXY(anchor, head)];
|
|
333
|
+
};
|
|
334
|
+
var orientSelection = function orientSelection(normalized, to) {
|
|
335
|
+
var _normalized$ = normalized[0],
|
|
336
|
+
left = _normalized$[0],
|
|
337
|
+
top = _normalized$[1],
|
|
338
|
+
_normalized$2 = normalized[1],
|
|
339
|
+
right = _normalized$2[0],
|
|
340
|
+
bottom = _normalized$2[1];
|
|
341
|
+
var anchor = to[0],
|
|
342
|
+
head = to[1];
|
|
343
|
+
var ax = anchor[0],
|
|
344
|
+
ay = anchor[1];
|
|
345
|
+
var hx = head[0],
|
|
346
|
+
hy = head[1];
|
|
347
|
+
var swapX = (ax - hx || 1) * (right - left || 1) < 0;
|
|
348
|
+
var swapY = (ay - hy || 1) * (bottom - top || 1) < 0;
|
|
349
|
+
return [[swapX ? right : left, swapY ? bottom : top], [swapX ? left : right, swapY ? top : bottom]];
|
|
350
|
+
};
|
|
270
351
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
352
|
+
var LIMIT = 1000;
|
|
353
|
+
|
|
354
|
+
var scanGroup = function scanGroup(keys, index, direction, matchKeys) {
|
|
355
|
+
var i = 1;
|
|
356
|
+
var limit = direction > 0 ? LIMIT : Math.min(LIMIT, index + 1);
|
|
276
357
|
|
|
277
|
-
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
bottom = _ref2[1];
|
|
358
|
+
for (; i < limit; i++) {
|
|
359
|
+
var key = keys(index + i * direction);
|
|
360
|
+
if (key == null || !matchKeys.has(key)) break;
|
|
281
361
|
}
|
|
282
362
|
|
|
283
|
-
return
|
|
363
|
+
return index + (i - 1) * direction;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
var expandSelectionToRowOrColumnGroups = function expandSelectionToRowOrColumnGroups(selection, groupKeys, matchKeys, coordinate) {
|
|
367
|
+
if (!matchKeys) return selection;
|
|
368
|
+
|
|
369
|
+
var _normalizeSelection = normalizeSelection(selection),
|
|
370
|
+
first = _normalizeSelection[0],
|
|
371
|
+
second = _normalizeSelection[1];
|
|
372
|
+
|
|
373
|
+
var start = first[coordinate];
|
|
374
|
+
var end = second[coordinate];
|
|
375
|
+
var startIndex = scanGroup(groupKeys, start, -1, matchKeys);
|
|
376
|
+
var endIndex = scanGroup(groupKeys, end, 1, matchKeys);
|
|
377
|
+
var expanded = [first.slice(), second.slice()];
|
|
378
|
+
expanded[0][coordinate] = startIndex;
|
|
379
|
+
expanded[1][coordinate] = endIndex;
|
|
380
|
+
var oriented = orientSelection(expanded, selection);
|
|
381
|
+
return oriented;
|
|
382
|
+
};
|
|
383
|
+
var isBoundaryInsideGroup = function isBoundaryInsideGroup(index, groupKeys) {
|
|
384
|
+
var before = groupKeys(index - 1);
|
|
385
|
+
var after = groupKeys(index);
|
|
386
|
+
return before != null && after != null && before === after;
|
|
284
387
|
};
|
|
285
388
|
|
|
286
389
|
var createRowOrColumnProp = function createRowOrColumnProp(rowColProp, defaultValue) {
|
|
@@ -426,7 +529,7 @@ var findInDisplayData = function findInDisplayData(displayData, start, direction
|
|
|
426
529
|
return maxXY(cell, [0, 0]);
|
|
427
530
|
};
|
|
428
531
|
|
|
429
|
-
var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, cellReadOnly, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, onEdit, onCommit, onKnobAreaChange, onDragOffsetChange, onDropTargetChange, onSelectionChange, onInvalidateColumn, onInvalidateRow, onChange, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onRightClick, dontCommitEditOnSelectionChange) {
|
|
532
|
+
var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, cellReadOnly, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups, onEdit, onCommit, onKnobAreaChange, onDragIndicesChange, onDragOffsetChange, onDropTargetChange, onSelectionChange, onInvalidateColumn, onInvalidateRow, onChange, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onRightClick, dontCommitEditOnSelectionChange, dontChangeSelectionOnOrderChange) {
|
|
430
533
|
var _useState = useState(null),
|
|
431
534
|
hitTarget = _useState[0],
|
|
432
535
|
setHitTarget = _useState[1];
|
|
@@ -576,31 +679,26 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
576
679
|
return;
|
|
577
680
|
}
|
|
578
681
|
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
minX =
|
|
582
|
-
minY =
|
|
583
|
-
|
|
584
|
-
maxX =
|
|
585
|
-
maxY =
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
for (var _i = minY; _i <= maxY; _i++) {
|
|
595
|
-
selectedRows.push(_i);
|
|
596
|
-
}
|
|
682
|
+
var normalized = normalizeSelection(selection);
|
|
683
|
+
var _normalized$ = normalized[0],
|
|
684
|
+
minX = _normalized$[0],
|
|
685
|
+
minY = _normalized$[1],
|
|
686
|
+
_normalized$2 = normalized[1],
|
|
687
|
+
maxX = _normalized$2[0],
|
|
688
|
+
maxY = _normalized$2[1];
|
|
689
|
+
var selectedColumns = mapSelectionColumns(selection)(function (i) {
|
|
690
|
+
return i;
|
|
691
|
+
});
|
|
692
|
+
var selectedRows = mapSelectionRows(selection)(function (i) {
|
|
693
|
+
return i;
|
|
694
|
+
});
|
|
597
695
|
|
|
598
696
|
if (!hideColumnHeaders && y < getIndentY()) {
|
|
599
697
|
if (onColumnOrderChange) {
|
|
600
698
|
var start = columnToPixel(minX) + SIZES.resizeZone;
|
|
601
699
|
var end = columnToPixel(maxX, 1) - SIZES.resizeZone;
|
|
602
700
|
|
|
603
|
-
if (isInRange(x, start, end)) {
|
|
701
|
+
if (isInRange(x, start, end) || selectedColumnGroups) {
|
|
604
702
|
for (var _iterator2 = _createForOfIteratorHelperLoose(columns), _step2; !(_step2 = _iterator2()).done;) {
|
|
605
703
|
var index = _step2.value;
|
|
606
704
|
|
|
@@ -608,9 +706,31 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
608
706
|
|
|
609
707
|
var _end = columnToPixel(index, 1);
|
|
610
708
|
|
|
611
|
-
if (isColumnSelection(selection) && isInRange(x, _start, _end) && isInRange(index, minX, maxX) && canOrderColumn(index)) {
|
|
709
|
+
if (isColumnSelection(selection) && isInRange(x, _start, _end) && (isInRange(index, minX, maxX) || selectedColumnGroups !== null && selectedColumnGroups !== void 0 && selectedColumnGroups.has(columnGroupKeys(index))) && canOrderColumn(index)) {
|
|
612
710
|
window.document.body.style.cursor = 'grabbing';
|
|
613
|
-
var indices = selectedColumns
|
|
711
|
+
var indices = [].concat(new Set([].concat(selectedColumns, selectedColumnGroups ? columns.filter(function (index) {
|
|
712
|
+
return selectedColumnGroups.has(columnGroupKeys(index));
|
|
713
|
+
}) : [])).values());
|
|
714
|
+
indices.sort(function (a, b) {
|
|
715
|
+
return a - b;
|
|
716
|
+
});
|
|
717
|
+
var dragIndices = indices;
|
|
718
|
+
|
|
719
|
+
if (selectedColumnGroups) {
|
|
720
|
+
var clickSelection = [[index, -1], [index, -1]];
|
|
721
|
+
|
|
722
|
+
var _expandSelectionToRow = expandSelectionToRowOrColumnGroups(clickSelection, columnGroupKeys, selectedColumnGroups, 0),
|
|
723
|
+
_expandSelectionToRow2 = _expandSelectionToRow[0],
|
|
724
|
+
left = _expandSelectionToRow2[0],
|
|
725
|
+
_expandSelectionToRow3 = _expandSelectionToRow[1],
|
|
726
|
+
right = _expandSelectionToRow3[0];
|
|
727
|
+
|
|
728
|
+
var connected = !(minX > right || maxX < left);
|
|
729
|
+
var dragStart = connected ? Math.min(minX, left) : left;
|
|
730
|
+
var dragEnd = connected ? Math.max(maxX, right) : right;
|
|
731
|
+
dragIndices = seq(dragEnd - dragStart + 1, dragStart);
|
|
732
|
+
}
|
|
733
|
+
|
|
614
734
|
var size = columnToPixel(maxX, 1) - columnToPixel(minX);
|
|
615
735
|
|
|
616
736
|
var _getScrollPosition = getScrollPosition(e),
|
|
@@ -623,6 +743,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
623
743
|
indices: indices
|
|
624
744
|
});
|
|
625
745
|
onDragOffsetChange === null || onDragOffsetChange === void 0 ? void 0 : onDragOffsetChange([0, 0]);
|
|
746
|
+
onDragIndicesChange === null || onDragIndicesChange === void 0 ? void 0 : onDragIndicesChange([dragIndices, null]);
|
|
626
747
|
return;
|
|
627
748
|
}
|
|
628
749
|
}
|
|
@@ -664,7 +785,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
664
785
|
|
|
665
786
|
var _end2 = rowToPixel(maxY, 1) - SIZES.resizeZone;
|
|
666
787
|
|
|
667
|
-
if (isInRange(y, _start2, _end2)) {
|
|
788
|
+
if (isInRange(y, _start2, _end2) || selectedRowGroups) {
|
|
668
789
|
for (var _iterator4 = _createForOfIteratorHelperLoose(rows), _step4; !(_step4 = _iterator4()).done;) {
|
|
669
790
|
var _index2 = _step4.value;
|
|
670
791
|
|
|
@@ -672,9 +793,38 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
672
793
|
|
|
673
794
|
var _end3 = rowToPixel(_index2, 1);
|
|
674
795
|
|
|
675
|
-
if (isRowSelection(selection) && isInRange(y, _start3, _end3) && isInRange(_index2, minY, maxY) && canOrderRow(_index2)) {
|
|
796
|
+
if (isRowSelection(selection) && isInRange(y, _start3, _end3) && (isInRange(_index2, minY, maxY) || selectedRowGroups !== null && selectedRowGroups !== void 0 && selectedRowGroups.has(rowGroupKeys(_index2))) && canOrderRow(_index2)) {
|
|
676
797
|
window.document.body.style.cursor = 'grabbing';
|
|
677
|
-
|
|
798
|
+
|
|
799
|
+
var _indices2 = [].concat(new Set([].concat(selectedRows, selectedRowGroups ? rows.map(function (_, i) {
|
|
800
|
+
return i;
|
|
801
|
+
}).filter(function (index) {
|
|
802
|
+
return selectedRowGroups.has(rowGroupKeys(index));
|
|
803
|
+
}) : [])).values());
|
|
804
|
+
|
|
805
|
+
_indices2.sort(function (a, b) {
|
|
806
|
+
return a - b;
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
var _dragIndices = _indices2;
|
|
810
|
+
|
|
811
|
+
if (selectedRowGroups) {
|
|
812
|
+
var _clickSelection = [[-1, _index2], [-1, _index2]];
|
|
813
|
+
|
|
814
|
+
var _expandSelectionToRow4 = expandSelectionToRowOrColumnGroups(_clickSelection, rowGroupKeys, selectedRowGroups, 1),
|
|
815
|
+
_expandSelectionToRow5 = _expandSelectionToRow4[0],
|
|
816
|
+
top = _expandSelectionToRow5[1],
|
|
817
|
+
_expandSelectionToRow6 = _expandSelectionToRow4[1],
|
|
818
|
+
bottom = _expandSelectionToRow6[1];
|
|
819
|
+
|
|
820
|
+
var _connected = !(minY > bottom || maxY < top);
|
|
821
|
+
|
|
822
|
+
var _dragStart = _connected ? Math.min(minY, top) : top;
|
|
823
|
+
|
|
824
|
+
var _dragEnd = _connected ? Math.max(maxY, bottom) : bottom;
|
|
825
|
+
|
|
826
|
+
_dragIndices = seq(_dragEnd - _dragStart + 1, _dragStart);
|
|
827
|
+
}
|
|
678
828
|
|
|
679
829
|
var _size2 = rowToPixel(maxY, 1) - rowToPixel(minY);
|
|
680
830
|
|
|
@@ -688,6 +838,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
688
838
|
indices: _indices2
|
|
689
839
|
});
|
|
690
840
|
onDragOffsetChange === null || onDragOffsetChange === void 0 ? void 0 : onDragOffsetChange([0, 0]);
|
|
841
|
+
onDragIndicesChange === null || onDragIndicesChange === void 0 ? void 0 : onDragIndicesChange([null, _dragIndices]);
|
|
691
842
|
return;
|
|
692
843
|
}
|
|
693
844
|
}
|
|
@@ -762,7 +913,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
762
913
|
|
|
763
914
|
setDraggingSelection(true);
|
|
764
915
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange([anchor, head], scrollTo, true);
|
|
765
|
-
}, [getMousePosition, getScrollPosition, getMouseHit, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onKnobAreaChange, onSelectionChange, onCommit, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow]);
|
|
916
|
+
}, [getMousePosition, getScrollPosition, getMouseHit, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onKnobAreaChange, onSelectionChange, onCommit, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, dontCommitEditOnSelectionChange, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups]);
|
|
766
917
|
var onPointerUp = useCallback(function (e) {
|
|
767
918
|
var _getMouseHit;
|
|
768
919
|
|
|
@@ -792,18 +943,19 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
792
943
|
|
|
793
944
|
if (xy && (columnDrag || rowDrag)) {
|
|
794
945
|
window.document.body.style.cursor = 'auto';
|
|
946
|
+
onDragIndicesChange === null || onDragIndicesChange === void 0 ? void 0 : onDragIndicesChange([null, null]);
|
|
795
947
|
onDragOffsetChange === null || onDragOffsetChange === void 0 ? void 0 : onDragOffsetChange(null);
|
|
796
948
|
onDropTargetChange === null || onDropTargetChange === void 0 ? void 0 : onDropTargetChange(null);
|
|
797
949
|
var x = xy[0],
|
|
798
950
|
y = xy[1];
|
|
799
951
|
|
|
800
|
-
var
|
|
801
|
-
|
|
802
|
-
minX =
|
|
803
|
-
minY =
|
|
804
|
-
|
|
805
|
-
maxX =
|
|
806
|
-
maxY =
|
|
952
|
+
var _normalizeSelection2 = normalizeSelection(selection),
|
|
953
|
+
_normalizeSelection2$ = _normalizeSelection2[0],
|
|
954
|
+
minX = _normalizeSelection2$[0],
|
|
955
|
+
minY = _normalizeSelection2$[1],
|
|
956
|
+
_normalizeSelection2$2 = _normalizeSelection2[1],
|
|
957
|
+
maxX = _normalizeSelection2$2[0],
|
|
958
|
+
maxY = _normalizeSelection2$2[1];
|
|
807
959
|
|
|
808
960
|
var cellX = pixelToColumn(Math.max(x, getIndentX()), 0.5);
|
|
809
961
|
var cellY = pixelToRow(Math.max(y, getIndentY()), 0.5);
|
|
@@ -811,10 +963,14 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
811
963
|
if (columnDrag) {
|
|
812
964
|
var indices = columnDrag.indices;
|
|
813
965
|
var insideSelection = cellX >= minX && cellX <= maxX + 1;
|
|
966
|
+
var insideGroup = selectedColumnGroups === null || selectedColumnGroups === void 0 ? void 0 : selectedColumnGroups.has(columnGroupKeys(x));
|
|
814
967
|
|
|
815
|
-
if (!insideSelection) {
|
|
816
|
-
var
|
|
817
|
-
|
|
968
|
+
if (!insideSelection && !insideGroup) {
|
|
969
|
+
var preceding = indices.filter(function (i) {
|
|
970
|
+
return i < cellX;
|
|
971
|
+
});
|
|
972
|
+
var order = cellX - preceding.length;
|
|
973
|
+
dontChangeSelectionOnOrderChange || (onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange([[order, minY], [order + indices.length - 1, maxY]]));
|
|
818
974
|
onColumnOrderChange === null || onColumnOrderChange === void 0 ? void 0 : onColumnOrderChange(indices, order);
|
|
819
975
|
onInvalidateColumn === null || onInvalidateColumn === void 0 ? void 0 : onInvalidateColumn(Math.min(minX, order));
|
|
820
976
|
}
|
|
@@ -825,10 +981,16 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
825
981
|
|
|
826
982
|
var _insideSelection = cellY >= minY && cellY <= maxY + 1;
|
|
827
983
|
|
|
828
|
-
|
|
829
|
-
|
|
984
|
+
var _insideGroup = selectedRowGroups === null || selectedRowGroups === void 0 ? void 0 : selectedRowGroups.has(rowGroupKeys(y));
|
|
985
|
+
|
|
986
|
+
if (!_insideSelection && !_insideGroup) {
|
|
987
|
+
var _preceding = _indices4.filter(function (i) {
|
|
988
|
+
return i < cellY;
|
|
989
|
+
});
|
|
830
990
|
|
|
831
|
-
|
|
991
|
+
var _order = cellY - _preceding.length;
|
|
992
|
+
|
|
993
|
+
dontChangeSelectionOnOrderChange || (onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange([[minX, _order], [maxX, _order + _indices4.length - 1]]));
|
|
832
994
|
onRowOrderChange === null || onRowOrderChange === void 0 ? void 0 : onRowOrderChange(_indices4, _order);
|
|
833
995
|
onInvalidateRow === null || onInvalidateRow === void 0 ? void 0 : onInvalidateRow(Math.min(minY, _order));
|
|
834
996
|
}
|
|
@@ -854,7 +1016,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
854
1016
|
var obj = hitTarget.obj;
|
|
855
1017
|
(_obj$onClick = obj.onClick) === null || _obj$onClick === void 0 ? void 0 : _obj$onClick.call(obj, e);
|
|
856
1018
|
}
|
|
857
|
-
}, [getMousePosition, getMouseHit, onChange, onSelectionChange, onKnobAreaChange, onDropTargetChange, onColumnOrderChange, onRowOrderChange]);
|
|
1019
|
+
}, [getMousePosition, getMouseHit, onChange, onSelectionChange, onKnobAreaChange, onDropTargetChange, onColumnOrderChange, onRowOrderChange, dontChangeSelectionOnOrderChange]);
|
|
858
1020
|
var onPointerMove = useCallback(function (e) {
|
|
859
1021
|
var _ref$current3 = ref.current,
|
|
860
1022
|
selection = _ref$current3.selection,
|
|
@@ -900,13 +1062,13 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
900
1062
|
var x = xy[0],
|
|
901
1063
|
y = xy[1];
|
|
902
1064
|
|
|
903
|
-
var
|
|
904
|
-
|
|
905
|
-
minX =
|
|
906
|
-
minY =
|
|
907
|
-
|
|
908
|
-
maxX =
|
|
909
|
-
maxY =
|
|
1065
|
+
var _normalizeSelection3 = normalizeSelection(selection),
|
|
1066
|
+
_normalizeSelection3$ = _normalizeSelection3[0],
|
|
1067
|
+
minX = _normalizeSelection3$[0],
|
|
1068
|
+
minY = _normalizeSelection3$[1],
|
|
1069
|
+
_normalizeSelection3$2 = _normalizeSelection3[1],
|
|
1070
|
+
maxX = _normalizeSelection3$2[0],
|
|
1071
|
+
maxY = _normalizeSelection3$2[1];
|
|
910
1072
|
|
|
911
1073
|
var isDragging = columnResize || columnDrag || rowResize || rowDrag || draggingRowSelection || draggingColumnSelection;
|
|
912
1074
|
|
|
@@ -916,7 +1078,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
916
1078
|
var start = columnToPixel(minX) + SIZES.resizeZone;
|
|
917
1079
|
var end = columnToPixel(maxX, 1) - SIZES.resizeZone;
|
|
918
1080
|
|
|
919
|
-
if (isInRange(x, start, end)) {
|
|
1081
|
+
if (isInRange(x, start, end) || selectedColumnGroups) {
|
|
920
1082
|
for (var _iterator6 = _createForOfIteratorHelperLoose(columns), _step6; !(_step6 = _iterator6()).done;) {
|
|
921
1083
|
var index = _step6.value;
|
|
922
1084
|
|
|
@@ -924,7 +1086,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
924
1086
|
|
|
925
1087
|
var _end4 = columnToPixel(index, 1);
|
|
926
1088
|
|
|
927
|
-
if (!draggingColumnSelection && isColumnSelection(selection) && isInRange(x, _start4, _end4) && isInRange(index, minX, maxX) && canOrderColumn(index)) {
|
|
1089
|
+
if (!draggingColumnSelection && isColumnSelection(selection) && isInRange(x, _start4, _end4) && (isInRange(index, minX, maxX) || selectedColumnGroups !== null && selectedColumnGroups !== void 0 && selectedColumnGroups.has(columnGroupKeys(index))) && canOrderColumn(index)) {
|
|
928
1090
|
window.document.body.style.cursor = 'grab';
|
|
929
1091
|
return;
|
|
930
1092
|
}
|
|
@@ -951,7 +1113,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
951
1113
|
|
|
952
1114
|
var _end5 = rowToPixel(maxY, 1) - SIZES.resizeZone;
|
|
953
1115
|
|
|
954
|
-
if (isInRange(y, _start5, _end5)) {
|
|
1116
|
+
if (isInRange(y, _start5, _end5) || selectedRowGroups) {
|
|
955
1117
|
for (var _iterator8 = _createForOfIteratorHelperLoose(rows), _step8; !(_step8 = _iterator8()).done;) {
|
|
956
1118
|
var _index5 = _step8.value;
|
|
957
1119
|
|
|
@@ -959,7 +1121,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
959
1121
|
|
|
960
1122
|
var _end6 = rowToPixel(_index5, 1);
|
|
961
1123
|
|
|
962
|
-
if (!draggingRowSelection && isRowSelection(selection) && isInRange(y, _start6, _end6) && isInRange(_index5, minY, maxY) && canOrderRow(_index5)) {
|
|
1124
|
+
if (!draggingRowSelection && isRowSelection(selection) && isInRange(y, _start6, _end6) && (isInRange(_index5, minY, maxY) || selectedRowGroups !== null && selectedRowGroups !== void 0 && selectedRowGroups.has(rowGroupKeys(_index5))) && canOrderRow(_index5)) {
|
|
963
1125
|
window.document.body.style.cursor = 'grab';
|
|
964
1126
|
return;
|
|
965
1127
|
}
|
|
@@ -1052,13 +1214,13 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1052
1214
|
cellX = _pixelToCell[0],
|
|
1053
1215
|
cellY = _pixelToCell[1];
|
|
1054
1216
|
|
|
1055
|
-
var
|
|
1056
|
-
|
|
1057
|
-
_minX =
|
|
1058
|
-
_minY =
|
|
1059
|
-
|
|
1060
|
-
_maxX =
|
|
1061
|
-
_maxY =
|
|
1217
|
+
var _normalizeSelection4 = normalizeSelection(selection),
|
|
1218
|
+
_normalizeSelection4$ = _normalizeSelection4[0],
|
|
1219
|
+
_minX = _normalizeSelection4$[0],
|
|
1220
|
+
_minY = _normalizeSelection4$[1],
|
|
1221
|
+
_normalizeSelection4$2 = _normalizeSelection4[1],
|
|
1222
|
+
_maxX = _normalizeSelection4$2[0],
|
|
1223
|
+
_maxY = _normalizeSelection4$2[1];
|
|
1062
1224
|
|
|
1063
1225
|
var xCellDiff = Math.min(cellX - _minX, _maxX - cellX, 0);
|
|
1064
1226
|
var yCellDiff = Math.min(cellY - _minY, _maxY - cellY, 0);
|
|
@@ -1088,6 +1250,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1088
1250
|
var _cellX = pixelToColumn(Math.max(_x, getIndentX()), 0.5);
|
|
1089
1251
|
|
|
1090
1252
|
var insideSelection = _cellX >= minX && _cellX <= maxX + 1;
|
|
1253
|
+
var insideGroup = isBoundaryInsideGroup(_cellX, columnGroupKeys);
|
|
1091
1254
|
var _anchor3 = columnDrag.anchor,
|
|
1092
1255
|
_scroll5 = columnDrag.scroll;
|
|
1093
1256
|
var shift = _x - _anchor3;
|
|
@@ -1096,7 +1259,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1096
1259
|
_currentScroll2 = _getScrollPosition7[0];
|
|
1097
1260
|
|
|
1098
1261
|
onDragOffsetChange === null || onDragOffsetChange === void 0 ? void 0 : onDragOffsetChange([shift + _currentScroll2 - _scroll5, 0]);
|
|
1099
|
-
onDropTargetChange === null || onDropTargetChange === void 0 ? void 0 : onDropTargetChange(insideSelection ? null : [[_cellX, -1], [_cellX, -1]]);
|
|
1262
|
+
onDropTargetChange === null || onDropTargetChange === void 0 ? void 0 : onDropTargetChange(insideSelection || insideGroup ? null : [[_cellX, -1], [_cellX, -1]]);
|
|
1100
1263
|
}
|
|
1101
1264
|
|
|
1102
1265
|
if (rowDrag) {
|
|
@@ -1104,6 +1267,8 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1104
1267
|
|
|
1105
1268
|
var _insideSelection2 = _cellY >= minY && _cellY <= maxY + 1;
|
|
1106
1269
|
|
|
1270
|
+
var _insideGroup2 = isBoundaryInsideGroup(_cellY, rowGroupKeys);
|
|
1271
|
+
|
|
1107
1272
|
var _anchor4 = rowDrag.anchor,
|
|
1108
1273
|
_scroll6 = rowDrag.scroll;
|
|
1109
1274
|
|
|
@@ -1113,10 +1278,10 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1113
1278
|
_currentScroll3 = _getScrollPosition8[1];
|
|
1114
1279
|
|
|
1115
1280
|
onDragOffsetChange === null || onDragOffsetChange === void 0 ? void 0 : onDragOffsetChange([0, _shift + _currentScroll3 - _scroll6]);
|
|
1116
|
-
onDropTargetChange === null || onDropTargetChange === void 0 ? void 0 : onDropTargetChange(_insideSelection2 ? null : [[-1, _cellY], [-1, _cellY]]);
|
|
1281
|
+
onDropTargetChange === null || onDropTargetChange === void 0 ? void 0 : onDropTargetChange(_insideSelection2 || _insideGroup2 ? null : [[-1, _cellY], [-1, _cellY]]);
|
|
1117
1282
|
}
|
|
1118
1283
|
}
|
|
1119
|
-
}, [getMousePosition, getScrollPosition, getMouseHit, onCellWidthChange, onCellHeightChange]);
|
|
1284
|
+
}, [getMousePosition, getScrollPosition, getMouseHit, onCellWidthChange, onCellHeightChange, onDragIndicesChange, onDragOffsetChange, onDropTargetChange, onSelectionChange, onKnobAreaChange, onInvalidateRow, onInvalidateColumn, columnGroupKeys, rowGroupKeys]);
|
|
1120
1285
|
var onDoubleClick = useCallback(function (e) {
|
|
1121
1286
|
var pixelToCell = ref.current.cellLayout.pixelToCell;
|
|
1122
1287
|
e.preventDefault();
|
|
@@ -1180,21 +1345,21 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1180
1345
|
};
|
|
1181
1346
|
|
|
1182
1347
|
var parseKnobOperation = function parseKnobOperation(knobArea, selection, sourceData, editData, cellReadOnly) {
|
|
1183
|
-
var
|
|
1348
|
+
var _normalizeSelection5 = normalizeSelection(knobArea),
|
|
1349
|
+
_normalizeSelection5$ = _normalizeSelection5[0],
|
|
1350
|
+
kx1 = _normalizeSelection5$[0],
|
|
1351
|
+
ky1 = _normalizeSelection5$[1],
|
|
1352
|
+
_normalizeSelection5$2 = _normalizeSelection5[1],
|
|
1353
|
+
kx2 = _normalizeSelection5$2[0],
|
|
1354
|
+
ky2 = _normalizeSelection5$2[1];
|
|
1355
|
+
|
|
1356
|
+
var _normalizeSelection6 = normalizeSelection(selection),
|
|
1184
1357
|
_normalizeSelection6$ = _normalizeSelection6[0],
|
|
1185
|
-
|
|
1186
|
-
|
|
1358
|
+
sx1 = _normalizeSelection6$[0],
|
|
1359
|
+
sy1 = _normalizeSelection6$[1],
|
|
1187
1360
|
_normalizeSelection6$2 = _normalizeSelection6[1],
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
var _normalizeSelection7 = normalizeSelection(selection),
|
|
1192
|
-
_normalizeSelection7$ = _normalizeSelection7[0],
|
|
1193
|
-
sx1 = _normalizeSelection7$[0],
|
|
1194
|
-
sy1 = _normalizeSelection7$[1],
|
|
1195
|
-
_normalizeSelection7$2 = _normalizeSelection7[1],
|
|
1196
|
-
sx2 = _normalizeSelection7$2[0],
|
|
1197
|
-
sy2 = _normalizeSelection7$2[1];
|
|
1361
|
+
sx2 = _normalizeSelection6$2[0],
|
|
1362
|
+
sy2 = _normalizeSelection6$2[1];
|
|
1198
1363
|
|
|
1199
1364
|
var fx1 = kx1;
|
|
1200
1365
|
var fy1 = ky1;
|
|
@@ -2008,6 +2173,8 @@ var makeIntMap = function makeIntMap(initialSize) {
|
|
|
2008
2173
|
};
|
|
2009
2174
|
|
|
2010
2175
|
var resolveSheetStyle = function resolveSheetStyle(sheetStyle) {
|
|
2176
|
+
var _sheetStyle$shadowBlu, _sheetStyle$shadowOpa, _sheetStyle$shadowCol;
|
|
2177
|
+
|
|
2011
2178
|
return {
|
|
2012
2179
|
freezeColumns: (sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.freezeColumns) || 0,
|
|
2013
2180
|
freezeRows: (sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.freezeRows) || 0,
|
|
@@ -2016,7 +2183,10 @@ var resolveSheetStyle = function resolveSheetStyle(sheetStyle) {
|
|
|
2016
2183
|
hideGridlines: (sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.hideGridlines) || false,
|
|
2017
2184
|
hideScrollBars: (sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.hideScrollBars) || false,
|
|
2018
2185
|
columnHeaderHeight: sheetStyle !== null && sheetStyle !== void 0 && sheetStyle.hideColumnHeaders ? 1 : SIZES.headerHeight,
|
|
2019
|
-
rowHeaderWidth: sheetStyle !== null && sheetStyle !== void 0 && sheetStyle.hideRowHeaders ? 1 : SIZES.headerWidth
|
|
2186
|
+
rowHeaderWidth: sheetStyle !== null && sheetStyle !== void 0 && sheetStyle.hideRowHeaders ? 1 : SIZES.headerWidth,
|
|
2187
|
+
shadowBlur: (_sheetStyle$shadowBlu = sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.shadowBlur) != null ? _sheetStyle$shadowBlu : SIZES.shadowBlur,
|
|
2188
|
+
shadowOpacity: (_sheetStyle$shadowOpa = sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.shadowOpacity) != null ? _sheetStyle$shadowOpa : SIZES.shadowOpacity,
|
|
2189
|
+
shadowColor: (_sheetStyle$shadowCol = sheetStyle === null || sheetStyle === void 0 ? void 0 : sheetStyle.shadowColor) != null ? _sheetStyle$shadowCol : COLORS.shadowColor
|
|
2020
2190
|
};
|
|
2021
2191
|
};
|
|
2022
2192
|
var resolveCellStyle = function resolveCellStyle(optionalStyle, defaultStyle) {
|
|
@@ -2038,7 +2208,7 @@ var applyAlignment = function applyAlignment(start, cellSize, style, imageWidth,
|
|
|
2038
2208
|
return start;
|
|
2039
2209
|
};
|
|
2040
2210
|
|
|
2041
|
-
var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, dataOffset) {
|
|
2211
|
+
var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragIndices, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups, dataOffset) {
|
|
2042
2212
|
var canvas = context.canvas;
|
|
2043
2213
|
var width = canvas.width,
|
|
2044
2214
|
height = canvas.height;
|
|
@@ -2048,11 +2218,16 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2048
2218
|
rowHeaderWidth = sheetStyle.rowHeaderWidth,
|
|
2049
2219
|
columnHeaderHeight = sheetStyle.columnHeaderHeight,
|
|
2050
2220
|
freezeColumns = sheetStyle.freezeColumns,
|
|
2051
|
-
freezeRows = sheetStyle.freezeRows
|
|
2221
|
+
freezeRows = sheetStyle.freezeRows,
|
|
2222
|
+
shadowBlur = sheetStyle.shadowBlur,
|
|
2223
|
+
shadowColor = sheetStyle.shadowColor,
|
|
2224
|
+
shadowOpacity = sheetStyle.shadowOpacity;
|
|
2052
2225
|
var columns = visibleCells.columns,
|
|
2053
2226
|
rows = visibleCells.rows;
|
|
2054
2227
|
var columnToPixel = cellLayout.columnToPixel,
|
|
2055
|
-
rowToPixel = cellLayout.rowToPixel
|
|
2228
|
+
rowToPixel = cellLayout.rowToPixel,
|
|
2229
|
+
columnToAbsolute = cellLayout.columnToAbsolute,
|
|
2230
|
+
rowToAbsolute = cellLayout.rowToAbsolute;
|
|
2056
2231
|
var clickables = [];
|
|
2057
2232
|
var freeze = [freezeColumns, freezeRows];
|
|
2058
2233
|
var indent = [rowHeaderWidth, columnHeaderHeight];
|
|
@@ -2060,12 +2235,13 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2060
2235
|
context.clearRect(0, 0, width, height);
|
|
2061
2236
|
context.fillStyle = 'white';
|
|
2062
2237
|
context.fillRect(0, 0, width, height);
|
|
2238
|
+
context.shadowColor = '#00000080';
|
|
2063
2239
|
|
|
2064
2240
|
for (var _iterator = _createForOfIteratorHelperLoose(rows), _step; !(_step = _iterator()).done;) {
|
|
2065
2241
|
var y = _step.value;
|
|
2066
2242
|
|
|
2067
|
-
for (var
|
|
2068
|
-
var x =
|
|
2243
|
+
for (var _iterator10 = _createForOfIteratorHelperLoose(columns), _step10; !(_step10 = _iterator10()).done;) {
|
|
2244
|
+
var x = _step10.value;
|
|
2069
2245
|
|
|
2070
2246
|
var _left7 = columnToPixel(x);
|
|
2071
2247
|
|
|
@@ -2139,15 +2315,15 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2139
2315
|
|
|
2140
2316
|
var drawGridLineX = function drawGridLineX(x, height) {
|
|
2141
2317
|
context.beginPath();
|
|
2142
|
-
context.moveTo(x - .5, 0);
|
|
2143
|
-
context.lineTo(x - .5, height);
|
|
2318
|
+
context.moveTo(x - 0.5, 0);
|
|
2319
|
+
context.lineTo(x - 0.5, height);
|
|
2144
2320
|
context.stroke();
|
|
2145
2321
|
};
|
|
2146
2322
|
|
|
2147
2323
|
var drawGridLineY = function drawGridLineY(y, width) {
|
|
2148
2324
|
context.beginPath();
|
|
2149
|
-
context.moveTo(0, y - .5);
|
|
2150
|
-
context.lineTo(width, y - .5);
|
|
2325
|
+
context.moveTo(0, y - 0.5);
|
|
2326
|
+
context.lineTo(width, y - 0.5);
|
|
2151
2327
|
context.stroke();
|
|
2152
2328
|
};
|
|
2153
2329
|
|
|
@@ -2155,17 +2331,17 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2155
2331
|
drawGridLineY(columnHeaderHeight, context.canvas.width);
|
|
2156
2332
|
|
|
2157
2333
|
for (var _iterator2 = _createForOfIteratorHelperLoose(columns), _step2; !(_step2 = _iterator2()).done;) {
|
|
2158
|
-
var
|
|
2334
|
+
var _column2 = _step2.value;
|
|
2159
2335
|
|
|
2160
|
-
var _right8 = columnToPixel(
|
|
2336
|
+
var _right8 = columnToPixel(_column2, 1);
|
|
2161
2337
|
|
|
2162
2338
|
drawGridLineX(_right8, gridBottom);
|
|
2163
2339
|
}
|
|
2164
2340
|
|
|
2165
2341
|
for (var _iterator3 = _createForOfIteratorHelperLoose(rows), _step3; !(_step3 = _iterator3()).done;) {
|
|
2166
|
-
var
|
|
2342
|
+
var _row2 = _step3.value;
|
|
2167
2343
|
|
|
2168
|
-
var _bottom8 = rowToPixel(
|
|
2344
|
+
var _bottom8 = rowToPixel(_row2, 1);
|
|
2169
2345
|
|
|
2170
2346
|
drawGridLineY(_bottom8, gridRight);
|
|
2171
2347
|
}
|
|
@@ -2188,8 +2364,11 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2188
2364
|
var row = _step4.value;
|
|
2189
2365
|
var content = "" + (row + 1);
|
|
2190
2366
|
var isActive = isInRange(row, minY, maxY);
|
|
2191
|
-
var
|
|
2192
|
-
var
|
|
2367
|
+
var groupKey = rowGroupKeys(row);
|
|
2368
|
+
var isInRowGroup = groupKey != null && (selectedRowGroups === null || selectedRowGroups === void 0 ? void 0 : selectedRowGroups.has(groupKey));
|
|
2369
|
+
var isSelfSelected = rowSelectionActive && isActive;
|
|
2370
|
+
var isGroupSelected = rowSelectionActive && isInRowGroup;
|
|
2371
|
+
var style = isSelfSelected ? HEADER_SELECTED_STYLE : isGroupSelected ? HEADER_GROUP_SELECTED_STYLE : isActive ? HEADER_ACTIVE_STYLE : NO_STYLE;
|
|
2193
2372
|
|
|
2194
2373
|
var _top2 = rowToPixel(row);
|
|
2195
2374
|
|
|
@@ -2212,7 +2391,11 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2212
2391
|
|
|
2213
2392
|
var _isActive = isInRange(column, minX, maxX);
|
|
2214
2393
|
|
|
2215
|
-
var
|
|
2394
|
+
var _groupKey = columnGroupKeys(column);
|
|
2395
|
+
|
|
2396
|
+
var isInColumnGroup = _groupKey != null && (selectedColumnGroups === null || selectedColumnGroups === void 0 ? void 0 : selectedColumnGroups.has(_groupKey));
|
|
2397
|
+
var isSelected = columnSelectionActive && !rowSelectionActive && (_isActive || isInColumnGroup);
|
|
2398
|
+
var selectedStyle = isSelected ? HEADER_SELECTED_STYLE : NO_STYLE;
|
|
2216
2399
|
var activeStyle = _isActive ? HEADER_ACTIVE_STYLE : NO_STYLE;
|
|
2217
2400
|
|
|
2218
2401
|
var _style = _extends({}, columnHeaderStyle(column), activeStyle, selectedStyle);
|
|
@@ -2291,30 +2474,46 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2291
2474
|
if (dragOffset) {
|
|
2292
2475
|
var shiftX = dragOffset[0],
|
|
2293
2476
|
shiftY = dragOffset[1];
|
|
2477
|
+
var dragColumns = dragIndices[0],
|
|
2478
|
+
dragRows = dragIndices[1];
|
|
2479
|
+
context.fillStyle = COLORS.dragGhost;
|
|
2294
2480
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
_top5 = _resolveSelection$[1],
|
|
2299
|
-
_resolveSelection$2 = _resolveSelection[1],
|
|
2300
|
-
_right5 = _resolveSelection$2[0],
|
|
2301
|
-
_bottom5 = _resolveSelection$2[1];
|
|
2481
|
+
if (dragColumns) {
|
|
2482
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose(dragColumns), _step7; !(_step7 = _iterator7()).done;) {
|
|
2483
|
+
var _column = _step7.value;
|
|
2302
2484
|
|
|
2303
|
-
|
|
2304
|
-
|
|
2485
|
+
var _left5 = columnToPixel(_column);
|
|
2486
|
+
|
|
2487
|
+
var _right5 = columnToPixel(_column, 1);
|
|
2488
|
+
|
|
2489
|
+
context.fillRect(_left5 + shiftX, 0, _right5 - _left5, height);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
if (dragRows) {
|
|
2494
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose(dragRows), _step8; !(_step8 = _iterator8()).done;) {
|
|
2495
|
+
var _row = _step8.value;
|
|
2496
|
+
|
|
2497
|
+
var _top5 = rowToPixel(_row);
|
|
2498
|
+
|
|
2499
|
+
var _bottom5 = rowToPixel(_row, 1);
|
|
2500
|
+
|
|
2501
|
+
context.fillRect(0, _top5 + shiftY, width, _bottom5 - _top5);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2305
2504
|
}
|
|
2306
2505
|
|
|
2307
2506
|
if (dropTarget) {
|
|
2308
|
-
var
|
|
2309
|
-
|
|
2310
|
-
_left6 =
|
|
2311
|
-
_top6 =
|
|
2312
|
-
|
|
2313
|
-
_right6 =
|
|
2314
|
-
_bottom6 =
|
|
2507
|
+
var _resolveSelection = resolveSelection(dropTarget, cellLayout),
|
|
2508
|
+
_resolveSelection$ = _resolveSelection[0],
|
|
2509
|
+
_left6 = _resolveSelection$[0],
|
|
2510
|
+
_top6 = _resolveSelection$[1],
|
|
2511
|
+
_resolveSelection$2 = _resolveSelection[1],
|
|
2512
|
+
_right6 = _resolveSelection$2[0],
|
|
2513
|
+
_bottom6 = _resolveSelection$2[1];
|
|
2315
2514
|
|
|
2316
2515
|
context.strokeStyle = COLORS.dropTarget;
|
|
2317
|
-
context.lineWidth =
|
|
2516
|
+
context.lineWidth = 4;
|
|
2318
2517
|
|
|
2319
2518
|
if (isColumnSelection(dropTarget)) {
|
|
2320
2519
|
_right6 = _left6;
|
|
@@ -2327,13 +2526,38 @@ var renderSheet = function renderSheet(context, cellLayout, visibleCells, sheetS
|
|
|
2327
2526
|
context.strokeRect(_left6 - 1, _top6 - 1, _right6 - _left6, _bottom6 - _top6);
|
|
2328
2527
|
}
|
|
2329
2528
|
|
|
2529
|
+
var scrollX = dataOffset[0],
|
|
2530
|
+
scrollY = dataOffset[1];
|
|
2531
|
+
var hasRowShadow = freezeRows > 0 && scrollY > 0;
|
|
2532
|
+
var hasColumnShadow = freezeColumns > 0 && scrollX > 0;
|
|
2533
|
+
|
|
2534
|
+
if (hasRowShadow || hasColumnShadow) {
|
|
2535
|
+
if (hasRowShadow) {
|
|
2536
|
+
var h = columnHeaderHeight + rowToAbsolute(freezeRows);
|
|
2537
|
+
var gradient = context.createLinearGradient(0, h, 0, h + shadowBlur);
|
|
2538
|
+
halfShadowGradient(gradient, shadowColor, shadowOpacity);
|
|
2539
|
+
context.fillStyle = gradient;
|
|
2540
|
+
context.fillRect(0, h, width, shadowBlur);
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
if (hasColumnShadow) {
|
|
2544
|
+
var w = rowHeaderWidth + columnToAbsolute(freezeColumns);
|
|
2545
|
+
|
|
2546
|
+
var _gradient = context.createLinearGradient(w, 0, w + shadowBlur, 0);
|
|
2547
|
+
|
|
2548
|
+
halfShadowGradient(_gradient, shadowColor, shadowOpacity);
|
|
2549
|
+
context.fillStyle = _gradient;
|
|
2550
|
+
context.fillRect(w, 0, shadowBlur, height);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2330
2554
|
context.textBaseline = 'middle';
|
|
2331
2555
|
|
|
2332
|
-
for (var
|
|
2333
|
-
var _y =
|
|
2556
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose(rows), _step9; !(_step9 = _iterator9()).done;) {
|
|
2557
|
+
var _y = _step9.value;
|
|
2334
2558
|
|
|
2335
|
-
for (var
|
|
2336
|
-
var _x =
|
|
2559
|
+
for (var _iterator11 = _createForOfIteratorHelperLoose(columns), _step11; !(_step11 = _iterator11()).done;) {
|
|
2560
|
+
var _x = _step11.value;
|
|
2337
2561
|
|
|
2338
2562
|
var _left9 = columnToPixel(_x);
|
|
2339
2563
|
|
|
@@ -2383,8 +2607,8 @@ var renderCell = function renderCell(context, cellContent, style, defaultCellSty
|
|
|
2383
2607
|
var text = '' + cellContent;
|
|
2384
2608
|
context.fillText(text, xx, yy);
|
|
2385
2609
|
} else if (typeof cellContent === 'object') {
|
|
2386
|
-
for (var
|
|
2387
|
-
var obj =
|
|
2610
|
+
for (var _iterator12 = _createForOfIteratorHelperLoose(cellContent.items), _step12; !(_step12 = _iterator12()).done;) {
|
|
2611
|
+
var obj = _step12.value;
|
|
2388
2612
|
var x = 0;
|
|
2389
2613
|
var y = 0;
|
|
2390
2614
|
var w = 0;
|
|
@@ -2592,8 +2816,27 @@ var excelHeaderString = function excelHeaderString(num) {
|
|
|
2592
2816
|
return s || '';
|
|
2593
2817
|
};
|
|
2594
2818
|
|
|
2819
|
+
var halfShadowGradient = function halfShadowGradient(gradient, rgb, opacity) {
|
|
2820
|
+
var hex = function hex(x) {
|
|
2821
|
+
return ('0' + Math.round(x).toString(16)).slice(-2);
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2824
|
+
var ease = function ease(x) {
|
|
2825
|
+
return 1.0 - Math.sin(x * Math.PI / 2);
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
var adjust = function adjust(x) {
|
|
2829
|
+
return 1.0 - Math.pow(1.0 - x, 2.2);
|
|
2830
|
+
};
|
|
2831
|
+
|
|
2832
|
+
for (var i = 0; i <= 16; ++i) {
|
|
2833
|
+
var f = i / 16;
|
|
2834
|
+
gradient.addColorStop(f, rgb + hex(adjust(opacity * ease(f) * 0.5) * 255));
|
|
2835
|
+
}
|
|
2836
|
+
};
|
|
2837
|
+
|
|
2595
2838
|
var Sheet = forwardRef(function (props, ref) {
|
|
2596
|
-
var _props$selection, _props$secondarySelec, _props$inputComponent;
|
|
2839
|
+
var _props$selection, _props$secondarySelec, _props$cacheLayout, _props$inputComponent;
|
|
2597
2840
|
|
|
2598
2841
|
var canvasRef = useRef(null);
|
|
2599
2842
|
var overlayRef = useRef(null);
|
|
@@ -2620,33 +2863,37 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2620
2863
|
dragOffset = _useState5[0],
|
|
2621
2864
|
setDragOffset = _useState5[1];
|
|
2622
2865
|
|
|
2623
|
-
var _useState6 = useState(null),
|
|
2624
|
-
|
|
2625
|
-
|
|
2866
|
+
var _useState6 = useState([null, null]),
|
|
2867
|
+
dragIndices = _useState6[0],
|
|
2868
|
+
setDragIndices = _useState6[1];
|
|
2626
2869
|
|
|
2627
|
-
var _useState7 = useState(
|
|
2628
|
-
|
|
2629
|
-
|
|
2870
|
+
var _useState7 = useState(null),
|
|
2871
|
+
dropTarget = _useState7[0],
|
|
2872
|
+
setDropTarget = _useState7[1];
|
|
2630
2873
|
|
|
2631
|
-
var _useState8 = useState(
|
|
2632
|
-
|
|
2633
|
-
|
|
2874
|
+
var _useState8 = useState(NO_CELL),
|
|
2875
|
+
editCell = _useState8[0],
|
|
2876
|
+
setEditCell = _useState8[1];
|
|
2877
|
+
|
|
2878
|
+
var _useState9 = useState(selectionProp),
|
|
2879
|
+
lastSelectionProp = _useState9[0],
|
|
2880
|
+
setLastSelectionProp = _useState9[1];
|
|
2634
2881
|
|
|
2635
2882
|
if (lastSelectionProp !== selectionProp) {
|
|
2636
2883
|
setLastSelectionProp(selectionProp);
|
|
2637
2884
|
setSelection(selectionProp);
|
|
2638
2885
|
}
|
|
2639
2886
|
|
|
2640
|
-
var
|
|
2641
|
-
editValue =
|
|
2642
|
-
setEditValue =
|
|
2887
|
+
var _useState10 = useState(''),
|
|
2888
|
+
editValue = _useState10[0],
|
|
2889
|
+
setEditValue = _useState10[1];
|
|
2643
2890
|
|
|
2644
|
-
var
|
|
2645
|
-
arrowKeyCommitMode =
|
|
2646
|
-
setArrowKeyCommitMode =
|
|
2891
|
+
var _useState11 = useState(false),
|
|
2892
|
+
arrowKeyCommitMode = _useState11[0],
|
|
2893
|
+
setArrowKeyCommitMode = _useState11[1];
|
|
2647
2894
|
|
|
2648
2895
|
var _useResizeObserver = useResizeObserver({
|
|
2649
|
-
ref:
|
|
2896
|
+
ref: overlayRef
|
|
2650
2897
|
}),
|
|
2651
2898
|
_useResizeObserver$wi = _useResizeObserver.width,
|
|
2652
2899
|
canvasWidth = _useResizeObserver$wi === void 0 ? 3000 : _useResizeObserver$wi,
|
|
@@ -2677,6 +2924,12 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2677
2924
|
var canOrderRow = useMemo(function () {
|
|
2678
2925
|
return createRowOrColumnProp(props.canOrderRow, true);
|
|
2679
2926
|
}, [props.canOrderRow]);
|
|
2927
|
+
var rowGroupKeys = useMemo(function () {
|
|
2928
|
+
return createRowOrColumnProp(props.rowGroupKeys, null);
|
|
2929
|
+
}, [props.rowGroupKeys]);
|
|
2930
|
+
var columnGroupKeys = useMemo(function () {
|
|
2931
|
+
return createRowOrColumnProp(props.columnGroupKeys, null);
|
|
2932
|
+
}, [props.columnGroupKeys]);
|
|
2680
2933
|
var cellReadOnly = useMemo(function () {
|
|
2681
2934
|
return createCellProp(props.readOnly, false);
|
|
2682
2935
|
}, [props.readOnly]);
|
|
@@ -2699,22 +2952,38 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2699
2952
|
return resolveSheetStyle(props.sheetStyle);
|
|
2700
2953
|
}, [props.sheetStyle]);
|
|
2701
2954
|
var secondarySelections = (_props$secondarySelec = props.secondarySelections) != null ? _props$secondarySelec : NO_SELECTIONS;
|
|
2955
|
+
var selectedColumnGroups = useMemo(function () {
|
|
2956
|
+
return props.columnGroupKeys ? new Set(mapSelectionColumns(selection)(function (x) {
|
|
2957
|
+
return columnGroupKeys(x);
|
|
2958
|
+
}).filter(function (x) {
|
|
2959
|
+
return x != null;
|
|
2960
|
+
})) : null;
|
|
2961
|
+
}, [props.columnGroupKeys, columnGroupKeys, selection]);
|
|
2962
|
+
var selectedRowGroups = useMemo(function () {
|
|
2963
|
+
return props.rowGroupKeys ? new Set(mapSelectionRows(selection)(function (y) {
|
|
2964
|
+
return rowGroupKeys(y);
|
|
2965
|
+
}).filter(function (x) {
|
|
2966
|
+
return x != null;
|
|
2967
|
+
})) : null;
|
|
2968
|
+
}, [props.rowGroupKeys, rowGroupKeys, selection]);
|
|
2702
2969
|
var maxScrollX = maxScroll[0],
|
|
2703
2970
|
maxScrollY = maxScroll[1];
|
|
2704
2971
|
var editCellX = editCell[0],
|
|
2705
2972
|
editCellY = editCell[1];
|
|
2706
2973
|
var editMode = editCellX !== -1 && editCellY !== -1;
|
|
2974
|
+
var shouldCacheLayout = ((_props$cacheLayout = props.cacheLayout) != null ? _props$cacheLayout : false) !== false;
|
|
2975
|
+
var layoutVersion = typeof props.cacheLayout === 'number' ? props.cacheLayout : 0;
|
|
2707
2976
|
var columnLayout = useMemo(function () {
|
|
2708
2977
|
return makeLayoutCache(cellWidth);
|
|
2709
|
-
}, [
|
|
2978
|
+
}, [shouldCacheLayout ? layoutVersion : cellWidth]);
|
|
2710
2979
|
var rowLayout = useMemo(function () {
|
|
2711
2980
|
return makeLayoutCache(cellHeight);
|
|
2712
|
-
}, [
|
|
2981
|
+
}, [shouldCacheLayout ? layoutVersion : cellHeight]);
|
|
2713
2982
|
useMemo(function () {
|
|
2714
|
-
if (!
|
|
2983
|
+
if (!shouldCacheLayout) return;
|
|
2715
2984
|
columnLayout.setSizer(cellWidth);
|
|
2716
2985
|
rowLayout.setSizer(cellHeight);
|
|
2717
|
-
}, [
|
|
2986
|
+
}, [shouldCacheLayout, layoutVersion, cellWidth, cellHeight]);
|
|
2718
2987
|
var freezeColumns = sheetStyle.freezeColumns,
|
|
2719
2988
|
freezeRows = sheetStyle.freezeRows,
|
|
2720
2989
|
rowHeaderWidth = sheetStyle.rowHeaderWidth,
|
|
@@ -2744,7 +3013,7 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2744
3013
|
}
|
|
2745
3014
|
|
|
2746
3015
|
if (!isSameSelection(selection, newSelection)) {
|
|
2747
|
-
setSelection(newSelection);
|
|
3016
|
+
setSelection(validateSelection(newSelection));
|
|
2748
3017
|
}
|
|
2749
3018
|
|
|
2750
3019
|
var overlay = overlayRef.current;
|
|
@@ -2817,7 +3086,7 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2817
3086
|
useClipboardPaste(textAreaRef, selection, changeSelection, props.onChange, cellReadOnly);
|
|
2818
3087
|
var onScroll = useScroll(dataOffset, maxScroll, cellLayout, setDataOffset, setMaxScroll);
|
|
2819
3088
|
|
|
2820
|
-
var _useMouse = useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, cellReadOnly, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, startEditingCell, commitEditingCell, setKnobArea, setDragOffset, setDropTarget, changeSelection, props.cacheLayout ? columnLayout.clearAfter : undefined, props.cacheLayout ? rowLayout.clearAfter : undefined, props.onChange, props.onColumnOrderChange, props.onRowOrderChange, props.onCellWidthChange, props.onCellHeightChange, props.onRightClick, props.dontCommitEditOnSelectionChange),
|
|
3089
|
+
var _useMouse = useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, cellReadOnly, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups, startEditingCell, commitEditingCell, setKnobArea, setDragIndices, setDragOffset, setDropTarget, changeSelection, props.cacheLayout ? columnLayout.clearAfter : undefined, props.cacheLayout ? rowLayout.clearAfter : undefined, props.onChange, props.onColumnOrderChange, props.onRowOrderChange, props.onCellWidthChange, props.onCellHeightChange, props.onRightClick, props.dontCommitEditOnSelectionChange, props.dontChangeSelectionOnOrderChange),
|
|
2821
3090
|
mouseHandlers = _useMouse.mouseHandlers,
|
|
2822
3091
|
knobPosition = _useMouse.knobPosition;
|
|
2823
3092
|
|
|
@@ -2835,12 +3104,12 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2835
3104
|
}
|
|
2836
3105
|
|
|
2837
3106
|
var animationFrameId = window.requestAnimationFrame(function () {
|
|
2838
|
-
hitmapRef.current = renderSheet(context, cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, dataOffset);
|
|
3107
|
+
hitmapRef.current = renderSheet(context, cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragIndices, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups, dataOffset);
|
|
2839
3108
|
});
|
|
2840
3109
|
return function () {
|
|
2841
3110
|
window.cancelAnimationFrame(animationFrameId);
|
|
2842
3111
|
};
|
|
2843
|
-
}, [cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, dataOffset]);
|
|
3112
|
+
}, [cellLayout, visibleCells, sheetStyle, cellStyle, selection, secondarySelections, knobPosition, knobArea, dragOffset, dropTarget, columnHeaders, columnHeaderStyle, displayData, columnGroupKeys, rowGroupKeys, selectedColumnGroups, selectedRowGroups, dataOffset]);
|
|
2844
3113
|
|
|
2845
3114
|
var onKeyDown = function onKeyDown(e) {
|
|
2846
3115
|
if (e.key === 'Escape') {
|
|
@@ -2956,9 +3225,9 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
2956
3225
|
e.preventDefault();
|
|
2957
3226
|
};
|
|
2958
3227
|
|
|
2959
|
-
var
|
|
2960
|
-
lastEditKey =
|
|
2961
|
-
setLastEditKey =
|
|
3228
|
+
var _useState12 = useState(''),
|
|
3229
|
+
lastEditKey = _useState12[0],
|
|
3230
|
+
setLastEditKey = _useState12[1];
|
|
2962
3231
|
|
|
2963
3232
|
var editTextPosition = ORIGIN;
|
|
2964
3233
|
var editTextWidth = 0;
|
|
@@ -3016,8 +3285,8 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
3016
3285
|
borderBottom: '1px solid #ddd'
|
|
3017
3286
|
};
|
|
3018
3287
|
var canvasStyles = {
|
|
3019
|
-
width:
|
|
3020
|
-
height:
|
|
3288
|
+
width: canvasWidth,
|
|
3289
|
+
height: canvasHeight,
|
|
3021
3290
|
outline: '1px solid #ddd'
|
|
3022
3291
|
};
|
|
3023
3292
|
|
|
@@ -3025,7 +3294,6 @@ var Sheet = forwardRef(function (props, ref) {
|
|
|
3025
3294
|
delete canvasStyles['outline'];
|
|
3026
3295
|
delete overlayDivStyles['borderBottom'];
|
|
3027
3296
|
overlayDivClassName = '';
|
|
3028
|
-
canvasStyles.width = 'calc(100%)';
|
|
3029
3297
|
}
|
|
3030
3298
|
|
|
3031
3299
|
var renderedInside = useMemo(function () {
|