sheet-happens 0.0.32 → 0.0.34
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.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +25 -7
- package/dist/index.modern.js.map +1 -1
- package/dist/sheet.d.ts +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -499,6 +499,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
499
499
|
sourceData: sourceData,
|
|
500
500
|
cellLayout: cellLayout,
|
|
501
501
|
visibleCells: visibleCells,
|
|
502
|
+
hitTarget: hitTarget,
|
|
502
503
|
knobPosition: knobPosition,
|
|
503
504
|
columnResize: columnResize,
|
|
504
505
|
rowResize: rowResize,
|
|
@@ -574,6 +575,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
574
575
|
|
|
575
576
|
if (hitTarget) {
|
|
576
577
|
setHitTarget(hitTarget);
|
|
578
|
+
ref.current.hitTarget = hitTarget;
|
|
577
579
|
return;
|
|
578
580
|
}
|
|
579
581
|
|
|
@@ -765,6 +767,8 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
765
767
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange([anchor, head], scrollTo, true);
|
|
766
768
|
}, [getMousePosition, getScrollPosition, getMouseHit, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onKnobAreaChange, onSelectionChange, onCommit, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow]);
|
|
767
769
|
var onPointerUp = React.useCallback(function (e) {
|
|
770
|
+
var _getMouseHit;
|
|
771
|
+
|
|
768
772
|
var _ref$current2 = ref.current,
|
|
769
773
|
knobArea = _ref$current2.knobArea,
|
|
770
774
|
selection = _ref$current2.selection,
|
|
@@ -773,6 +777,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
773
777
|
columnDrag = _ref$current2.columnDrag,
|
|
774
778
|
rowDrag = _ref$current2.rowDrag,
|
|
775
779
|
draggingKnob = _ref$current2.draggingKnob,
|
|
780
|
+
hitTarget = _ref$current2.hitTarget,
|
|
776
781
|
_ref$current2$cellLay = _ref$current2.cellLayout,
|
|
777
782
|
pixelToColumn = _ref$current2$cellLay.pixelToColumn,
|
|
778
783
|
pixelToRow = _ref$current2$cellLay.pixelToRow,
|
|
@@ -782,7 +787,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
782
787
|
if (knobArea && draggingKnob) {
|
|
783
788
|
var changes = parseKnobOperation(knobArea, selection, sourceData, editData);
|
|
784
789
|
onChange === null || onChange === void 0 ? void 0 : onChange(changes);
|
|
785
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(knobArea);
|
|
790
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(knobArea, true, true);
|
|
786
791
|
onKnobAreaChange === null || onKnobAreaChange === void 0 ? void 0 : onKnobAreaChange(null);
|
|
787
792
|
}
|
|
788
793
|
|
|
@@ -843,8 +848,10 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
843
848
|
setRowDrag(null);
|
|
844
849
|
if (!xy || !hitTarget) return;
|
|
845
850
|
setHitTarget(null);
|
|
851
|
+
var previousRect = JSON.stringify(hitTarget.rect);
|
|
852
|
+
var currentRect = JSON.stringify((_getMouseHit = getMouseHit(xy)) === null || _getMouseHit === void 0 ? void 0 : _getMouseHit.rect);
|
|
846
853
|
|
|
847
|
-
if (
|
|
854
|
+
if (previousRect === currentRect) {
|
|
848
855
|
var _obj$onClick;
|
|
849
856
|
|
|
850
857
|
var obj = hitTarget.obj;
|
|
@@ -1382,7 +1389,13 @@ var useClipboardCopy = function useClipboardCopy(textAreaRef, selection, editMod
|
|
|
1382
1389
|
if (!textArea) return;
|
|
1383
1390
|
if (editMode) return;
|
|
1384
1391
|
if (isEmptySelection(selection)) return;
|
|
1385
|
-
|
|
1392
|
+
var v = formatSelectionAsTSV(selection, editData);
|
|
1393
|
+
|
|
1394
|
+
if (v.match(/^[\t\n]*$/)) {
|
|
1395
|
+
v = ' ' + v;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
textArea.value = v;
|
|
1386
1399
|
}, [selection, editMode, editData, textAreaRef]);
|
|
1387
1400
|
React.useLayoutEffect(function () {
|
|
1388
1401
|
var textArea = textAreaRef.current;
|
|
@@ -2705,9 +2718,6 @@ var Sheet = React.forwardRef(function (props, ref) {
|
|
|
2705
2718
|
var cellLayout = React.useMemo(function () {
|
|
2706
2719
|
return makeCellLayout([freezeColumns, freezeRows], [rowHeaderWidth, columnHeaderHeight], dataOffset, columnLayout, rowLayout);
|
|
2707
2720
|
}, [freezeColumns, freezeRows, rowHeaderWidth, columnHeaderHeight, dataOffset, columnLayout, rowLayout]);
|
|
2708
|
-
React.useImperativeHandle(ref, function () {
|
|
2709
|
-
return cellLayout;
|
|
2710
|
-
}, [cellLayout]);
|
|
2711
2721
|
var getVisibleCells = cellLayout.getVisibleCells,
|
|
2712
2722
|
cellToPixel = cellLayout.cellToPixel,
|
|
2713
2723
|
getVersion = cellLayout.getVersion;
|
|
@@ -3032,6 +3042,11 @@ var Sheet = React.forwardRef(function (props, ref) {
|
|
|
3032
3042
|
editMode: editMode
|
|
3033
3043
|
});
|
|
3034
3044
|
}, [props.renderOutside, visibleCells, cellLayout, selection, editMode]);
|
|
3045
|
+
React.useImperativeHandle(ref, function () {
|
|
3046
|
+
return _extends({}, cellLayout, {
|
|
3047
|
+
startEditingCell: startEditingCell
|
|
3048
|
+
});
|
|
3049
|
+
}, [cellLayout, startEditingCell]);
|
|
3035
3050
|
return React__default.createElement("div", {
|
|
3036
3051
|
style: {
|
|
3037
3052
|
position: 'relative',
|
|
@@ -3075,7 +3090,10 @@ var Sheet = React.forwardRef(function (props, ref) {
|
|
|
3075
3090
|
style: {
|
|
3076
3091
|
position: 'absolute',
|
|
3077
3092
|
left: 0,
|
|
3078
|
-
top: 0
|
|
3093
|
+
top: 0,
|
|
3094
|
+
width: '100%',
|
|
3095
|
+
height: '100%',
|
|
3096
|
+
pointerEvents: 'none'
|
|
3079
3097
|
}
|
|
3080
3098
|
}, renderedOutside) : null, React__default.createElement("textarea", {
|
|
3081
3099
|
style: {
|