sheet-happens 0.0.34 → 0.0.36
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/clipboard.d.ts +1 -1
- package/dist/index.js +45 -36
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +45 -36
- package/dist/index.modern.js.map +1 -1
- package/dist/mouse.d.ts +1 -1
- package/package.json +1 -1
package/dist/clipboard.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CellPropertyFunction, Change, Rectangle } from './types';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
export declare const useClipboardCopy: (textAreaRef: RefObject<HTMLTextAreaElement>, selection: Rectangle, editMode: boolean, editData: CellPropertyFunction<string>) => void;
|
|
4
|
-
export declare const useClipboardPaste: (textAreaRef: RefObject<HTMLTextAreaElement>, selection: Rectangle, onSelectionChange?: ((selection: Rectangle) => void) | undefined, onChange?: ((changes: Array<Change>) => void) | undefined) => void;
|
|
4
|
+
export declare const useClipboardPaste: (textAreaRef: RefObject<HTMLTextAreaElement>, selection: Rectangle, onSelectionChange?: ((selection: Rectangle) => void) | undefined, onChange?: ((changes: Array<Change>) => void) | undefined, isReadOnly?: CellPropertyFunction<boolean> | undefined) => void;
|
package/dist/index.js
CHANGED
|
@@ -429,7 +429,7 @@ var findInDisplayData = function findInDisplayData(displayData, start, direction
|
|
|
429
429
|
return maxXY(cell, [0, 0]);
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
-
var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, onEdit, onCommit, onKnobAreaChange, onDragOffsetChange, onDropTargetChange, onSelectionChange, onInvalidateColumn, onInvalidateRow, onChange, onColumnOrderChange, onRowOrderChange, onCellWidthChange, onCellHeightChange, onRightClick, dontCommitEditOnSelectionChange) {
|
|
432
|
+
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) {
|
|
433
433
|
var _useState = React.useState(null),
|
|
434
434
|
hitTarget = _useState[0],
|
|
435
435
|
setHitTarget = _useState[1];
|
|
@@ -785,7 +785,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
785
785
|
getIndentY = _ref$current2$cellLay.getIndentY;
|
|
786
786
|
|
|
787
787
|
if (knobArea && draggingKnob) {
|
|
788
|
-
var changes = parseKnobOperation(knobArea, selection, sourceData, editData);
|
|
788
|
+
var changes = parseKnobOperation(knobArea, selection, sourceData, editData, cellReadOnly);
|
|
789
789
|
onChange === null || onChange === void 0 ? void 0 : onChange(changes);
|
|
790
790
|
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(knobArea, true, true);
|
|
791
791
|
onKnobAreaChange === null || onKnobAreaChange === void 0 ? void 0 : onKnobAreaChange(null);
|
|
@@ -1182,7 +1182,7 @@ var useMouse = function useMouse(hitmapRef, selection, knobArea, editMode, editD
|
|
|
1182
1182
|
};
|
|
1183
1183
|
};
|
|
1184
1184
|
|
|
1185
|
-
var parseKnobOperation = function parseKnobOperation(knobArea, selection, sourceData, editData) {
|
|
1185
|
+
var parseKnobOperation = function parseKnobOperation(knobArea, selection, sourceData, editData, cellReadOnly) {
|
|
1186
1186
|
var _normalizeSelection6 = normalizeSelection(knobArea),
|
|
1187
1187
|
_normalizeSelection6$ = _normalizeSelection6[0],
|
|
1188
1188
|
kx1 = _normalizeSelection6$[0],
|
|
@@ -1225,15 +1225,18 @@ var parseKnobOperation = function parseKnobOperation(knobArea, selection, source
|
|
|
1225
1225
|
for (var y = fy1; y <= fy2; y++) {
|
|
1226
1226
|
for (var x = fx1; x <= fx2; x++) {
|
|
1227
1227
|
var value = sourceData(x, srcY);
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
value: value,
|
|
1232
|
-
source: {
|
|
1228
|
+
|
|
1229
|
+
if (!cellReadOnly(x, y)) {
|
|
1230
|
+
changes.push({
|
|
1233
1231
|
x: x,
|
|
1234
|
-
y:
|
|
1235
|
-
|
|
1236
|
-
|
|
1232
|
+
y: y,
|
|
1233
|
+
value: value,
|
|
1234
|
+
source: {
|
|
1235
|
+
x: x,
|
|
1236
|
+
y: srcY
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1237
1240
|
}
|
|
1238
1241
|
|
|
1239
1242
|
srcY = srcY + 1;
|
|
@@ -1263,15 +1266,17 @@ var parseKnobOperation = function parseKnobOperation(knobArea, selection, source
|
|
|
1263
1266
|
for (var _y2 = fy1; _y2 <= fy2; _y2++) {
|
|
1264
1267
|
var _value = sourceData(srcX, _y2);
|
|
1265
1268
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1269
|
+
if (!cellReadOnly(_x2, _y2)) {
|
|
1270
|
+
changes.push({
|
|
1271
|
+
x: _x2,
|
|
1272
|
+
y: _y2,
|
|
1273
|
+
value: _value,
|
|
1274
|
+
source: {
|
|
1275
|
+
x: srcX,
|
|
1276
|
+
y: _y2
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1275
1280
|
}
|
|
1276
1281
|
|
|
1277
1282
|
srcX = srcX + 1;
|
|
@@ -1417,7 +1422,7 @@ var useClipboardCopy = function useClipboardCopy(textAreaRef, selection, editMod
|
|
|
1417
1422
|
}
|
|
1418
1423
|
});
|
|
1419
1424
|
};
|
|
1420
|
-
var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSelectionChange, onChange) {
|
|
1425
|
+
var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSelectionChange, onChange, isReadOnly) {
|
|
1421
1426
|
React.useEffect(function () {
|
|
1422
1427
|
var onPaste = function onPaste(e) {
|
|
1423
1428
|
var textArea = textAreaRef.current;
|
|
@@ -1430,10 +1435,10 @@ var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSel
|
|
|
1430
1435
|
|
|
1431
1436
|
if (types.includes('text/html')) {
|
|
1432
1437
|
var pastedHtml = clipboardData.getData('text/html');
|
|
1433
|
-
parsed = parsePastedHtml(selection, pastedHtml);
|
|
1438
|
+
parsed = parsePastedHtml(selection, pastedHtml, isReadOnly);
|
|
1434
1439
|
} else if (types.includes('text/plain')) {
|
|
1435
1440
|
var text = clipboardData.getData('text/plain');
|
|
1436
|
-
parsed = parsePastedText(selection, text);
|
|
1441
|
+
parsed = parsePastedText(selection, text, isReadOnly);
|
|
1437
1442
|
}
|
|
1438
1443
|
|
|
1439
1444
|
if (!parsed) return;
|
|
@@ -1519,7 +1524,7 @@ var findTable = function findTable(element) {
|
|
|
1519
1524
|
}
|
|
1520
1525
|
};
|
|
1521
1526
|
|
|
1522
|
-
var parsePastedHtml = function parsePastedHtml(selection, html) {
|
|
1527
|
+
var parsePastedHtml = function parsePastedHtml(selection, html, isReadOnly) {
|
|
1523
1528
|
var div = document.createElement('div');
|
|
1524
1529
|
div.innerHTML = html.trim();
|
|
1525
1530
|
|
|
@@ -1570,7 +1575,7 @@ var parsePastedHtml = function parsePastedHtml(selection, html) {
|
|
|
1570
1575
|
|
|
1571
1576
|
str = str.replaceAll('\n', '');
|
|
1572
1577
|
str = str.replaceAll(/\s\s+/g, ' ');
|
|
1573
|
-
changes.push({
|
|
1578
|
+
if (!(isReadOnly !== null && isReadOnly !== void 0 && isReadOnly(x, y))) changes.push({
|
|
1574
1579
|
x: x,
|
|
1575
1580
|
y: y,
|
|
1576
1581
|
value: str
|
|
@@ -1594,7 +1599,7 @@ var parsePastedHtml = function parsePastedHtml(selection, html) {
|
|
|
1594
1599
|
};
|
|
1595
1600
|
};
|
|
1596
1601
|
|
|
1597
|
-
var parsePastedText = function parsePastedText(selection, text) {
|
|
1602
|
+
var parsePastedText = function parsePastedText(selection, text, isReadOnly) {
|
|
1598
1603
|
var _normalizeSelection3 = normalizeSelection(selection),
|
|
1599
1604
|
_normalizeSelection3$ = _normalizeSelection3[0],
|
|
1600
1605
|
minX = _normalizeSelection3$[0],
|
|
@@ -1612,9 +1617,11 @@ var parsePastedText = function parsePastedText(selection, text) {
|
|
|
1612
1617
|
right = Math.max(right, left + cols.length - 1);
|
|
1613
1618
|
|
|
1614
1619
|
for (var x = 0; x < cols.length; x++) {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1620
|
+
var X = left + x;
|
|
1621
|
+
var Y = top + y;
|
|
1622
|
+
if (!(isReadOnly !== null && isReadOnly !== void 0 && isReadOnly(X, Y))) changes.push({
|
|
1623
|
+
x: X,
|
|
1624
|
+
y: Y,
|
|
1618
1625
|
value: cols[x]
|
|
1619
1626
|
});
|
|
1620
1627
|
}
|
|
@@ -2810,10 +2817,10 @@ var Sheet = React.forwardRef(function (props, ref) {
|
|
|
2810
2817
|
var hitmapRef = React.useRef(NO_CLICKABLES);
|
|
2811
2818
|
var textAreaRef = React.useRef(null);
|
|
2812
2819
|
useClipboardCopy(textAreaRef, selection, editMode, editData);
|
|
2813
|
-
useClipboardPaste(textAreaRef, selection, changeSelection, props.onChange);
|
|
2820
|
+
useClipboardPaste(textAreaRef, selection, changeSelection, props.onChange, cellReadOnly);
|
|
2814
2821
|
var onScroll = useScroll(dataOffset, maxScroll, cellLayout, setDataOffset, setMaxScroll);
|
|
2815
2822
|
|
|
2816
|
-
var _useMouse = useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, 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),
|
|
2823
|
+
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),
|
|
2817
2824
|
mouseHandlers = _useMouse.mouseHandlers,
|
|
2818
2825
|
knobPosition = _useMouse.knobPosition;
|
|
2819
2826
|
|
|
@@ -2894,11 +2901,13 @@ var Sheet = React.forwardRef(function (props, ref) {
|
|
|
2894
2901
|
|
|
2895
2902
|
for (var y = y1; y <= y2; y++) {
|
|
2896
2903
|
for (var x = x1; x <= x2; x++) {
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2904
|
+
if (!cellReadOnly(x, y)) {
|
|
2905
|
+
changes.push({
|
|
2906
|
+
x: x,
|
|
2907
|
+
y: y,
|
|
2908
|
+
value: null
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2902
2911
|
}
|
|
2903
2912
|
}
|
|
2904
2913
|
|