@fileverse-dev/fortune-react 1.2.44 → 1.2.45

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.
@@ -238,6 +238,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
238
238
  });
239
239
  selectedSourceColRef.current = selectedSourceCol;
240
240
  selectedTargetColRef.current = selectedTargetCol;
241
+ console.log("selectedSourceCol", selectedTargetCol);
241
242
  selectedSourceCol.forEach(function () {
242
243
  var adjustedSourceIndex = sourceIndex_1;
243
244
  if (targetIndex < sourceIndex_1) {
@@ -351,13 +352,10 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
351
352
  }
352
353
  });
353
354
  (_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
354
- });
355
- var d = getFlowdata(context);
356
- var rowLen_1 = (d === null || d === void 0 ? void 0 : d.length) || 0;
357
- setContext(function (draftCtx) {
358
- api.setSelection(draftCtx, [{
359
- row: [0, rowLen_1],
360
- column: selectedTargetColRef.current
355
+ var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
356
+ api.setSelection(draft, [{
357
+ row: [0, rowLen],
358
+ column: [selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0], selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1]]
361
359
  }], {
362
360
  id: context.currentSheetId
363
361
  });
@@ -194,20 +194,20 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
194
194
  }
195
195
  };
196
196
  var handleRowDragEnd = function handleRowDragEnd(ev) {
197
- var _a, _b, _c, _d;
197
+ var _a, _b, _c;
198
198
  if (!dragRef.current.mouseDown) return;
199
199
  dragRef.current.mouseDown = false;
200
200
  try {
201
201
  document.body.style.userSelect = dragRef.current.prevUserSelect || "";
202
202
  document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
203
- } catch (_e) {}
203
+ } catch (_d) {}
204
204
  if (dragRef.current.active) {
205
205
  var finalInsertionIndex_1 = computeInsertionFromPageY(ev.pageY).insertionIndex;
206
206
  var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) === null || _c === void 0 ? void 0 : _c[0]) || 0;
207
207
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
208
208
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
209
209
  setContext(function (draft) {
210
- var _a, _b, _c, _d, _e;
210
+ var _a, _b, _c, _d, _e, _f;
211
211
  var _sheet = draft.luckysheetfile[sheetIdx_1];
212
212
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
213
213
  var rows = _sheet.data;
@@ -341,20 +341,10 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
341
341
  }
342
342
  });
343
343
  (_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
344
- });
345
- var d = getFlowdata(context);
346
- var colLen_1 = ((_d = d === null || d === void 0 ? void 0 : d[0]) === null || _d === void 0 ? void 0 : _d.length) || 0;
347
- var targetIndex_1 = finalInsertionIndex_1;
348
- if (targetIndex_1 > sourceIndex_1) targetIndex_1 -= 1;
349
- var selData = api.getSelection(context) || [];
350
- var sel = __spreadArray([], selData, true);
351
- if (sel && sel[0]) {
352
- sel[0].column = [targetIndex_1, targetIndex_1];
353
- }
354
- setContext(function (draftCtx) {
355
- api.setSelection(draftCtx, [{
356
- row: [targetIndex_1, targetIndex_1],
357
- column: [0, colLen_1]
344
+ var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
345
+ api.setSelection(draft, [{
346
+ row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
347
+ column: [0, colLen]
358
348
  }], {
359
349
  id: context.currentSheetId
360
350
  });
@@ -1,7 +1,7 @@
1
1
  import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
2
2
  import { getCryptoPrice } from "../../utils/cryptoApi";
3
3
  import { SetContextOptions } from "../../context";
4
- export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
4
+ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null, refs: any): {
5
5
  applyOp: (ops: Op[]) => void;
6
6
  getCryptoPrice: typeof getCryptoPrice;
7
7
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
@@ -1191,4 +1191,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
1191
1191
  getWorkbookContext: () => Context;
1192
1192
  getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
1193
1193
  getSettings: () => Required<Settings>;
1194
+ getRefs: () => any;
1195
+ getShowDialog: () => (content: import("react").ReactNode, type?: "ok" | "yesno" | undefined, title?: import("react").ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
1196
+ getSplitColComponent: () => import("react").FC<{}>;
1194
1197
  };
@@ -12,7 +12,9 @@ import { addSheet, api, deleteRowCol, deleteSheet, insertRowCol, opToPatch, crea
12
12
  import { applyPatches } from "immer";
13
13
  import _ from "lodash";
14
14
  import { getCryptoPrice } from "../../utils/cryptoApi";
15
- export function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
15
+ import { useDialog } from "../../hooks/useDialog";
16
+ import { SplitColumn } from "../../components/SplitColumn";
17
+ export function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache, refs) {
16
18
  return {
17
19
  applyOp: function applyOp(ops) {
18
20
  setContext(function (ctx_) {
@@ -436,6 +438,16 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
436
438
  },
437
439
  getSettings: function getSettings() {
438
440
  return settings;
441
+ },
442
+ getRefs: function getRefs() {
443
+ return refs;
444
+ },
445
+ getShowDialog: function getShowDialog() {
446
+ var showDialog = useDialog().showDialog;
447
+ return showDialog;
448
+ },
449
+ getSplitColComponent: function getSplitColComponent() {
450
+ return SplitColumn;
439
451
  }
440
452
  };
441
453
  }
@@ -1199,5 +1199,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
1199
1199
  getWorkbookContext: () => Context;
1200
1200
  getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions | undefined) => void;
1201
1201
  getSettings: () => Required<Settings>;
1202
+ getRefs: () => any;
1203
+ getShowDialog: () => (content: React.ReactNode, type?: "ok" | "yesno" | undefined, title?: React.ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
1204
+ getSplitColComponent: () => React.FC<{}>;
1202
1205
  }>>;
1203
1206
  export default Workbook;
@@ -663,7 +663,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
663
663
  };
664
664
  }, [onPaste]);
665
665
  useImperativeHandle(ref, function () {
666
- return generateAPIs(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current);
666
+ return generateAPIs(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current, refs);
667
667
  }, [context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, globalCache]);
668
668
  var i = getSheetIndex(context, context.currentSheetId);
669
669
  if (i == null) {
@@ -246,6 +246,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
246
246
  });
247
247
  selectedSourceColRef.current = selectedSourceCol;
248
248
  selectedTargetColRef.current = selectedTargetCol;
249
+ console.log("selectedSourceCol", selectedTargetCol);
249
250
  selectedSourceCol.forEach(function () {
250
251
  var adjustedSourceIndex = sourceIndex_1;
251
252
  if (targetIndex < sourceIndex_1) {
@@ -359,13 +360,10 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
359
360
  }
360
361
  });
361
362
  (_g = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _g === void 0 ? void 0 : _g.call(window, selectedSourceCol, selectedTargetCol, "column", context.currentSheetId, sourceIndex_1, targetIndex);
362
- });
363
- var d = (0, _fortuneCore.getFlowdata)(context);
364
- var rowLen_1 = (d === null || d === void 0 ? void 0 : d.length) || 0;
365
- setContext(function (draftCtx) {
366
- _fortuneCore.api.setSelection(draftCtx, [{
367
- row: [0, rowLen_1],
368
- column: selectedTargetColRef.current
363
+ var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
364
+ _fortuneCore.api.setSelection(draft, [{
365
+ row: [0, rowLen],
366
+ column: [selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[0], selectedTargetCol === null || selectedTargetCol === void 0 ? void 0 : selectedTargetCol[selectedTargetCol.length - 1]]
369
367
  }], {
370
368
  id: context.currentSheetId
371
369
  });
@@ -201,20 +201,20 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
201
201
  }
202
202
  };
203
203
  var handleRowDragEnd = function handleRowDragEnd(ev) {
204
- var _a, _b, _c, _d;
204
+ var _a, _b, _c;
205
205
  if (!dragRef.current.mouseDown) return;
206
206
  dragRef.current.mouseDown = false;
207
207
  try {
208
208
  document.body.style.userSelect = dragRef.current.prevUserSelect || "";
209
209
  document.body.style.webkitUserSelect = dragRef.current.prevWebkitUserSelect || "";
210
- } catch (_e) {}
210
+ } catch (_d) {}
211
211
  if (dragRef.current.active) {
212
212
  var finalInsertionIndex_1 = computeInsertionFromPageY(ev.pageY).insertionIndex;
213
213
  var sourceIndex_1 = ((_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) === null || _c === void 0 ? void 0 : _c[0]) || 0;
214
214
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
215
215
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
216
216
  setContext(function (draft) {
217
- var _a, _b, _c, _d, _e;
217
+ var _a, _b, _c, _d, _e, _f;
218
218
  var _sheet = draft.luckysheetfile[sheetIdx_1];
219
219
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
220
220
  var rows = _sheet.data;
@@ -348,20 +348,10 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
348
348
  }
349
349
  });
350
350
  (_e = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _e === void 0 ? void 0 : _e.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
351
- });
352
- var d = (0, _fortuneCore.getFlowdata)(context);
353
- var colLen_1 = ((_d = d === null || d === void 0 ? void 0 : d[0]) === null || _d === void 0 ? void 0 : _d.length) || 0;
354
- var targetIndex_1 = finalInsertionIndex_1;
355
- if (targetIndex_1 > sourceIndex_1) targetIndex_1 -= 1;
356
- var selData = _fortuneCore.api.getSelection(context) || [];
357
- var sel = __spreadArray([], selData, true);
358
- if (sel && sel[0]) {
359
- sel[0].column = [targetIndex_1, targetIndex_1];
360
- }
361
- setContext(function (draftCtx) {
362
- _fortuneCore.api.setSelection(draftCtx, [{
363
- row: [targetIndex_1, targetIndex_1],
364
- column: [0, colLen_1]
351
+ var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
352
+ _fortuneCore.api.setSelection(draft, [{
353
+ row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
354
+ column: [0, colLen]
365
355
  }], {
366
356
  id: context.currentSheetId
367
357
  });
@@ -1,7 +1,7 @@
1
1
  import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
2
2
  import { getCryptoPrice } from "../../utils/cryptoApi";
3
3
  import { SetContextOptions } from "../../context";
4
- export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
4
+ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null, refs: any): {
5
5
  applyOp: (ops: Op[]) => void;
6
6
  getCryptoPrice: typeof getCryptoPrice;
7
7
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
@@ -1191,4 +1191,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
1191
1191
  getWorkbookContext: () => Context;
1192
1192
  getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
1193
1193
  getSettings: () => Required<Settings>;
1194
+ getRefs: () => any;
1195
+ getShowDialog: () => (content: import("react").ReactNode, type?: "ok" | "yesno" | undefined, title?: import("react").ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
1196
+ getSplitColComponent: () => import("react").FC<{}>;
1194
1197
  };
@@ -8,6 +8,8 @@ var _fortuneCore = require("@fileverse-dev/fortune-core");
8
8
  var _immer = require("immer");
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _cryptoApi = require("../../utils/cryptoApi");
11
+ var _useDialog = require("../../hooks/useDialog");
12
+ var _SplitColumn = require("../../components/SplitColumn");
11
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
14
  var __assign = void 0 && (void 0).__assign || function () {
13
15
  __assign = Object.assign || function (t) {
@@ -19,7 +21,7 @@ var __assign = void 0 && (void 0).__assign || function () {
19
21
  };
20
22
  return __assign.apply(this, arguments);
21
23
  };
22
- function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
24
+ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache, refs) {
23
25
  return {
24
26
  applyOp: function applyOp(ops) {
25
27
  setContext(function (ctx_) {
@@ -443,6 +445,16 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
443
445
  },
444
446
  getSettings: function getSettings() {
445
447
  return settings;
448
+ },
449
+ getRefs: function getRefs() {
450
+ return refs;
451
+ },
452
+ getShowDialog: function getShowDialog() {
453
+ var showDialog = (0, _useDialog.useDialog)().showDialog;
454
+ return showDialog;
455
+ },
456
+ getSplitColComponent: function getSplitColComponent() {
457
+ return _SplitColumn.SplitColumn;
446
458
  }
447
459
  };
448
460
  }
@@ -1199,5 +1199,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
1199
1199
  getWorkbookContext: () => Context;
1200
1200
  getWorkbookSetContext: () => (recipe: (ctx: Context) => void, options?: SetContextOptions | undefined) => void;
1201
1201
  getSettings: () => Required<Settings>;
1202
+ getRefs: () => any;
1203
+ getShowDialog: () => (content: React.ReactNode, type?: "ok" | "yesno" | undefined, title?: React.ReactNode, okLabel?: string | undefined, cancelLabel?: string | undefined, onOk?: () => void, onCancel?: () => void) => void;
1204
+ getSplitColComponent: () => React.FC<{}>;
1202
1205
  }>>;
1203
1206
  export default Workbook;
@@ -672,7 +672,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
672
672
  };
673
673
  }, [onPaste]);
674
674
  (0, _react.useImperativeHandle)(ref, function () {
675
- return (0, _api.generateAPIs)(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current);
675
+ return (0, _api.generateAPIs)(context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, cellInput.current, scrollbarX.current, scrollbarY.current, globalCache.current, refs);
676
676
  }, [context, setContextWithProduce, handleUndo, handleRedo, mergedSettings, globalCache]);
677
677
  var i = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
678
678
  if (i == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.44",
3
+ "version": "1.2.45",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",