@leankylin-sheet/react 3.1.11 → 3.1.13

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
@@ -3922,7 +3922,8 @@ var Sheet = function Sheet(_ref) {
3922
3922
  }, [context, refs.canvas, refs.globalCache.freezen, setContext, sheet.id]);
3923
3923
  function isMost(direction) {
3924
3924
  var _containerRef$current;
3925
- var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(".luckysheet-scrollbar-y");
3925
+ var targetClassName = ["top", "bottom"].includes(direction) ? ".luckysheet-scrollbar-y" : ".luckysheet-scrollbar-x";
3926
+ var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(targetClassName);
3926
3927
  var scrollTop = target.scrollTop,
3927
3928
  clientHeight = target.clientHeight,
3928
3929
  clientWidth = target.clientWidth,
@@ -3947,11 +3948,25 @@ var Sheet = function Sheet(_ref) {
3947
3948
  setContext(function (draftCtx) {
3948
3949
  handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
3949
3950
  });
3951
+ if (e.deltaY === 0 && e.deltaX === 0) {
3952
+ return;
3953
+ }
3954
+ var mainDirection = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? "vertical" : "horizontal";
3950
3955
  var upToBottom = e.deltaY > 0;
3951
- if (upToBottom && !isMost("bottom")) {
3952
- e.preventDefault();
3953
- } else if (!upToBottom && !isMost("top")) {
3954
- e.preventDefault();
3956
+ var leftToRight = e.deltaX > 0;
3957
+ if (mainDirection === "vertical") {
3958
+ if (upToBottom && !isMost("bottom")) {
3959
+ e.preventDefault();
3960
+ } else if (!upToBottom && !isMost("top")) {
3961
+ e.preventDefault();
3962
+ }
3963
+ }
3964
+ if (mainDirection === "horizontal") {
3965
+ if (leftToRight && !isMost("right")) {
3966
+ e.preventDefault();
3967
+ } else if (!leftToRight && !isMost("left")) {
3968
+ e.preventDefault();
3969
+ }
3955
3970
  }
3956
3971
  }, [refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
3957
3972
  useEffect(function () {
@@ -7375,8 +7390,11 @@ var ContextMenu = function ContextMenu() {
7375
7390
  generalDialog = _locale.generalDialog,
7376
7391
  info = _locale.info;
7377
7392
  var getMenuElement = useCallback(function (name, i) {
7378
- var _context$luckysheet_s;
7393
+ var _context$luckysheet_s, _context$hooks, _context$hooks$showMe;
7379
7394
  var selection = (_context$luckysheet_s = context.luckysheet_select_save) === null || _context$luckysheet_s === void 0 ? void 0 : _context$luckysheet_s[0];
7395
+ if (((_context$hooks = context.hooks) === null || _context$hooks === void 0 ? void 0 : (_context$hooks$showMe = _context$hooks.showMenuBefore) === null || _context$hooks$showMe === void 0 ? void 0 : _context$hooks$showMe.call(_context$hooks, name, selection)) === false) {
7396
+ return null;
7397
+ }
7380
7398
  if (name === "|") {
7381
7399
  return /*#__PURE__*/React.createElement(Divider$1, {
7382
7400
  key: "divider-".concat(i)
@@ -7405,12 +7423,10 @@ var ContextMenu = function ContextMenu() {
7405
7423
  return /*#__PURE__*/React.createElement(Menu, {
7406
7424
  key: item.text,
7407
7425
  onClick: function onClick() {
7408
- if (row_index && col_index) {
7409
- setContext(function (draftCtx) {
7410
- item.onClick(draftCtx, refs.globalCache, row_index, col_index);
7411
- draftCtx.contextMenu = {};
7412
- });
7413
- }
7426
+ setContext(function (draftCtx) {
7427
+ item.onClick(draftCtx, refs.globalCache, row_index, col_index);
7428
+ draftCtx.contextMenu = {};
7429
+ });
7414
7430
  }
7415
7431
  }, item.text);
7416
7432
  });
package/dist/index.js CHANGED
@@ -3932,7 +3932,8 @@ var Sheet = function Sheet(_ref) {
3932
3932
  }, [context, refs.canvas, refs.globalCache.freezen, setContext, sheet.id]);
3933
3933
  function isMost(direction) {
3934
3934
  var _containerRef$current;
3935
- var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(".luckysheet-scrollbar-y");
3935
+ var targetClassName = ["top", "bottom"].includes(direction) ? ".luckysheet-scrollbar-y" : ".luckysheet-scrollbar-x";
3936
+ var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(targetClassName);
3936
3937
  var scrollTop = target.scrollTop,
3937
3938
  clientHeight = target.clientHeight,
3938
3939
  clientWidth = target.clientWidth,
@@ -3957,11 +3958,25 @@ var Sheet = function Sheet(_ref) {
3957
3958
  setContext(function (draftCtx) {
3958
3959
  core.handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
3959
3960
  });
3961
+ if (e.deltaY === 0 && e.deltaX === 0) {
3962
+ return;
3963
+ }
3964
+ var mainDirection = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? "vertical" : "horizontal";
3960
3965
  var upToBottom = e.deltaY > 0;
3961
- if (upToBottom && !isMost("bottom")) {
3962
- e.preventDefault();
3963
- } else if (!upToBottom && !isMost("top")) {
3964
- e.preventDefault();
3966
+ var leftToRight = e.deltaX > 0;
3967
+ if (mainDirection === "vertical") {
3968
+ if (upToBottom && !isMost("bottom")) {
3969
+ e.preventDefault();
3970
+ } else if (!upToBottom && !isMost("top")) {
3971
+ e.preventDefault();
3972
+ }
3973
+ }
3974
+ if (mainDirection === "horizontal") {
3975
+ if (leftToRight && !isMost("right")) {
3976
+ e.preventDefault();
3977
+ } else if (!leftToRight && !isMost("left")) {
3978
+ e.preventDefault();
3979
+ }
3965
3980
  }
3966
3981
  }, [refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
3967
3982
  React.useEffect(function () {
@@ -7385,8 +7400,11 @@ var ContextMenu = function ContextMenu() {
7385
7400
  generalDialog = _locale.generalDialog,
7386
7401
  info = _locale.info;
7387
7402
  var getMenuElement = React.useCallback(function (name, i) {
7388
- var _context$luckysheet_s;
7403
+ var _context$luckysheet_s, _context$hooks, _context$hooks$showMe;
7389
7404
  var selection = (_context$luckysheet_s = context.luckysheet_select_save) === null || _context$luckysheet_s === void 0 ? void 0 : _context$luckysheet_s[0];
7405
+ if (((_context$hooks = context.hooks) === null || _context$hooks === void 0 ? void 0 : (_context$hooks$showMe = _context$hooks.showMenuBefore) === null || _context$hooks$showMe === void 0 ? void 0 : _context$hooks$showMe.call(_context$hooks, name, selection)) === false) {
7406
+ return null;
7407
+ }
7390
7408
  if (name === "|") {
7391
7409
  return /*#__PURE__*/React__default['default'].createElement(Divider$1, {
7392
7410
  key: "divider-".concat(i)
@@ -7415,12 +7433,10 @@ var ContextMenu = function ContextMenu() {
7415
7433
  return /*#__PURE__*/React__default['default'].createElement(Menu, {
7416
7434
  key: item.text,
7417
7435
  onClick: function onClick() {
7418
- if (row_index && col_index) {
7419
- setContext(function (draftCtx) {
7420
- item.onClick(draftCtx, refs.globalCache, row_index, col_index);
7421
- draftCtx.contextMenu = {};
7422
- });
7423
- }
7436
+ setContext(function (draftCtx) {
7437
+ item.onClick(draftCtx, refs.globalCache, row_index, col_index);
7438
+ draftCtx.contextMenu = {};
7439
+ });
7424
7440
  }
7425
7441
  }, item.text);
7426
7442
  });
package/dist/index.umd.js CHANGED
@@ -107022,7 +107022,8 @@
107022
107022
  }, [context, refs.canvas, refs.globalCache.freezen, setContext, sheet.id]);
107023
107023
  function isMost(direction) {
107024
107024
  var _containerRef$current;
107025
- var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(".luckysheet-scrollbar-y");
107025
+ var targetClassName = ["top", "bottom"].includes(direction) ? ".luckysheet-scrollbar-y" : ".luckysheet-scrollbar-x";
107026
+ var target = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(targetClassName);
107026
107027
  var scrollTop = target.scrollTop,
107027
107028
  clientHeight = target.clientHeight,
107028
107029
  clientWidth = target.clientWidth,
@@ -107047,11 +107048,25 @@
107047
107048
  setContext(function (draftCtx) {
107048
107049
  handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
107049
107050
  });
107051
+ if (e.deltaY === 0 && e.deltaX === 0) {
107052
+ return;
107053
+ }
107054
+ var mainDirection = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? "vertical" : "horizontal";
107050
107055
  var upToBottom = e.deltaY > 0;
107051
- if (upToBottom && !isMost("bottom")) {
107052
- e.preventDefault();
107053
- } else if (!upToBottom && !isMost("top")) {
107054
- e.preventDefault();
107056
+ var leftToRight = e.deltaX > 0;
107057
+ if (mainDirection === "vertical") {
107058
+ if (upToBottom && !isMost("bottom")) {
107059
+ e.preventDefault();
107060
+ } else if (!upToBottom && !isMost("top")) {
107061
+ e.preventDefault();
107062
+ }
107063
+ }
107064
+ if (mainDirection === "horizontal") {
107065
+ if (leftToRight && !isMost("right")) {
107066
+ e.preventDefault();
107067
+ } else if (!leftToRight && !isMost("left")) {
107068
+ e.preventDefault();
107069
+ }
107055
107070
  }
107056
107071
  }, [refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
107057
107072
  React.useEffect(function () {
@@ -110475,8 +110490,11 @@
110475
110490
  generalDialog = _locale.generalDialog,
110476
110491
  info = _locale.info;
110477
110492
  var getMenuElement = React.useCallback(function (name, i) {
110478
- var _context$luckysheet_s;
110493
+ var _context$luckysheet_s, _context$hooks, _context$hooks$showMe;
110479
110494
  var selection = (_context$luckysheet_s = context.luckysheet_select_save) === null || _context$luckysheet_s === void 0 ? void 0 : _context$luckysheet_s[0];
110495
+ if (((_context$hooks = context.hooks) === null || _context$hooks === void 0 ? void 0 : (_context$hooks$showMe = _context$hooks.showMenuBefore) === null || _context$hooks$showMe === void 0 ? void 0 : _context$hooks$showMe.call(_context$hooks, name, selection)) === false) {
110496
+ return null;
110497
+ }
110480
110498
  if (name === "|") {
110481
110499
  return /*#__PURE__*/React__default['default'].createElement(Divider$1, {
110482
110500
  key: "divider-".concat(i)
@@ -110505,12 +110523,10 @@
110505
110523
  return /*#__PURE__*/React__default['default'].createElement(Menu, {
110506
110524
  key: item.text,
110507
110525
  onClick: function onClick() {
110508
- if (row_index && col_index) {
110509
- setContext(function (draftCtx) {
110510
- item.onClick(draftCtx, refs.globalCache, row_index, col_index);
110511
- draftCtx.contextMenu = {};
110512
- });
110513
- }
110526
+ setContext(function (draftCtx) {
110527
+ item.onClick(draftCtx, refs.globalCache, row_index, col_index);
110528
+ draftCtx.contextMenu = {};
110529
+ });
110514
110530
  }
110515
110531
  }, item.text);
110516
110532
  });