@fileverse-dev/fortune-react 1.1.86 → 1.1.88

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.
@@ -1,4 +1,5 @@
1
1
  import { RefObject } from "react";
2
+ export declare function numberToColumnName(num: number): string;
2
3
  export declare const useColumnDragAndDrop: (containerRef: RefObject<HTMLDivElement | null>, selectedLocationRef: RefObject<any[]>) => {
3
4
  initiateDrag: (clickedColIndex: number, startX: number) => void;
4
5
  getColIndexClicked: (pageX: number, headerEl: HTMLDivElement) => number;
@@ -1,6 +1,15 @@
1
1
  import { useContext, useRef } from "react";
2
- import { fixPositionOnFrozenCells, getSheetIndex, colLocation, colLocationByIndex, updateContextWithSheetData } from "@fileverse-dev/fortune-core";
2
+ import { fixPositionOnFrozenCells, getSheetIndex, getFlowdata, colLocation, colLocationByIndex, updateContextWithSheetData } from "@fileverse-dev/fortune-core";
3
3
  import WorkbookContext from "../../../context";
4
+ export function numberToColumnName(num) {
5
+ var columnName = '';
6
+ while (num >= 0) {
7
+ var remainder = num % 26;
8
+ columnName = String.fromCharCode(65 + remainder) + columnName;
9
+ num = Math.floor(num / 26) - 1;
10
+ }
11
+ return columnName;
12
+ }
4
13
  export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, selectedLocationRef) {
5
14
  var DOUBLE_CLICK_MS = 300;
6
15
  var START_DRAG_THRESHOLD_PX = 6;
@@ -103,7 +112,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
103
112
  var createGhost = function createGhost(host) {
104
113
  var el = document.createElement("div");
105
114
  el.style.position = "fixed";
106
- el.style.top = "135px";
115
+ el.style.top = "134px";
107
116
  el.style.height = "".concat(window.innerHeight, "px");
108
117
  el.style.boxSizing = "border-box";
109
118
  el.style.padding = "6px 8px";
@@ -185,8 +194,9 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
185
194
  var sourceIndex_1 = dragRef.current.source;
186
195
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
187
196
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
197
+ console.log("sourceIndex", sourceIndex_1);
188
198
  setContext(function (draft) {
189
- var _a, _b;
199
+ var _a, _b, _c, _d;
190
200
  var _sheet = draft.luckysheetfile[sheetIdx_1];
191
201
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
192
202
  var rows = _sheet.data;
@@ -205,6 +215,74 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
205
215
  }
206
216
  _sheet.data = rows;
207
217
  updateContextWithSheetData(draft, _sheet.data);
218
+ var d = getFlowdata(draft);
219
+ d === null || d === void 0 ? void 0 : d.forEach(function (row) {
220
+ row.forEach(function (cell) {
221
+ if (cell) {
222
+ var sourceColName = numberToColumnName(sourceIndex_1);
223
+ var targetColName_1 = numberToColumnName(targetIndex);
224
+ if (cell.f) {
225
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
226
+ if (/^\d+$/.test(p1)) {
227
+ return "".concat(targetColName_1).concat(p1);
228
+ }
229
+ return match;
230
+ });
231
+ }
232
+ var otherAffectedCols = [];
233
+ if (sourceIndex_1 < targetIndex) {
234
+ for (var c = sourceIndex_1 + 1; c < targetIndex; c += 1) {
235
+ otherAffectedCols.push({
236
+ source: numberToColumnName(c),
237
+ target: numberToColumnName(c - 1)
238
+ });
239
+ }
240
+ } else if (sourceIndex_1 > targetIndex) {
241
+ for (var c = targetIndex; c < sourceIndex_1; c += 1) {
242
+ otherAffectedCols.push({
243
+ source: numberToColumnName(c),
244
+ target: numberToColumnName(c + 1)
245
+ });
246
+ }
247
+ }
248
+ if (cell.f) {
249
+ var formula_1 = cell.f;
250
+ var replacements_1 = [];
251
+ otherAffectedCols.forEach(function (col) {
252
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
253
+ var match;
254
+ while ((match = regex.exec(formula_1)) !== null) {
255
+ if (/^\d+$/.test(match[1])) {
256
+ replacements_1.push({
257
+ start: match.index,
258
+ end: match.index + match[0].length,
259
+ original: match[0],
260
+ replacement: "".concat(col.target).concat(match[1])
261
+ });
262
+ }
263
+ }
264
+ });
265
+ replacements_1 === null || replacements_1 === void 0 ? void 0 : replacements_1.sort(function (a, b) {
266
+ return b.start - a.start;
267
+ });
268
+ replacements_1 === null || replacements_1 === void 0 ? void 0 : replacements_1.forEach(function (rep) {
269
+ formula_1 = formula_1.substring(0, rep.start) + rep.replacement + formula_1.substring(rep.end);
270
+ });
271
+ cell.f = formula_1;
272
+ }
273
+ }
274
+ });
275
+ });
276
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
277
+ if (item.c === sourceIndex_1) {
278
+ item.c = targetIndex;
279
+ } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
280
+ item.c = item.c - 1;
281
+ } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
282
+ item.c = item.c + 1;
283
+ }
284
+ });
285
+ (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, 'column');
208
286
  });
209
287
  }
210
288
  }
@@ -1,5 +1,5 @@
1
1
  import { useContext, useRef } from "react";
2
- import { fixPositionOnFrozenCells, getSheetIndex, rowLocation, rowLocationByIndex, updateContextWithSheetData } from "@fileverse-dev/fortune-core";
2
+ import { fixPositionOnFrozenCells, getSheetIndex, rowLocation, getFlowdata, rowLocationByIndex, updateContextWithSheetData } from "@fileverse-dev/fortune-core";
3
3
  import WorkbookContext from "../../../context";
4
4
  export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selectedLocationRef) {
5
5
  var DOUBLE_MS = 300;
@@ -103,7 +103,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
103
103
  var createGhost = function createGhost(host) {
104
104
  var el = document.createElement("div");
105
105
  el.style.position = "fixed";
106
- el.style.left = "55px";
106
+ el.style.left = "58px";
107
107
  el.style.width = "".concat(window.innerWidth, "px");
108
108
  el.style.boxSizing = "border-box";
109
109
  el.style.padding = "6px 8px";
@@ -185,6 +185,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
185
185
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
186
186
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
187
187
  setContext(function (draft) {
188
+ var _a, _b;
188
189
  var _sheet = draft.luckysheetfile[sheetIdx_1];
189
190
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
190
191
  var rows = _sheet.data;
@@ -197,6 +198,72 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
197
198
  rows.splice(targetIndex, 0, rowData);
198
199
  _sheet.data = rows;
199
200
  updateContextWithSheetData(draft, _sheet.data);
201
+ console.log("rows", sourceIndex_1);
202
+ var d = getFlowdata(draft);
203
+ d === null || d === void 0 ? void 0 : d.forEach(function (row) {
204
+ row.forEach(function (cell, index) {
205
+ if (cell) {
206
+ var startingIndex = sourceIndex_1 + 1;
207
+ var targetingIndex_1 = targetIndex + 1;
208
+ if (cell.f) {
209
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
210
+ return "".concat(p1).concat(targetingIndex_1);
211
+ });
212
+ }
213
+ var otherAffectedRows = [];
214
+ if (sourceIndex_1 < targetIndex) {
215
+ for (var c = startingIndex + 1; c < targetingIndex_1; c += 1) {
216
+ otherAffectedRows.push({
217
+ source: c,
218
+ target: c - 1
219
+ });
220
+ }
221
+ } else {
222
+ for (var c = targetingIndex_1; c < startingIndex; c += 1) {
223
+ otherAffectedRows.push({
224
+ source: c,
225
+ target: c + 1
226
+ });
227
+ }
228
+ }
229
+ if (cell.f) {
230
+ var formula_1 = cell.f;
231
+ var replacements_1 = [];
232
+ otherAffectedRows.forEach(function (_a) {
233
+ var source = _a.source,
234
+ target = _a.target;
235
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
236
+ var match;
237
+ while ((match = regex.exec(formula_1)) !== null) {
238
+ replacements_1.push({
239
+ start: match.index,
240
+ end: match.index + match[0].length,
241
+ original: match[0],
242
+ replacement: "".concat(match[1]).concat(target)
243
+ });
244
+ }
245
+ });
246
+ replacements_1.sort(function (a, b) {
247
+ return b.start - a.start;
248
+ });
249
+ replacements_1.forEach(function (rep) {
250
+ formula_1 = formula_1.substring(0, rep.start) + rep.replacement + formula_1.substring(rep.end);
251
+ });
252
+ cell.f = formula_1;
253
+ }
254
+ }
255
+ });
256
+ });
257
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
258
+ if (item.r === sourceIndex_1) {
259
+ item.r = targetIndex;
260
+ } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
261
+ item.r = item.r - 1;
262
+ } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
263
+ item.r = item.r + 1;
264
+ }
265
+ });
266
+ (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, 'row');
200
267
  });
201
268
  }
202
269
  }
@@ -12,21 +12,21 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
12
12
  applyOp: (ops: Op[]) => void;
13
13
  getCryptoPrice: typeof getCryptoPrice;
14
14
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
15
- type?: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
15
+ type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
16
16
  }) => any;
17
17
  onboardingActiveCell: (functionName: string) => void;
18
18
  initializeComment: (row: number, column: number) => void;
19
19
  updateSheetLiveQueryList: (subsheetIndex: number, _data: import("@fileverse-dev/fortune-core").LiveQueryData) => void;
20
20
  removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
21
21
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
22
- type?: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
22
+ type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
23
23
  }) => void;
24
24
  setCellError: (row: number, column: number, errorMessage: {
25
25
  title: string;
26
26
  message: string;
27
27
  }) => void;
28
28
  clearCell: (row: number, column: number, options?: api.CommonOptions) => void;
29
- setCellFormat: (row: number, column: number, attr: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?: api.CommonOptions) => void;
29
+ setCellFormat: (row: number, column: number, attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?: api.CommonOptions) => void;
30
30
  autoFillCell: (copyRange: import("@fileverse-dev/fortune-core").SingleRange, applyRange: import("@fileverse-dev/fortune-core").SingleRange, direction: "left" | "right" | "down" | "up") => void;
31
31
  freeze: (type: "column" | "both" | "row", range: {
32
32
  row: number;
@@ -57,7 +57,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
57
57
  getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
58
58
  setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
59
59
  setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
60
- setCellFormatByRange: (attr: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
60
+ setCellFormatByRange: (attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
61
61
  mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
62
62
  cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
63
63
  getAllSheets: () => SheetType[];
@@ -1,4 +1,5 @@
1
1
  import { RefObject } from "react";
2
+ export declare function numberToColumnName(num: number): string;
2
3
  export declare const useColumnDragAndDrop: (containerRef: RefObject<HTMLDivElement | null>, selectedLocationRef: RefObject<any[]>) => {
3
4
  initiateDrag: (clickedColIndex: number, startX: number) => void;
4
5
  getColIndexClicked: (pageX: number, headerEl: HTMLDivElement) => number;
@@ -3,11 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.numberToColumnName = numberToColumnName;
6
7
  exports.useColumnDragAndDrop = void 0;
7
8
  var _react = require("react");
8
9
  var _fortuneCore = require("@fileverse-dev/fortune-core");
9
10
  var _context = _interopRequireDefault(require("../../../context"));
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function numberToColumnName(num) {
13
+ var columnName = '';
14
+ while (num >= 0) {
15
+ var remainder = num % 26;
16
+ columnName = String.fromCharCode(65 + remainder) + columnName;
17
+ num = Math.floor(num / 26) - 1;
18
+ }
19
+ return columnName;
20
+ }
11
21
  var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, selectedLocationRef) {
12
22
  var DOUBLE_CLICK_MS = 300;
13
23
  var START_DRAG_THRESHOLD_PX = 6;
@@ -110,7 +120,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
110
120
  var createGhost = function createGhost(host) {
111
121
  var el = document.createElement("div");
112
122
  el.style.position = "fixed";
113
- el.style.top = "135px";
123
+ el.style.top = "134px";
114
124
  el.style.height = "".concat(window.innerHeight, "px");
115
125
  el.style.boxSizing = "border-box";
116
126
  el.style.padding = "6px 8px";
@@ -192,8 +202,9 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
192
202
  var sourceIndex_1 = dragRef.current.source;
193
203
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
194
204
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
205
+ console.log("sourceIndex", sourceIndex_1);
195
206
  setContext(function (draft) {
196
- var _a, _b;
207
+ var _a, _b, _c, _d;
197
208
  var _sheet = draft.luckysheetfile[sheetIdx_1];
198
209
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
199
210
  var rows = _sheet.data;
@@ -212,6 +223,74 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
212
223
  }
213
224
  _sheet.data = rows;
214
225
  (0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
226
+ var d = (0, _fortuneCore.getFlowdata)(draft);
227
+ d === null || d === void 0 ? void 0 : d.forEach(function (row) {
228
+ row.forEach(function (cell) {
229
+ if (cell) {
230
+ var sourceColName = numberToColumnName(sourceIndex_1);
231
+ var targetColName_1 = numberToColumnName(targetIndex);
232
+ if (cell.f) {
233
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
234
+ if (/^\d+$/.test(p1)) {
235
+ return "".concat(targetColName_1).concat(p1);
236
+ }
237
+ return match;
238
+ });
239
+ }
240
+ var otherAffectedCols = [];
241
+ if (sourceIndex_1 < targetIndex) {
242
+ for (var c = sourceIndex_1 + 1; c < targetIndex; c += 1) {
243
+ otherAffectedCols.push({
244
+ source: numberToColumnName(c),
245
+ target: numberToColumnName(c - 1)
246
+ });
247
+ }
248
+ } else if (sourceIndex_1 > targetIndex) {
249
+ for (var c = targetIndex; c < sourceIndex_1; c += 1) {
250
+ otherAffectedCols.push({
251
+ source: numberToColumnName(c),
252
+ target: numberToColumnName(c + 1)
253
+ });
254
+ }
255
+ }
256
+ if (cell.f) {
257
+ var formula_1 = cell.f;
258
+ var replacements_1 = [];
259
+ otherAffectedCols.forEach(function (col) {
260
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
261
+ var match;
262
+ while ((match = regex.exec(formula_1)) !== null) {
263
+ if (/^\d+$/.test(match[1])) {
264
+ replacements_1.push({
265
+ start: match.index,
266
+ end: match.index + match[0].length,
267
+ original: match[0],
268
+ replacement: "".concat(col.target).concat(match[1])
269
+ });
270
+ }
271
+ }
272
+ });
273
+ replacements_1 === null || replacements_1 === void 0 ? void 0 : replacements_1.sort(function (a, b) {
274
+ return b.start - a.start;
275
+ });
276
+ replacements_1 === null || replacements_1 === void 0 ? void 0 : replacements_1.forEach(function (rep) {
277
+ formula_1 = formula_1.substring(0, rep.start) + rep.replacement + formula_1.substring(rep.end);
278
+ });
279
+ cell.f = formula_1;
280
+ }
281
+ }
282
+ });
283
+ });
284
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
285
+ if (item.c === sourceIndex_1) {
286
+ item.c = targetIndex;
287
+ } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
288
+ item.c = item.c - 1;
289
+ } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
290
+ item.c = item.c + 1;
291
+ }
292
+ });
293
+ (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, 'column');
215
294
  });
216
295
  }
217
296
  }
@@ -110,7 +110,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
110
110
  var createGhost = function createGhost(host) {
111
111
  var el = document.createElement("div");
112
112
  el.style.position = "fixed";
113
- el.style.left = "55px";
113
+ el.style.left = "58px";
114
114
  el.style.width = "".concat(window.innerWidth, "px");
115
115
  el.style.boxSizing = "border-box";
116
116
  el.style.padding = "6px 8px";
@@ -192,6 +192,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
192
192
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
193
193
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
194
194
  setContext(function (draft) {
195
+ var _a, _b;
195
196
  var _sheet = draft.luckysheetfile[sheetIdx_1];
196
197
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
197
198
  var rows = _sheet.data;
@@ -204,6 +205,72 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
204
205
  rows.splice(targetIndex, 0, rowData);
205
206
  _sheet.data = rows;
206
207
  (0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
208
+ console.log("rows", sourceIndex_1);
209
+ var d = (0, _fortuneCore.getFlowdata)(draft);
210
+ d === null || d === void 0 ? void 0 : d.forEach(function (row) {
211
+ row.forEach(function (cell, index) {
212
+ if (cell) {
213
+ var startingIndex = sourceIndex_1 + 1;
214
+ var targetingIndex_1 = targetIndex + 1;
215
+ if (cell.f) {
216
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
217
+ return "".concat(p1).concat(targetingIndex_1);
218
+ });
219
+ }
220
+ var otherAffectedRows = [];
221
+ if (sourceIndex_1 < targetIndex) {
222
+ for (var c = startingIndex + 1; c < targetingIndex_1; c += 1) {
223
+ otherAffectedRows.push({
224
+ source: c,
225
+ target: c - 1
226
+ });
227
+ }
228
+ } else {
229
+ for (var c = targetingIndex_1; c < startingIndex; c += 1) {
230
+ otherAffectedRows.push({
231
+ source: c,
232
+ target: c + 1
233
+ });
234
+ }
235
+ }
236
+ if (cell.f) {
237
+ var formula_1 = cell.f;
238
+ var replacements_1 = [];
239
+ otherAffectedRows.forEach(function (_a) {
240
+ var source = _a.source,
241
+ target = _a.target;
242
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
243
+ var match;
244
+ while ((match = regex.exec(formula_1)) !== null) {
245
+ replacements_1.push({
246
+ start: match.index,
247
+ end: match.index + match[0].length,
248
+ original: match[0],
249
+ replacement: "".concat(match[1]).concat(target)
250
+ });
251
+ }
252
+ });
253
+ replacements_1.sort(function (a, b) {
254
+ return b.start - a.start;
255
+ });
256
+ replacements_1.forEach(function (rep) {
257
+ formula_1 = formula_1.substring(0, rep.start) + rep.replacement + formula_1.substring(rep.end);
258
+ });
259
+ cell.f = formula_1;
260
+ }
261
+ }
262
+ });
263
+ });
264
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
265
+ if (item.r === sourceIndex_1) {
266
+ item.r = targetIndex;
267
+ } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
268
+ item.r = item.r - 1;
269
+ } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
270
+ item.r = item.r + 1;
271
+ }
272
+ });
273
+ (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, 'row');
207
274
  });
208
275
  }
209
276
  }
@@ -12,21 +12,21 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
12
12
  applyOp: (ops: Op[]) => void;
13
13
  getCryptoPrice: typeof getCryptoPrice;
14
14
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
15
- type?: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
15
+ type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
16
16
  }) => any;
17
17
  onboardingActiveCell: (functionName: string) => void;
18
18
  initializeComment: (row: number, column: number) => void;
19
19
  updateSheetLiveQueryList: (subsheetIndex: number, _data: import("@fileverse-dev/fortune-core").LiveQueryData) => void;
20
20
  removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
21
21
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
22
- type?: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
22
+ type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
23
23
  }) => void;
24
24
  setCellError: (row: number, column: number, errorMessage: {
25
25
  title: string;
26
26
  message: string;
27
27
  }) => void;
28
28
  clearCell: (row: number, column: number, options?: api.CommonOptions) => void;
29
- setCellFormat: (row: number, column: number, attr: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?: api.CommonOptions) => void;
29
+ setCellFormat: (row: number, column: number, attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, options?: api.CommonOptions) => void;
30
30
  autoFillCell: (copyRange: import("@fileverse-dev/fortune-core").SingleRange, applyRange: import("@fileverse-dev/fortune-core").SingleRange, direction: "left" | "right" | "down" | "up") => void;
31
31
  freeze: (type: "column" | "both" | "row", range: {
32
32
  row: number;
@@ -57,7 +57,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
57
57
  getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
58
58
  setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
59
59
  setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
60
- setCellFormatByRange: (attr: "error" | "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
60
+ setCellFormatByRange: (attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").SingleRange | import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
61
61
  mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
62
62
  cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
63
63
  getAllSheets: () => SheetType[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.86",
3
+ "version": "1.1.88",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.1.86",
19
+ "@fileverse-dev/fortune-core": "1.1.88",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",