@leankylin-sheet/react 5.2.64 → 5.2.66
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 +88 -27
- package/dist/index.js +88 -27
- package/dist/index.umd.js +88 -27
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -7877,6 +7877,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7877
7877
|
var _useContext = useContext(WorkbookContext),
|
|
7878
7878
|
context = _useContext.context,
|
|
7879
7879
|
setContext = _useContext.setContext,
|
|
7880
|
+
settings = _useContext.settings,
|
|
7880
7881
|
refs = _useContext.refs;
|
|
7881
7882
|
var _useState = useState(false),
|
|
7882
7883
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -7959,6 +7960,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7959
7960
|
var droppingId = sheet.id;
|
|
7960
7961
|
var draggingSheet;
|
|
7961
7962
|
var droppingSheet;
|
|
7963
|
+
var moved = false;
|
|
7962
7964
|
_.sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
7963
7965
|
f.order = i;
|
|
7964
7966
|
if (f.id === draggingId) {
|
|
@@ -7972,13 +7974,19 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7972
7974
|
_.sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
7973
7975
|
f.order = i;
|
|
7974
7976
|
});
|
|
7977
|
+
moved = true;
|
|
7975
7978
|
} else if (draggingSheet && isDropPlaceholder) {
|
|
7976
7979
|
draggingSheet.order = draftCtx.luckysheetfile.length;
|
|
7980
|
+
moved = true;
|
|
7981
|
+
}
|
|
7982
|
+
if (moved) {
|
|
7983
|
+
var _settings$hooks, _settings$hooks$onMov;
|
|
7984
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, draggingId, isDropPlaceholder ? undefined : droppingId);
|
|
7977
7985
|
}
|
|
7978
7986
|
});
|
|
7979
7987
|
setDragOver(false);
|
|
7980
7988
|
e.stopPropagation();
|
|
7981
|
-
}, [context.allowEdit, isDropPlaceholder, setContext, sheet.id]);
|
|
7989
|
+
}, [context.allowEdit, isDropPlaceholder, setContext, settings.hooks, sheet.id]);
|
|
7982
7990
|
var onChangeSheet = useMemoizedFn(function () {
|
|
7983
7991
|
if (isDropPlaceholder) return;
|
|
7984
7992
|
setContext(function (draftCtx) {
|
|
@@ -8004,7 +8012,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
8004
8012
|
},
|
|
8005
8013
|
onDrop: onDrop,
|
|
8006
8014
|
onDragStart: onDragStart,
|
|
8007
|
-
draggable: context.allowEdit && !editing,
|
|
8015
|
+
draggable: context.allowEdit && !settings.disabledMoveSheet && !editing,
|
|
8008
8016
|
key: sheet.id,
|
|
8009
8017
|
ref: containerRef,
|
|
8010
8018
|
className: isDropPlaceholder ? "leankylin-sheettab-placeholder" : "luckysheet-sheets-item".concat(context.currentSheetId === sheet.id ? " luckysheet-sheets-item-active" : ""),
|
|
@@ -10545,6 +10553,7 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10545
10553
|
useOutsideClick(containerRef, close, [close]);
|
|
10546
10554
|
var moveSheet = useCallback(function (delta) {
|
|
10547
10555
|
if (context.allowEdit === false) return;
|
|
10556
|
+
if (settings.disabledMoveSheet) return;
|
|
10548
10557
|
if (!sheet) return;
|
|
10549
10558
|
setContext(function (ctx) {
|
|
10550
10559
|
var currentOrder = -1;
|
|
@@ -10555,8 +10564,16 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10555
10564
|
}
|
|
10556
10565
|
});
|
|
10557
10566
|
api.setSheetOrder(ctx, _defineProperty({}, sheet.id, currentOrder + delta));
|
|
10567
|
+
var sorted = _.sortBy(ctx.luckysheetfile, ["order"]);
|
|
10568
|
+
var newIndex = sorted.findIndex(function (_sheet) {
|
|
10569
|
+
return _sheet.id === sheet.id;
|
|
10570
|
+
});
|
|
10571
|
+
if (newIndex !== currentOrder) {
|
|
10572
|
+
var _settings$hooks, _settings$hooks$onMov, _sorted;
|
|
10573
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, sheet.id, (_sorted = sorted[newIndex + 1]) === null || _sorted === void 0 ? void 0 : _sorted.id);
|
|
10574
|
+
}
|
|
10558
10575
|
});
|
|
10559
|
-
}, [context.allowEdit, setContext, sheet]);
|
|
10576
|
+
}, [context.allowEdit, settings.disabledMoveSheet, settings.hooks, setContext, sheet]);
|
|
10560
10577
|
var hideSheet = useCallback(function () {
|
|
10561
10578
|
if (context.allowEdit === false) return;
|
|
10562
10579
|
if (!sheet) return;
|
|
@@ -10571,15 +10588,59 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10571
10588
|
}
|
|
10572
10589
|
});
|
|
10573
10590
|
}, [context.allowEdit, setContext, sheet, showAlert, sheetconfig]);
|
|
10574
|
-
var copySheet = useCallback(function () {
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10591
|
+
var copySheet = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
10592
|
+
var _settings$hooks2;
|
|
10593
|
+
var _ref2, onCopySheetCheck, isAllowed;
|
|
10594
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10595
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10596
|
+
case 0:
|
|
10597
|
+
if (!(context.allowEdit === false)) {
|
|
10598
|
+
_context.next = 2;
|
|
10599
|
+
break;
|
|
10600
|
+
}
|
|
10601
|
+
return _context.abrupt("return");
|
|
10602
|
+
case 2:
|
|
10603
|
+
if (sheet === null || sheet === void 0 ? void 0 : sheet.id) {
|
|
10604
|
+
_context.next = 4;
|
|
10605
|
+
break;
|
|
10606
|
+
}
|
|
10607
|
+
return _context.abrupt("return");
|
|
10608
|
+
case 4:
|
|
10609
|
+
_ref2 = (_settings$hooks2 = settings.hooks) !== null && _settings$hooks2 !== void 0 ? _settings$hooks2 : {}, onCopySheetCheck = _ref2.onCopySheetCheck;
|
|
10610
|
+
if (!onCopySheetCheck) {
|
|
10611
|
+
_context.next = 18;
|
|
10612
|
+
break;
|
|
10613
|
+
}
|
|
10614
|
+
_context.prev = 6;
|
|
10615
|
+
_context.next = 9;
|
|
10616
|
+
return onCopySheetCheck(sheet.id, sheet);
|
|
10617
|
+
case 9:
|
|
10618
|
+
isAllowed = _context.sent;
|
|
10619
|
+
_context.next = 16;
|
|
10620
|
+
break;
|
|
10621
|
+
case 12:
|
|
10622
|
+
_context.prev = 12;
|
|
10623
|
+
_context.t0 = _context["catch"](6);
|
|
10624
|
+
console.error(_context.t0);
|
|
10625
|
+
isAllowed = false;
|
|
10626
|
+
case 16:
|
|
10627
|
+
if (isAllowed) {
|
|
10628
|
+
_context.next = 18;
|
|
10629
|
+
break;
|
|
10630
|
+
}
|
|
10631
|
+
return _context.abrupt("return");
|
|
10632
|
+
case 18:
|
|
10633
|
+
setContext(function (ctx) {
|
|
10634
|
+
api.copySheet(ctx, sheet.id, settings.hooks);
|
|
10635
|
+
}, {
|
|
10636
|
+
addSheetOp: true
|
|
10637
|
+
});
|
|
10638
|
+
case 19:
|
|
10639
|
+
case "end":
|
|
10640
|
+
return _context.stop();
|
|
10641
|
+
}
|
|
10642
|
+
}, _callee, null, [[6, 12]]);
|
|
10643
|
+
})), [context.allowEdit, setContext, settings.hooks, sheet]);
|
|
10583
10644
|
var updateShowInputColor = useCallback(function (state) {
|
|
10584
10645
|
setIsShowInputColor(state);
|
|
10585
10646
|
}, []);
|
|
@@ -10620,34 +10681,34 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10620
10681
|
return _.isUndefined(singleSheet.hide) || singleSheet.hide !== 1;
|
|
10621
10682
|
});
|
|
10622
10683
|
if (context.luckysheetfile.length > 1 && shownSheets.length > 1) {
|
|
10623
|
-
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
10684
|
+
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
10624
10685
|
var onDeleteSheetCheck, isAllowed;
|
|
10625
|
-
return _regeneratorRuntime().wrap(function
|
|
10626
|
-
while (1) switch (
|
|
10686
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10687
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
10627
10688
|
case 0:
|
|
10628
10689
|
onDeleteSheetCheck = settings.onDeleteSheetCheck;
|
|
10629
10690
|
if (!onDeleteSheetCheck) {
|
|
10630
|
-
|
|
10691
|
+
_context2.next = 14;
|
|
10631
10692
|
break;
|
|
10632
10693
|
}
|
|
10633
|
-
|
|
10634
|
-
|
|
10694
|
+
_context2.prev = 2;
|
|
10695
|
+
_context2.next = 5;
|
|
10635
10696
|
return onDeleteSheetCheck(sheet.id, sheet);
|
|
10636
10697
|
case 5:
|
|
10637
|
-
isAllowed =
|
|
10638
|
-
|
|
10698
|
+
isAllowed = _context2.sent;
|
|
10699
|
+
_context2.next = 12;
|
|
10639
10700
|
break;
|
|
10640
10701
|
case 8:
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
console.error(
|
|
10702
|
+
_context2.prev = 8;
|
|
10703
|
+
_context2.t0 = _context2["catch"](2);
|
|
10704
|
+
console.error(_context2.t0);
|
|
10644
10705
|
isAllowed = false;
|
|
10645
10706
|
case 12:
|
|
10646
10707
|
if (isAllowed) {
|
|
10647
|
-
|
|
10708
|
+
_context2.next = 14;
|
|
10648
10709
|
break;
|
|
10649
10710
|
}
|
|
10650
|
-
return
|
|
10711
|
+
return _context2.abrupt("return");
|
|
10651
10712
|
case 14:
|
|
10652
10713
|
setContext(function (ctx) {
|
|
10653
10714
|
deleteSheet(ctx, sheet.id);
|
|
@@ -10659,9 +10720,9 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10659
10720
|
hideAlert();
|
|
10660
10721
|
case 16:
|
|
10661
10722
|
case "end":
|
|
10662
|
-
return
|
|
10723
|
+
return _context2.stop();
|
|
10663
10724
|
}
|
|
10664
|
-
},
|
|
10725
|
+
}, _callee2, null, [[2, 8]]);
|
|
10665
10726
|
})), undefined, {
|
|
10666
10727
|
confirmText: sheetconfig.delete,
|
|
10667
10728
|
danger: true
|
package/dist/index.js
CHANGED
|
@@ -7887,6 +7887,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7887
7887
|
var _useContext = React.useContext(WorkbookContext),
|
|
7888
7888
|
context = _useContext.context,
|
|
7889
7889
|
setContext = _useContext.setContext,
|
|
7890
|
+
settings = _useContext.settings,
|
|
7890
7891
|
refs = _useContext.refs;
|
|
7891
7892
|
var _useState = React.useState(false),
|
|
7892
7893
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -7969,6 +7970,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7969
7970
|
var droppingId = sheet.id;
|
|
7970
7971
|
var draggingSheet;
|
|
7971
7972
|
var droppingSheet;
|
|
7973
|
+
var moved = false;
|
|
7972
7974
|
___default['default'].sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
7973
7975
|
f.order = i;
|
|
7974
7976
|
if (f.id === draggingId) {
|
|
@@ -7982,13 +7984,19 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
7982
7984
|
___default['default'].sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
7983
7985
|
f.order = i;
|
|
7984
7986
|
});
|
|
7987
|
+
moved = true;
|
|
7985
7988
|
} else if (draggingSheet && isDropPlaceholder) {
|
|
7986
7989
|
draggingSheet.order = draftCtx.luckysheetfile.length;
|
|
7990
|
+
moved = true;
|
|
7991
|
+
}
|
|
7992
|
+
if (moved) {
|
|
7993
|
+
var _settings$hooks, _settings$hooks$onMov;
|
|
7994
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, draggingId, isDropPlaceholder ? undefined : droppingId);
|
|
7987
7995
|
}
|
|
7988
7996
|
});
|
|
7989
7997
|
setDragOver(false);
|
|
7990
7998
|
e.stopPropagation();
|
|
7991
|
-
}, [context.allowEdit, isDropPlaceholder, setContext, sheet.id]);
|
|
7999
|
+
}, [context.allowEdit, isDropPlaceholder, setContext, settings.hooks, sheet.id]);
|
|
7992
8000
|
var onChangeSheet = ahooks.useMemoizedFn(function () {
|
|
7993
8001
|
if (isDropPlaceholder) return;
|
|
7994
8002
|
setContext(function (draftCtx) {
|
|
@@ -8014,7 +8022,7 @@ var SheetItem = function SheetItem(_ref) {
|
|
|
8014
8022
|
},
|
|
8015
8023
|
onDrop: onDrop,
|
|
8016
8024
|
onDragStart: onDragStart,
|
|
8017
|
-
draggable: context.allowEdit && !editing,
|
|
8025
|
+
draggable: context.allowEdit && !settings.disabledMoveSheet && !editing,
|
|
8018
8026
|
key: sheet.id,
|
|
8019
8027
|
ref: containerRef,
|
|
8020
8028
|
className: isDropPlaceholder ? "leankylin-sheettab-placeholder" : "luckysheet-sheets-item".concat(context.currentSheetId === sheet.id ? " luckysheet-sheets-item-active" : ""),
|
|
@@ -10555,6 +10563,7 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10555
10563
|
useOutsideClick(containerRef, close, [close]);
|
|
10556
10564
|
var moveSheet = React.useCallback(function (delta) {
|
|
10557
10565
|
if (context.allowEdit === false) return;
|
|
10566
|
+
if (settings.disabledMoveSheet) return;
|
|
10558
10567
|
if (!sheet) return;
|
|
10559
10568
|
setContext(function (ctx) {
|
|
10560
10569
|
var currentOrder = -1;
|
|
@@ -10565,8 +10574,16 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10565
10574
|
}
|
|
10566
10575
|
});
|
|
10567
10576
|
core.api.setSheetOrder(ctx, _defineProperty({}, sheet.id, currentOrder + delta));
|
|
10577
|
+
var sorted = ___default['default'].sortBy(ctx.luckysheetfile, ["order"]);
|
|
10578
|
+
var newIndex = sorted.findIndex(function (_sheet) {
|
|
10579
|
+
return _sheet.id === sheet.id;
|
|
10580
|
+
});
|
|
10581
|
+
if (newIndex !== currentOrder) {
|
|
10582
|
+
var _settings$hooks, _settings$hooks$onMov, _sorted;
|
|
10583
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, sheet.id, (_sorted = sorted[newIndex + 1]) === null || _sorted === void 0 ? void 0 : _sorted.id);
|
|
10584
|
+
}
|
|
10568
10585
|
});
|
|
10569
|
-
}, [context.allowEdit, setContext, sheet]);
|
|
10586
|
+
}, [context.allowEdit, settings.disabledMoveSheet, settings.hooks, setContext, sheet]);
|
|
10570
10587
|
var hideSheet = React.useCallback(function () {
|
|
10571
10588
|
if (context.allowEdit === false) return;
|
|
10572
10589
|
if (!sheet) return;
|
|
@@ -10581,15 +10598,59 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10581
10598
|
}
|
|
10582
10599
|
});
|
|
10583
10600
|
}, [context.allowEdit, setContext, sheet, showAlert, sheetconfig]);
|
|
10584
|
-
var copySheet = React.useCallback(function () {
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10601
|
+
var copySheet = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
10602
|
+
var _settings$hooks2;
|
|
10603
|
+
var _ref2, onCopySheetCheck, isAllowed;
|
|
10604
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10605
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10606
|
+
case 0:
|
|
10607
|
+
if (!(context.allowEdit === false)) {
|
|
10608
|
+
_context.next = 2;
|
|
10609
|
+
break;
|
|
10610
|
+
}
|
|
10611
|
+
return _context.abrupt("return");
|
|
10612
|
+
case 2:
|
|
10613
|
+
if (sheet === null || sheet === void 0 ? void 0 : sheet.id) {
|
|
10614
|
+
_context.next = 4;
|
|
10615
|
+
break;
|
|
10616
|
+
}
|
|
10617
|
+
return _context.abrupt("return");
|
|
10618
|
+
case 4:
|
|
10619
|
+
_ref2 = (_settings$hooks2 = settings.hooks) !== null && _settings$hooks2 !== void 0 ? _settings$hooks2 : {}, onCopySheetCheck = _ref2.onCopySheetCheck;
|
|
10620
|
+
if (!onCopySheetCheck) {
|
|
10621
|
+
_context.next = 18;
|
|
10622
|
+
break;
|
|
10623
|
+
}
|
|
10624
|
+
_context.prev = 6;
|
|
10625
|
+
_context.next = 9;
|
|
10626
|
+
return onCopySheetCheck(sheet.id, sheet);
|
|
10627
|
+
case 9:
|
|
10628
|
+
isAllowed = _context.sent;
|
|
10629
|
+
_context.next = 16;
|
|
10630
|
+
break;
|
|
10631
|
+
case 12:
|
|
10632
|
+
_context.prev = 12;
|
|
10633
|
+
_context.t0 = _context["catch"](6);
|
|
10634
|
+
console.error(_context.t0);
|
|
10635
|
+
isAllowed = false;
|
|
10636
|
+
case 16:
|
|
10637
|
+
if (isAllowed) {
|
|
10638
|
+
_context.next = 18;
|
|
10639
|
+
break;
|
|
10640
|
+
}
|
|
10641
|
+
return _context.abrupt("return");
|
|
10642
|
+
case 18:
|
|
10643
|
+
setContext(function (ctx) {
|
|
10644
|
+
core.api.copySheet(ctx, sheet.id, settings.hooks);
|
|
10645
|
+
}, {
|
|
10646
|
+
addSheetOp: true
|
|
10647
|
+
});
|
|
10648
|
+
case 19:
|
|
10649
|
+
case "end":
|
|
10650
|
+
return _context.stop();
|
|
10651
|
+
}
|
|
10652
|
+
}, _callee, null, [[6, 12]]);
|
|
10653
|
+
})), [context.allowEdit, setContext, settings.hooks, sheet]);
|
|
10593
10654
|
var updateShowInputColor = React.useCallback(function (state) {
|
|
10594
10655
|
setIsShowInputColor(state);
|
|
10595
10656
|
}, []);
|
|
@@ -10630,34 +10691,34 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10630
10691
|
return ___default['default'].isUndefined(singleSheet.hide) || singleSheet.hide !== 1;
|
|
10631
10692
|
});
|
|
10632
10693
|
if (context.luckysheetfile.length > 1 && shownSheets.length > 1) {
|
|
10633
|
-
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
10694
|
+
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
10634
10695
|
var onDeleteSheetCheck, isAllowed;
|
|
10635
|
-
return _regeneratorRuntime().wrap(function
|
|
10636
|
-
while (1) switch (
|
|
10696
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10697
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
10637
10698
|
case 0:
|
|
10638
10699
|
onDeleteSheetCheck = settings.onDeleteSheetCheck;
|
|
10639
10700
|
if (!onDeleteSheetCheck) {
|
|
10640
|
-
|
|
10701
|
+
_context2.next = 14;
|
|
10641
10702
|
break;
|
|
10642
10703
|
}
|
|
10643
|
-
|
|
10644
|
-
|
|
10704
|
+
_context2.prev = 2;
|
|
10705
|
+
_context2.next = 5;
|
|
10645
10706
|
return onDeleteSheetCheck(sheet.id, sheet);
|
|
10646
10707
|
case 5:
|
|
10647
|
-
isAllowed =
|
|
10648
|
-
|
|
10708
|
+
isAllowed = _context2.sent;
|
|
10709
|
+
_context2.next = 12;
|
|
10649
10710
|
break;
|
|
10650
10711
|
case 8:
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
console.error(
|
|
10712
|
+
_context2.prev = 8;
|
|
10713
|
+
_context2.t0 = _context2["catch"](2);
|
|
10714
|
+
console.error(_context2.t0);
|
|
10654
10715
|
isAllowed = false;
|
|
10655
10716
|
case 12:
|
|
10656
10717
|
if (isAllowed) {
|
|
10657
|
-
|
|
10718
|
+
_context2.next = 14;
|
|
10658
10719
|
break;
|
|
10659
10720
|
}
|
|
10660
|
-
return
|
|
10721
|
+
return _context2.abrupt("return");
|
|
10661
10722
|
case 14:
|
|
10662
10723
|
setContext(function (ctx) {
|
|
10663
10724
|
core.deleteSheet(ctx, sheet.id);
|
|
@@ -10669,9 +10730,9 @@ var SheetTabContextMenu = function SheetTabContextMenu() {
|
|
|
10669
10730
|
hideAlert();
|
|
10670
10731
|
case 16:
|
|
10671
10732
|
case "end":
|
|
10672
|
-
return
|
|
10733
|
+
return _context2.stop();
|
|
10673
10734
|
}
|
|
10674
|
-
},
|
|
10735
|
+
}, _callee2, null, [[2, 8]]);
|
|
10675
10736
|
})), undefined, {
|
|
10676
10737
|
confirmText: sheetconfig.delete,
|
|
10677
10738
|
danger: true
|
package/dist/index.umd.js
CHANGED
|
@@ -26961,6 +26961,7 @@
|
|
|
26961
26961
|
var _useContext = React.useContext(WorkbookContext),
|
|
26962
26962
|
context = _useContext.context,
|
|
26963
26963
|
setContext = _useContext.setContext,
|
|
26964
|
+
settings = _useContext.settings,
|
|
26964
26965
|
refs = _useContext.refs;
|
|
26965
26966
|
var _useState = React.useState(false),
|
|
26966
26967
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -27043,6 +27044,7 @@
|
|
|
27043
27044
|
var droppingId = sheet.id;
|
|
27044
27045
|
var draggingSheet;
|
|
27045
27046
|
var droppingSheet;
|
|
27047
|
+
var moved = false;
|
|
27046
27048
|
lodash.sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
27047
27049
|
f.order = i;
|
|
27048
27050
|
if (f.id === draggingId) {
|
|
@@ -27056,13 +27058,19 @@
|
|
|
27056
27058
|
lodash.sortBy(draftCtx.luckysheetfile, ["order"]).forEach(function (f, i) {
|
|
27057
27059
|
f.order = i;
|
|
27058
27060
|
});
|
|
27061
|
+
moved = true;
|
|
27059
27062
|
} else if (draggingSheet && isDropPlaceholder) {
|
|
27060
27063
|
draggingSheet.order = draftCtx.luckysheetfile.length;
|
|
27064
|
+
moved = true;
|
|
27065
|
+
}
|
|
27066
|
+
if (moved) {
|
|
27067
|
+
var _settings$hooks, _settings$hooks$onMov;
|
|
27068
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, draggingId, isDropPlaceholder ? undefined : droppingId);
|
|
27061
27069
|
}
|
|
27062
27070
|
});
|
|
27063
27071
|
setDragOver(false);
|
|
27064
27072
|
e.stopPropagation();
|
|
27065
|
-
}, [context.allowEdit, isDropPlaceholder, setContext, sheet.id]);
|
|
27073
|
+
}, [context.allowEdit, isDropPlaceholder, setContext, settings.hooks, sheet.id]);
|
|
27066
27074
|
var onChangeSheet = useMemoizedFn(function () {
|
|
27067
27075
|
if (isDropPlaceholder) return;
|
|
27068
27076
|
setContext(function (draftCtx) {
|
|
@@ -27088,7 +27096,7 @@
|
|
|
27088
27096
|
},
|
|
27089
27097
|
onDrop: onDrop,
|
|
27090
27098
|
onDragStart: onDragStart,
|
|
27091
|
-
draggable: context.allowEdit && !editing,
|
|
27099
|
+
draggable: context.allowEdit && !settings.disabledMoveSheet && !editing,
|
|
27092
27100
|
key: sheet.id,
|
|
27093
27101
|
ref: containerRef,
|
|
27094
27102
|
className: isDropPlaceholder ? "leankylin-sheettab-placeholder" : "luckysheet-sheets-item".concat(context.currentSheetId === sheet.id ? " luckysheet-sheets-item-active" : ""),
|
|
@@ -29629,6 +29637,7 @@
|
|
|
29629
29637
|
useOutsideClick(containerRef, close, [close]);
|
|
29630
29638
|
var moveSheet = React.useCallback(function (delta) {
|
|
29631
29639
|
if (context.allowEdit === false) return;
|
|
29640
|
+
if (settings.disabledMoveSheet) return;
|
|
29632
29641
|
if (!sheet) return;
|
|
29633
29642
|
setContext(function (ctx) {
|
|
29634
29643
|
var currentOrder = -1;
|
|
@@ -29639,8 +29648,16 @@
|
|
|
29639
29648
|
}
|
|
29640
29649
|
});
|
|
29641
29650
|
core.api.setSheetOrder(ctx, _defineProperty({}, sheet.id, currentOrder + delta));
|
|
29651
|
+
var sorted = lodash.sortBy(ctx.luckysheetfile, ["order"]);
|
|
29652
|
+
var newIndex = sorted.findIndex(function (_sheet) {
|
|
29653
|
+
return _sheet.id === sheet.id;
|
|
29654
|
+
});
|
|
29655
|
+
if (newIndex !== currentOrder) {
|
|
29656
|
+
var _settings$hooks, _settings$hooks$onMov, _sorted;
|
|
29657
|
+
(_settings$hooks = settings.hooks) === null || _settings$hooks === void 0 ? void 0 : (_settings$hooks$onMov = _settings$hooks.onMoveSheet) === null || _settings$hooks$onMov === void 0 ? void 0 : _settings$hooks$onMov.call(_settings$hooks, sheet.id, (_sorted = sorted[newIndex + 1]) === null || _sorted === void 0 ? void 0 : _sorted.id);
|
|
29658
|
+
}
|
|
29642
29659
|
});
|
|
29643
|
-
}, [context.allowEdit, setContext, sheet]);
|
|
29660
|
+
}, [context.allowEdit, settings.disabledMoveSheet, settings.hooks, setContext, sheet]);
|
|
29644
29661
|
var hideSheet = React.useCallback(function () {
|
|
29645
29662
|
if (context.allowEdit === false) return;
|
|
29646
29663
|
if (!sheet) return;
|
|
@@ -29655,15 +29672,59 @@
|
|
|
29655
29672
|
}
|
|
29656
29673
|
});
|
|
29657
29674
|
}, [context.allowEdit, setContext, sheet, showAlert, sheetconfig]);
|
|
29658
|
-
var copySheet = React.useCallback(function () {
|
|
29659
|
-
|
|
29660
|
-
|
|
29661
|
-
|
|
29662
|
-
|
|
29663
|
-
|
|
29664
|
-
|
|
29665
|
-
|
|
29666
|
-
|
|
29675
|
+
var copySheet = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
29676
|
+
var _settings$hooks2;
|
|
29677
|
+
var _ref2, onCopySheetCheck, isAllowed;
|
|
29678
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
29679
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29680
|
+
case 0:
|
|
29681
|
+
if (!(context.allowEdit === false)) {
|
|
29682
|
+
_context.next = 2;
|
|
29683
|
+
break;
|
|
29684
|
+
}
|
|
29685
|
+
return _context.abrupt("return");
|
|
29686
|
+
case 2:
|
|
29687
|
+
if (sheet === null || sheet === void 0 ? void 0 : sheet.id) {
|
|
29688
|
+
_context.next = 4;
|
|
29689
|
+
break;
|
|
29690
|
+
}
|
|
29691
|
+
return _context.abrupt("return");
|
|
29692
|
+
case 4:
|
|
29693
|
+
_ref2 = (_settings$hooks2 = settings.hooks) !== null && _settings$hooks2 !== void 0 ? _settings$hooks2 : {}, onCopySheetCheck = _ref2.onCopySheetCheck;
|
|
29694
|
+
if (!onCopySheetCheck) {
|
|
29695
|
+
_context.next = 18;
|
|
29696
|
+
break;
|
|
29697
|
+
}
|
|
29698
|
+
_context.prev = 6;
|
|
29699
|
+
_context.next = 9;
|
|
29700
|
+
return onCopySheetCheck(sheet.id, sheet);
|
|
29701
|
+
case 9:
|
|
29702
|
+
isAllowed = _context.sent;
|
|
29703
|
+
_context.next = 16;
|
|
29704
|
+
break;
|
|
29705
|
+
case 12:
|
|
29706
|
+
_context.prev = 12;
|
|
29707
|
+
_context.t0 = _context["catch"](6);
|
|
29708
|
+
console.error(_context.t0);
|
|
29709
|
+
isAllowed = false;
|
|
29710
|
+
case 16:
|
|
29711
|
+
if (isAllowed) {
|
|
29712
|
+
_context.next = 18;
|
|
29713
|
+
break;
|
|
29714
|
+
}
|
|
29715
|
+
return _context.abrupt("return");
|
|
29716
|
+
case 18:
|
|
29717
|
+
setContext(function (ctx) {
|
|
29718
|
+
core.api.copySheet(ctx, sheet.id, settings.hooks);
|
|
29719
|
+
}, {
|
|
29720
|
+
addSheetOp: true
|
|
29721
|
+
});
|
|
29722
|
+
case 19:
|
|
29723
|
+
case "end":
|
|
29724
|
+
return _context.stop();
|
|
29725
|
+
}
|
|
29726
|
+
}, _callee, null, [[6, 12]]);
|
|
29727
|
+
})), [context.allowEdit, setContext, settings.hooks, sheet]);
|
|
29667
29728
|
var updateShowInputColor = React.useCallback(function (state) {
|
|
29668
29729
|
setIsShowInputColor(state);
|
|
29669
29730
|
}, []);
|
|
@@ -29704,34 +29765,34 @@
|
|
|
29704
29765
|
return lodash.isUndefined(singleSheet.hide) || singleSheet.hide !== 1;
|
|
29705
29766
|
});
|
|
29706
29767
|
if (context.luckysheetfile.length > 1 && shownSheets.length > 1) {
|
|
29707
|
-
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
29768
|
+
showAlert("".concat(sheetconfig.confirmDelete, "\"").concat(sheet.name, "\"\uFF1F"), "yesno", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
29708
29769
|
var onDeleteSheetCheck, isAllowed;
|
|
29709
|
-
return _regeneratorRuntime().wrap(function
|
|
29710
|
-
while (1) switch (
|
|
29770
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
29771
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
29711
29772
|
case 0:
|
|
29712
29773
|
onDeleteSheetCheck = settings.onDeleteSheetCheck;
|
|
29713
29774
|
if (!onDeleteSheetCheck) {
|
|
29714
|
-
|
|
29775
|
+
_context2.next = 14;
|
|
29715
29776
|
break;
|
|
29716
29777
|
}
|
|
29717
|
-
|
|
29718
|
-
|
|
29778
|
+
_context2.prev = 2;
|
|
29779
|
+
_context2.next = 5;
|
|
29719
29780
|
return onDeleteSheetCheck(sheet.id, sheet);
|
|
29720
29781
|
case 5:
|
|
29721
|
-
isAllowed =
|
|
29722
|
-
|
|
29782
|
+
isAllowed = _context2.sent;
|
|
29783
|
+
_context2.next = 12;
|
|
29723
29784
|
break;
|
|
29724
29785
|
case 8:
|
|
29725
|
-
|
|
29726
|
-
|
|
29727
|
-
console.error(
|
|
29786
|
+
_context2.prev = 8;
|
|
29787
|
+
_context2.t0 = _context2["catch"](2);
|
|
29788
|
+
console.error(_context2.t0);
|
|
29728
29789
|
isAllowed = false;
|
|
29729
29790
|
case 12:
|
|
29730
29791
|
if (isAllowed) {
|
|
29731
|
-
|
|
29792
|
+
_context2.next = 14;
|
|
29732
29793
|
break;
|
|
29733
29794
|
}
|
|
29734
|
-
return
|
|
29795
|
+
return _context2.abrupt("return");
|
|
29735
29796
|
case 14:
|
|
29736
29797
|
setContext(function (ctx) {
|
|
29737
29798
|
core.deleteSheet(ctx, sheet.id);
|
|
@@ -29743,9 +29804,9 @@
|
|
|
29743
29804
|
hideAlert();
|
|
29744
29805
|
case 16:
|
|
29745
29806
|
case "end":
|
|
29746
|
-
return
|
|
29807
|
+
return _context2.stop();
|
|
29747
29808
|
}
|
|
29748
|
-
},
|
|
29809
|
+
}, _callee2, null, [[2, 8]]);
|
|
29749
29810
|
})), undefined, {
|
|
29750
29811
|
confirmText: sheetconfig.delete,
|
|
29751
29812
|
danger: true
|