@leankylin-sheet/react 3.1.6 → 3.1.8

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 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 _useThrottleFn = useThrottleFn(debounceMouseMove, {
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, {
3296
+ wait: 100
3297
+ }),
3298
+ cellAreaDragOver = _useThrottleFn.run;
3299
+ var _useThrottleFn2 = useThrottleFn(debounceCellDrop, {
3284
3300
  wait: 100
3285
3301
  }),
3286
- cellAreaMouseMove = _useThrottleFn.run;
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.formulaRangeHighlight.map(function (v) {
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", {
@@ -3858,7 +3895,8 @@ var Sheet = function Sheet(_ref) {
3858
3895
  tableCanvas.drawMain({
3859
3896
  scrollWidth: context.scrollLeft + _verticalPx - _verticalScrollWidth,
3860
3897
  scrollHeight: context.scrollTop,
3861
- offsetLeft: _verticalPx - _verticalScrollWidth + context.rowHeaderWidth
3898
+ offsetLeft: _verticalPx - _verticalScrollWidth + context.rowHeaderWidth,
3899
+ clear: true
3862
3900
  });
3863
3901
  tableCanvas.drawMain({
3864
3902
  scrollWidth: _verticalScrollWidth,
@@ -7316,6 +7354,39 @@ var ContextMenu = function ContextMenu() {
7316
7354
  key: "divider-".concat(i)
7317
7355
  });
7318
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
+ }
7319
7390
  if (name === "copy") {
7320
7391
  return /*#__PURE__*/React.createElement(Menu, {
7321
7392
  key: name,
@@ -9667,6 +9738,12 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
9667
9738
  return api.setColHidden(draftCtx, colHidden, options);
9668
9739
  });
9669
9740
  },
9741
+ setRowHidden: function setRowHidden(colHidden) {
9742
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9743
+ return setContext(function (draftCtx) {
9744
+ return api.setRowHidden(draftCtx, colHidden, options);
9745
+ });
9746
+ },
9670
9747
  setColumnWidth: function setColumnWidth(columnInfo) {
9671
9748
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9672
9749
  var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
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 _useThrottleFn = ahooks.useThrottleFn(debounceMouseMove, {
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, {
3306
+ wait: 100
3307
+ }),
3308
+ cellAreaDragOver = _useThrottleFn.run;
3309
+ var _useThrottleFn2 = ahooks.useThrottleFn(debounceCellDrop, {
3294
3310
  wait: 100
3295
3311
  }),
3296
- cellAreaMouseMove = _useThrottleFn.run;
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.formulaRangeHighlight.map(function (v) {
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", {
@@ -3868,7 +3905,8 @@ var Sheet = function Sheet(_ref) {
3868
3905
  tableCanvas.drawMain({
3869
3906
  scrollWidth: context.scrollLeft + _verticalPx - _verticalScrollWidth,
3870
3907
  scrollHeight: context.scrollTop,
3871
- offsetLeft: _verticalPx - _verticalScrollWidth + context.rowHeaderWidth
3908
+ offsetLeft: _verticalPx - _verticalScrollWidth + context.rowHeaderWidth,
3909
+ clear: true
3872
3910
  });
3873
3911
  tableCanvas.drawMain({
3874
3912
  scrollWidth: _verticalScrollWidth,
@@ -7326,6 +7364,39 @@ var ContextMenu = function ContextMenu() {
7326
7364
  key: "divider-".concat(i)
7327
7365
  });
7328
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
+ }
7329
7400
  if (name === "copy") {
7330
7401
  return /*#__PURE__*/React__default['default'].createElement(Menu, {
7331
7402
  key: name,
@@ -9677,6 +9748,12 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
9677
9748
  return core.api.setColHidden(draftCtx, colHidden, options);
9678
9749
  });
9679
9750
  },
9751
+ setRowHidden: function setRowHidden(colHidden) {
9752
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9753
+ return setContext(function (draftCtx) {
9754
+ return core.api.setRowHidden(draftCtx, colHidden, options);
9755
+ });
9756
+ },
9680
9757
  setColumnWidth: function setColumnWidth(columnInfo) {
9681
9758
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9682
9759
  var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;