@leankylin-sheet/react 5.2.76 → 6.0.0
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/context/index.d.ts +1 -0
- package/dist/index.esm.js +90 -58
- package/dist/index.js +90 -58
- package/dist/index.umd.js +90 -58
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
|
@@ -19640,6 +19640,7 @@
|
|
|
19640
19640
|
var WorkbookContext = /*#__PURE__*/React__default['default'].createContext({
|
|
19641
19641
|
context: core.defaultContext(defaultRefs),
|
|
19642
19642
|
setContext: function setContext() {},
|
|
19643
|
+
setScrollContext: function setScrollContext() {},
|
|
19643
19644
|
settings: core.defaultSettings,
|
|
19644
19645
|
handleUndo: function handleUndo() {},
|
|
19645
19646
|
handleRedo: function handleRedo() {},
|
|
@@ -20754,7 +20755,7 @@
|
|
|
20754
20755
|
var _useContext = React.useContext(WorkbookContext),
|
|
20755
20756
|
context = _useContext.context,
|
|
20756
20757
|
refs = _useContext.refs,
|
|
20757
|
-
|
|
20758
|
+
setScrollContext = _useContext.setScrollContext;
|
|
20758
20759
|
var ref = axis === "x" ? refs.scrollbarX : refs.scrollbarY;
|
|
20759
20760
|
var _useInViewport = useInViewport(ref),
|
|
20760
20761
|
_useInViewport2 = _slicedToArray(_useInViewport, 1),
|
|
@@ -20787,11 +20788,11 @@
|
|
|
20787
20788
|
className: "luckysheet-scrollbars luckysheet-scrollbar-ltr luckysheet-scrollbar-".concat(axis),
|
|
20788
20789
|
onScroll: function onScroll() {
|
|
20789
20790
|
if (axis === "x") {
|
|
20790
|
-
|
|
20791
|
+
setScrollContext(function (draftCtx) {
|
|
20791
20792
|
draftCtx.scrollLeft = refs.scrollbarX.current.scrollLeft;
|
|
20792
20793
|
});
|
|
20793
20794
|
} else {
|
|
20794
|
-
|
|
20795
|
+
setScrollContext(function (draftCtx) {
|
|
20795
20796
|
draftCtx.scrollTop = refs.scrollbarY.current.scrollTop;
|
|
20796
20797
|
});
|
|
20797
20798
|
}
|
|
@@ -23434,9 +23435,7 @@
|
|
|
23434
23435
|
}, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
23435
23436
|
var debounceMouseMove = useMemoizedFn(function (e) {
|
|
23436
23437
|
var nativeEvent = e.nativeEvent;
|
|
23437
|
-
|
|
23438
|
-
core.handleCellAreaMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
23439
|
-
});
|
|
23438
|
+
core.handleCellAreaMouseMove(context, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
23440
23439
|
});
|
|
23441
23440
|
var debounceDragOver = useMemoizedFn(function (e) {
|
|
23442
23441
|
var nativeEvent = e.nativeEvent;
|
|
@@ -23506,12 +23505,29 @@
|
|
|
23506
23505
|
debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
|
|
23507
23506
|
}
|
|
23508
23507
|
}, [debouncedShowLinkCard]);
|
|
23508
|
+
var lastHoverCellRef = React.useRef(null);
|
|
23509
23509
|
var onMouseMove = React.useCallback(function (nativeEvent) {
|
|
23510
|
+
var _gc$commentBox, _gc$commentBox2, _gc$searchDialog, _gc$linkCard;
|
|
23511
|
+
var container = containerRef.current;
|
|
23512
|
+
var scrollX = refs.scrollbarX.current;
|
|
23513
|
+
var scrollY = refs.scrollbarY.current;
|
|
23514
|
+
if (!container || !scrollX || !scrollY) return;
|
|
23515
|
+
var gc = refs.globalCache;
|
|
23516
|
+
var isInteracting = !!context.luckysheet_scroll_status || !!context.luckysheet_select_status || !!context.luckysheet_rows_selected_status || !!context.luckysheet_cols_selected_status || !!context.luckysheet_cell_selected_move || !!context.luckysheet_cell_selected_extend || !!context.luckysheet_cols_change_size || !!context.luckysheet_rows_change_size || ((_gc$commentBox = gc.commentBox) === null || _gc$commentBox === void 0 ? void 0 : _gc$commentBox.movingId) != null || ((_gc$commentBox2 = gc.commentBox) === null || _gc$commentBox2 === void 0 ? void 0 : _gc$commentBox2.resizingId) != null || gc.image != null || ((_gc$searchDialog = gc.searchDialog) === null || _gc$searchDialog === void 0 ? void 0 : _gc$searchDialog.moveProps) != null || ((_gc$linkCard = gc.linkCard) === null || _gc$linkCard === void 0 ? void 0 : _gc$linkCard.rangeSelectionModal) != null;
|
|
23517
|
+
if (!isInteracting) {
|
|
23518
|
+
var rc = core.getCellRowColumn(context, nativeEvent, container, scrollX, scrollY);
|
|
23519
|
+
var last = lastHoverCellRef.current;
|
|
23520
|
+
var hoverChanged = rc == null ? last != null : last == null || last.r !== rc.r || last.c !== rc.c;
|
|
23521
|
+
if (!hoverChanged) {
|
|
23522
|
+
return;
|
|
23523
|
+
}
|
|
23524
|
+
lastHoverCellRef.current = rc !== null && rc !== void 0 ? rc : null;
|
|
23525
|
+
}
|
|
23510
23526
|
setContext(function (draftCtx) {
|
|
23511
|
-
overShowLinkCard(draftCtx, refs.globalCache, nativeEvent,
|
|
23512
|
-
core.handleOverlayMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current,
|
|
23527
|
+
overShowLinkCard(draftCtx, refs.globalCache, nativeEvent, container, scrollX, scrollY);
|
|
23528
|
+
core.handleOverlayMouseMove(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, scrollX, scrollY, container, refs.fxInput.current);
|
|
23513
23529
|
});
|
|
23514
|
-
}, [overShowLinkCard, refs.cellInput, refs.fxInput, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
|
|
23530
|
+
}, [overShowLinkCard, context, refs.cellInput, refs.fxInput, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext]);
|
|
23515
23531
|
var onMouseUp = React.useCallback(function (nativeEvent) {
|
|
23516
23532
|
setContext(function (draftCtx) {
|
|
23517
23533
|
try {
|
|
@@ -24098,9 +24114,7 @@
|
|
|
24098
24114
|
return false;
|
|
24099
24115
|
}
|
|
24100
24116
|
var onWheel = React.useCallback(function (e) {
|
|
24101
|
-
|
|
24102
|
-
core.handleGlobalWheel(draftCtx, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
24103
|
-
});
|
|
24117
|
+
core.handleGlobalWheel(context, e, refs.globalCache, refs.scrollbarX.current, refs.scrollbarY.current);
|
|
24104
24118
|
if (e.deltaY === 0 && e.deltaX === 0) {
|
|
24105
24119
|
return;
|
|
24106
24120
|
}
|
|
@@ -24121,7 +24135,7 @@
|
|
|
24121
24135
|
e.preventDefault();
|
|
24122
24136
|
}
|
|
24123
24137
|
}
|
|
24124
|
-
}, [refs.globalCache, refs.scrollbarX, refs.scrollbarY
|
|
24138
|
+
}, [context, refs.globalCache, refs.scrollbarX, refs.scrollbarY]);
|
|
24125
24139
|
React.useEffect(function () {
|
|
24126
24140
|
var container = containerRef.current;
|
|
24127
24141
|
container === null || container === void 0 ? void 0 : container.addEventListener("wheel", onWheel);
|
|
@@ -31203,60 +31217,77 @@
|
|
|
31203
31217
|
}
|
|
31204
31218
|
}
|
|
31205
31219
|
contextRef.current = result;
|
|
31206
|
-
setContext(
|
|
31220
|
+
setContext(function (prev) {
|
|
31221
|
+
if (prev === ctx_) {
|
|
31222
|
+
return result;
|
|
31223
|
+
}
|
|
31224
|
+
var merged = pn(prev, patches);
|
|
31225
|
+
contextRef.current = merged;
|
|
31226
|
+
return merged;
|
|
31227
|
+
});
|
|
31228
|
+
});
|
|
31229
|
+
var setScrollContext = useMemoizedFn(function (recipe) {
|
|
31230
|
+
setContext(function (ctx_) {
|
|
31231
|
+
var result = fn(ctx_, recipe);
|
|
31232
|
+
if (result === ctx_) {
|
|
31233
|
+
return ctx_;
|
|
31234
|
+
}
|
|
31235
|
+
contextRef.current = result;
|
|
31236
|
+
return result;
|
|
31237
|
+
});
|
|
31207
31238
|
});
|
|
31208
31239
|
var handleUndo = React.useCallback(function () {
|
|
31209
31240
|
var history = globalCache.current.undoList.pop();
|
|
31210
31241
|
if (history) {
|
|
31211
|
-
|
|
31212
|
-
|
|
31213
|
-
|
|
31214
|
-
|
|
31215
|
-
|
|
31216
|
-
|
|
31217
|
-
|
|
31218
|
-
|
|
31219
|
-
|
|
31220
|
-
});
|
|
31221
|
-
lodash.forEach(sheetsRight, function (sheet) {
|
|
31222
|
-
history.inversePatches.push({
|
|
31223
|
-
op: "replace",
|
|
31224
|
-
path: ["luckysheetfile", core.getSheetIndex(ctx_, sheet.id), "order"],
|
|
31225
|
-
value: (sheet === null || sheet === void 0 ? void 0 : sheet.order) + 1
|
|
31242
|
+
setContext(function (ctx_) {
|
|
31243
|
+
var _history$options, _history$options3;
|
|
31244
|
+
if ((_history$options = history.options) === null || _history$options === void 0 ? void 0 : _history$options.deleteSheetOp) {
|
|
31245
|
+
var _history$options$dele, _history$options$dele2;
|
|
31246
|
+
history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
|
|
31247
|
+
var order = (_history$options$dele = history.options.deletedSheet) === null || _history$options$dele === void 0 ? void 0 : (_history$options$dele2 = _history$options$dele.value) === null || _history$options$dele2 === void 0 ? void 0 : _history$options$dele2.order;
|
|
31248
|
+
var sheetsRight = ctx_.luckysheetfile.filter(function (sheet) {
|
|
31249
|
+
var _history$options2, _history$options2$del;
|
|
31250
|
+
return (sheet === null || sheet === void 0 ? void 0 : sheet.order) >= order && sheet.id !== (history === null || history === void 0 ? void 0 : (_history$options2 = history.options) === null || _history$options2 === void 0 ? void 0 : (_history$options2$del = _history$options2.deleteSheetOp) === null || _history$options2$del === void 0 ? void 0 : _history$options2$del.id);
|
|
31226
31251
|
});
|
|
31227
|
-
|
|
31228
|
-
|
|
31229
|
-
|
|
31230
|
-
|
|
31231
|
-
|
|
31232
|
-
|
|
31233
|
-
|
|
31234
|
-
|
|
31235
|
-
|
|
31236
|
-
|
|
31237
|
-
var
|
|
31238
|
-
inversedOptions.
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
|
|
31248
|
-
|
|
31252
|
+
lodash.forEach(sheetsRight, function (sheet) {
|
|
31253
|
+
history.inversePatches.push({
|
|
31254
|
+
op: "replace",
|
|
31255
|
+
path: ["luckysheetfile", core.getSheetIndex(ctx_, sheet.id), "order"],
|
|
31256
|
+
value: (sheet === null || sheet === void 0 ? void 0 : sheet.order) + 1
|
|
31257
|
+
});
|
|
31258
|
+
});
|
|
31259
|
+
}
|
|
31260
|
+
var newContext = pn(ctx_, history.inversePatches);
|
|
31261
|
+
globalCache.current.redoList.push(history);
|
|
31262
|
+
var inversedOptions = core.inverseRowColOptions(history.options);
|
|
31263
|
+
if (inversedOptions === null || inversedOptions === void 0 ? void 0 : inversedOptions.insertRowColOp) {
|
|
31264
|
+
inversedOptions.restoreDeletedCells = true;
|
|
31265
|
+
}
|
|
31266
|
+
if ((_history$options3 = history.options) === null || _history$options3 === void 0 ? void 0 : _history$options3.addSheetOp) {
|
|
31267
|
+
var _inversedOptions$addS;
|
|
31268
|
+
var index = core.getSheetIndex(ctx_, history.options.addSheet.id);
|
|
31269
|
+
inversedOptions.addSheet = {
|
|
31270
|
+
id: history.options.addSheet.id,
|
|
31271
|
+
index: index,
|
|
31272
|
+
value: lodash.cloneDeep(ctx_.luckysheetfile[index])
|
|
31273
|
+
};
|
|
31274
|
+
inversedOptions.addSheet.value.celldata = dataToCelldata((_inversedOptions$addS = inversedOptions.addSheet.value) === null || _inversedOptions$addS === void 0 ? void 0 : _inversedOptions$addS.data);
|
|
31275
|
+
delete inversedOptions.addSheet.value.data;
|
|
31276
|
+
}
|
|
31277
|
+
emitOp(newContext, history.inversePatches, inversedOptions, true);
|
|
31278
|
+
return newContext;
|
|
31279
|
+
});
|
|
31249
31280
|
}
|
|
31250
31281
|
}, [emitOp]);
|
|
31251
31282
|
var handleRedo = React.useCallback(function () {
|
|
31252
31283
|
var history = globalCache.current.redoList.pop();
|
|
31253
31284
|
if (history) {
|
|
31254
|
-
|
|
31255
|
-
|
|
31256
|
-
|
|
31257
|
-
|
|
31258
|
-
|
|
31259
|
-
|
|
31285
|
+
setContext(function (ctx_) {
|
|
31286
|
+
var newContext = pn(ctx_, history.patches);
|
|
31287
|
+
globalCache.current.undoList.push(history);
|
|
31288
|
+
emitOp(newContext, history.patches, history.options);
|
|
31289
|
+
return newContext;
|
|
31290
|
+
});
|
|
31260
31291
|
}
|
|
31261
31292
|
}, [emitOp]);
|
|
31262
31293
|
React.useEffect(function () {
|
|
@@ -31277,12 +31308,13 @@
|
|
|
31277
31308
|
return {
|
|
31278
31309
|
context: context,
|
|
31279
31310
|
setContext: setContextWithProduce,
|
|
31311
|
+
setScrollContext: setScrollContext,
|
|
31280
31312
|
settings: mergedSettings,
|
|
31281
31313
|
handleUndo: handleUndo,
|
|
31282
31314
|
handleRedo: handleRedo,
|
|
31283
31315
|
refs: refs
|
|
31284
31316
|
};
|
|
31285
|
-
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
|
|
31317
|
+
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext]);
|
|
31286
31318
|
React.useEffect(function () {
|
|
31287
31319
|
if (!lodash.isEmpty(context.luckysheetfile)) {
|
|
31288
31320
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|