@leankylin-sheet/react 3.1.7 → 3.1.9
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.esm.js +75 -5
- package/dist/index.js +74 -4
- package/dist/index.umd.js +280 -47
- package/dist/index.umd.min.js +2 -2
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
|
|
1
|
+
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
|
|
2
2
|
import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
3
|
import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
|
|
4
4
|
import _ from 'lodash';
|
|
@@ -3280,10 +3280,30 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3280
3280
|
handleCellAreaMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3281
3281
|
});
|
|
3282
3282
|
});
|
|
3283
|
-
var
|
|
3283
|
+
var debounceDragOver = useMemoizedFn(function (e) {
|
|
3284
|
+
var nativeEvent = e.nativeEvent;
|
|
3285
|
+
setContext(function (draftCtx) {
|
|
3286
|
+
handleCellAreaDragOver(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3287
|
+
});
|
|
3288
|
+
});
|
|
3289
|
+
var debounceCellDrop = useMemoizedFn(function (e) {
|
|
3290
|
+
var nativeEvent = e.nativeEvent;
|
|
3291
|
+
setContext(function (draftCtx) {
|
|
3292
|
+
handleCellDrop(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3293
|
+
});
|
|
3294
|
+
});
|
|
3295
|
+
var _useThrottleFn = useThrottleFn(debounceDragOver, {
|
|
3284
3296
|
wait: 100
|
|
3285
3297
|
}),
|
|
3286
|
-
|
|
3298
|
+
cellAreaDragOver = _useThrottleFn.run;
|
|
3299
|
+
var _useThrottleFn2 = useThrottleFn(debounceCellDrop, {
|
|
3300
|
+
wait: 100
|
|
3301
|
+
}),
|
|
3302
|
+
cellDrop = _useThrottleFn2.run;
|
|
3303
|
+
var _useThrottleFn3 = useThrottleFn(debounceMouseMove, {
|
|
3304
|
+
wait: 100
|
|
3305
|
+
}),
|
|
3306
|
+
cellAreaMouseMove = _useThrottleFn3.run;
|
|
3287
3307
|
var cellAreaMouseLeave = useCallback(function () {
|
|
3288
3308
|
setTimeout(function () {
|
|
3289
3309
|
var _context$hooks$afterC, _context$hooks;
|
|
@@ -3442,6 +3462,14 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3442
3462
|
onMouseDown: cellAreaMouseDown,
|
|
3443
3463
|
onMouseMove: cellAreaMouseMove,
|
|
3444
3464
|
onMouseLeave: cellAreaMouseLeave,
|
|
3465
|
+
onDragOver: function onDragOver(e) {
|
|
3466
|
+
e.preventDefault();
|
|
3467
|
+
cellAreaDragOver(e);
|
|
3468
|
+
},
|
|
3469
|
+
onDrop: function onDrop(e) {
|
|
3470
|
+
e.preventDefault();
|
|
3471
|
+
cellDrop(e);
|
|
3472
|
+
},
|
|
3445
3473
|
onDoubleClick: cellAreaDoubleClick,
|
|
3446
3474
|
onContextMenu: cellAreaContextMenu,
|
|
3447
3475
|
style: {
|
|
@@ -3464,7 +3492,16 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3464
3492
|
className: "leankylin-selection-copy-left leankylin-copy"
|
|
3465
3493
|
}), /*#__PURE__*/React.createElement("div", {
|
|
3466
3494
|
className: "leankylin-selection-copy-hc"
|
|
3467
|
-
}))), context.
|
|
3495
|
+
}))), context.dragRangeSelect && ( /*#__PURE__*/React.createElement("div", {
|
|
3496
|
+
style: {
|
|
3497
|
+
position: "absolute",
|
|
3498
|
+
background: "rgba(0, 255, 0, 0.2)",
|
|
3499
|
+
left: context.dragRangeSelect.left,
|
|
3500
|
+
top: context.dragRangeSelect.top,
|
|
3501
|
+
width: context.dragRangeSelect.width,
|
|
3502
|
+
height: context.dragRangeSelect.height
|
|
3503
|
+
}
|
|
3504
|
+
})), context.formulaRangeHighlight.map(function (v) {
|
|
3468
3505
|
var rangeIndex = v.rangeIndex,
|
|
3469
3506
|
backgroundColor = v.backgroundColor;
|
|
3470
3507
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -7317,6 +7354,39 @@ var ContextMenu = function ContextMenu() {
|
|
|
7317
7354
|
key: "divider-".concat(i)
|
|
7318
7355
|
});
|
|
7319
7356
|
}
|
|
7357
|
+
if (name === "insert-comment") {
|
|
7358
|
+
var _flowdata$row_index, _flowdata$row_index$c;
|
|
7359
|
+
var flowdata = getFlowdata(context);
|
|
7360
|
+
var row_index = selection === null || selection === void 0 ? void 0 : selection.row[0];
|
|
7361
|
+
var col_index = selection === null || selection === void 0 ? void 0 : selection.column[0];
|
|
7362
|
+
var hasPs = (flowdata === null || flowdata === void 0 ? void 0 : (_flowdata$row_index = flowdata[row_index]) === null || _flowdata$row_index === void 0 ? void 0 : (_flowdata$row_index$c = _flowdata$row_index[col_index]) === null || _flowdata$row_index$c === void 0 ? void 0 : _flowdata$row_index$c.ps) != null;
|
|
7363
|
+
var itemData = hasPs ? [{
|
|
7364
|
+
text: "编辑批注",
|
|
7365
|
+
onClick: editComment
|
|
7366
|
+
}, {
|
|
7367
|
+
text: "删除批注",
|
|
7368
|
+
onClick: deleteComment
|
|
7369
|
+
}, {
|
|
7370
|
+
text: "显示/隐藏批注",
|
|
7371
|
+
onClick: showHideComment
|
|
7372
|
+
}] : [{
|
|
7373
|
+
text: "新建批注",
|
|
7374
|
+
onClick: newComment
|
|
7375
|
+
}];
|
|
7376
|
+
return itemData.map(function (item) {
|
|
7377
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
7378
|
+
key: item.text,
|
|
7379
|
+
onClick: function onClick() {
|
|
7380
|
+
if (row_index && col_index) {
|
|
7381
|
+
setContext(function (draftCtx) {
|
|
7382
|
+
item.onClick(draftCtx, refs.globalCache, row_index, col_index);
|
|
7383
|
+
draftCtx.contextMenu = {};
|
|
7384
|
+
});
|
|
7385
|
+
}
|
|
7386
|
+
}
|
|
7387
|
+
}, item.text);
|
|
7388
|
+
});
|
|
7389
|
+
}
|
|
7320
7390
|
if (name === "copy") {
|
|
7321
7391
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
7322
7392
|
key: name,
|
|
@@ -7575,7 +7645,7 @@ var ContextMenu = function ContextMenu() {
|
|
|
7575
7645
|
return colhidden[key] === 0;
|
|
7576
7646
|
});
|
|
7577
7647
|
var hiddenInCol = keys === null || keys === void 0 ? void 0 : keys.some(function (c) {
|
|
7578
|
-
return Number(c)
|
|
7648
|
+
return Number(c) >= start && Number(c) <= end;
|
|
7579
7649
|
});
|
|
7580
7650
|
if (hiddenInCol) {
|
|
7581
7651
|
mArr.push("showHide");
|
package/dist/index.js
CHANGED
|
@@ -3290,10 +3290,30 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3290
3290
|
core.handleCellAreaMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3291
3291
|
});
|
|
3292
3292
|
});
|
|
3293
|
-
var
|
|
3293
|
+
var debounceDragOver = ahooks.useMemoizedFn(function (e) {
|
|
3294
|
+
var nativeEvent = e.nativeEvent;
|
|
3295
|
+
setContext(function (draftCtx) {
|
|
3296
|
+
core.handleCellAreaDragOver(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3297
|
+
});
|
|
3298
|
+
});
|
|
3299
|
+
var debounceCellDrop = ahooks.useMemoizedFn(function (e) {
|
|
3300
|
+
var nativeEvent = e.nativeEvent;
|
|
3301
|
+
setContext(function (draftCtx) {
|
|
3302
|
+
core.handleCellDrop(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
3303
|
+
});
|
|
3304
|
+
});
|
|
3305
|
+
var _useThrottleFn = ahooks.useThrottleFn(debounceDragOver, {
|
|
3294
3306
|
wait: 100
|
|
3295
3307
|
}),
|
|
3296
|
-
|
|
3308
|
+
cellAreaDragOver = _useThrottleFn.run;
|
|
3309
|
+
var _useThrottleFn2 = ahooks.useThrottleFn(debounceCellDrop, {
|
|
3310
|
+
wait: 100
|
|
3311
|
+
}),
|
|
3312
|
+
cellDrop = _useThrottleFn2.run;
|
|
3313
|
+
var _useThrottleFn3 = ahooks.useThrottleFn(debounceMouseMove, {
|
|
3314
|
+
wait: 100
|
|
3315
|
+
}),
|
|
3316
|
+
cellAreaMouseMove = _useThrottleFn3.run;
|
|
3297
3317
|
var cellAreaMouseLeave = React.useCallback(function () {
|
|
3298
3318
|
setTimeout(function () {
|
|
3299
3319
|
var _context$hooks$afterC, _context$hooks;
|
|
@@ -3452,6 +3472,14 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3452
3472
|
onMouseDown: cellAreaMouseDown,
|
|
3453
3473
|
onMouseMove: cellAreaMouseMove,
|
|
3454
3474
|
onMouseLeave: cellAreaMouseLeave,
|
|
3475
|
+
onDragOver: function onDragOver(e) {
|
|
3476
|
+
e.preventDefault();
|
|
3477
|
+
cellAreaDragOver(e);
|
|
3478
|
+
},
|
|
3479
|
+
onDrop: function onDrop(e) {
|
|
3480
|
+
e.preventDefault();
|
|
3481
|
+
cellDrop(e);
|
|
3482
|
+
},
|
|
3455
3483
|
onDoubleClick: cellAreaDoubleClick,
|
|
3456
3484
|
onContextMenu: cellAreaContextMenu,
|
|
3457
3485
|
style: {
|
|
@@ -3474,7 +3502,16 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
3474
3502
|
className: "leankylin-selection-copy-left leankylin-copy"
|
|
3475
3503
|
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3476
3504
|
className: "leankylin-selection-copy-hc"
|
|
3477
|
-
}))), context.
|
|
3505
|
+
}))), context.dragRangeSelect && ( /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3506
|
+
style: {
|
|
3507
|
+
position: "absolute",
|
|
3508
|
+
background: "rgba(0, 255, 0, 0.2)",
|
|
3509
|
+
left: context.dragRangeSelect.left,
|
|
3510
|
+
top: context.dragRangeSelect.top,
|
|
3511
|
+
width: context.dragRangeSelect.width,
|
|
3512
|
+
height: context.dragRangeSelect.height
|
|
3513
|
+
}
|
|
3514
|
+
})), context.formulaRangeHighlight.map(function (v) {
|
|
3478
3515
|
var rangeIndex = v.rangeIndex,
|
|
3479
3516
|
backgroundColor = v.backgroundColor;
|
|
3480
3517
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -7327,6 +7364,39 @@ var ContextMenu = function ContextMenu() {
|
|
|
7327
7364
|
key: "divider-".concat(i)
|
|
7328
7365
|
});
|
|
7329
7366
|
}
|
|
7367
|
+
if (name === "insert-comment") {
|
|
7368
|
+
var _flowdata$row_index, _flowdata$row_index$c;
|
|
7369
|
+
var flowdata = core.getFlowdata(context);
|
|
7370
|
+
var row_index = selection === null || selection === void 0 ? void 0 : selection.row[0];
|
|
7371
|
+
var col_index = selection === null || selection === void 0 ? void 0 : selection.column[0];
|
|
7372
|
+
var hasPs = (flowdata === null || flowdata === void 0 ? void 0 : (_flowdata$row_index = flowdata[row_index]) === null || _flowdata$row_index === void 0 ? void 0 : (_flowdata$row_index$c = _flowdata$row_index[col_index]) === null || _flowdata$row_index$c === void 0 ? void 0 : _flowdata$row_index$c.ps) != null;
|
|
7373
|
+
var itemData = hasPs ? [{
|
|
7374
|
+
text: "编辑批注",
|
|
7375
|
+
onClick: core.editComment
|
|
7376
|
+
}, {
|
|
7377
|
+
text: "删除批注",
|
|
7378
|
+
onClick: core.deleteComment
|
|
7379
|
+
}, {
|
|
7380
|
+
text: "显示/隐藏批注",
|
|
7381
|
+
onClick: core.showHideComment
|
|
7382
|
+
}] : [{
|
|
7383
|
+
text: "新建批注",
|
|
7384
|
+
onClick: core.newComment
|
|
7385
|
+
}];
|
|
7386
|
+
return itemData.map(function (item) {
|
|
7387
|
+
return /*#__PURE__*/React__default['default'].createElement(Menu, {
|
|
7388
|
+
key: item.text,
|
|
7389
|
+
onClick: function onClick() {
|
|
7390
|
+
if (row_index && col_index) {
|
|
7391
|
+
setContext(function (draftCtx) {
|
|
7392
|
+
item.onClick(draftCtx, refs.globalCache, row_index, col_index);
|
|
7393
|
+
draftCtx.contextMenu = {};
|
|
7394
|
+
});
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
}, item.text);
|
|
7398
|
+
});
|
|
7399
|
+
}
|
|
7330
7400
|
if (name === "copy") {
|
|
7331
7401
|
return /*#__PURE__*/React__default['default'].createElement(Menu, {
|
|
7332
7402
|
key: name,
|
|
@@ -7585,7 +7655,7 @@ var ContextMenu = function ContextMenu() {
|
|
|
7585
7655
|
return colhidden[key] === 0;
|
|
7586
7656
|
});
|
|
7587
7657
|
var hiddenInCol = keys === null || keys === void 0 ? void 0 : keys.some(function (c) {
|
|
7588
|
-
return Number(c)
|
|
7658
|
+
return Number(c) >= start && Number(c) <= end;
|
|
7589
7659
|
});
|
|
7590
7660
|
if (hiddenInCol) {
|
|
7591
7661
|
mArr.push("showHide");
|