@fileverse-dev/fortune-react 1.1.88 → 1.1.90

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.
@@ -419,7 +419,7 @@ var ContextMenu = function ContextMenu() {
419
419
  });
420
420
  }
421
421
  if (name === "insert-row-above") {
422
- return (selection === null || selection === void 0 ? void 0 : selection.row_select) ? null : ["left"].map(function (dir) {
422
+ return (selection === null || selection === void 0 ? void 0 : selection.column_select) ? null : ["left"].map(function (dir) {
423
423
  return /*#__PURE__*/React.createElement(Menu, {
424
424
  key: "add-row-above-".concat(dir),
425
425
  onClick: function onClick() {
@@ -433,7 +433,7 @@ var ContextMenu = function ContextMenu() {
433
433
  });
434
434
  }
435
435
  if (name === "insert-row") {
436
- return (selection === null || selection === void 0 ? void 0 : selection.row_select) ? null : ["left"].map(function (dir) {
436
+ return (selection === null || selection === void 0 ? void 0 : selection.column_select) ? null : ["left"].map(function (dir) {
437
437
  return /*#__PURE__*/React.createElement(Menu, {
438
438
  key: "add-row-below-".concat(dir),
439
439
  onClick: function onClick() {
@@ -73,6 +73,12 @@ var ColumnHeader = function ColumnHeader() {
73
73
  }]);
74
74
  }, [context, hoverLocation.col_index, refs.globalCache.freezen]);
75
75
  var onMouseDown = useCallback(function (e) {
76
+ if (e.button === 0 && e.target.tagName === "use") {
77
+ var nativeEvent_1 = e.nativeEvent;
78
+ setContext(function (draft) {
79
+ handleColumnHeaderMouseDown(draft, refs.globalCache, nativeEvent_1, containerRef.current, refs.cellInput.current, refs.fxInput.current);
80
+ });
81
+ }
76
82
  if (e.button !== 0) return;
77
83
  var targetEl = e.target;
78
84
  if (targetEl.closest(".fortune-cols-change-size") || targetEl.closest(".fortune-cols-freeze-handle") || targetEl.closest(".header-arrow")) return;
@@ -85,9 +91,9 @@ var ColumnHeader = function ColumnHeader() {
85
91
  draft.luckysheet_scroll_status = true;
86
92
  });
87
93
  } else {
88
- var nativeEvent_1 = e.nativeEvent;
94
+ var nativeEvent_2 = e.nativeEvent;
89
95
  setContext(function (draft) {
90
- handleColumnHeaderMouseDown(draft, refs.globalCache, nativeEvent_1, containerRef.current, refs.cellInput.current, refs.fxInput.current);
96
+ handleColumnHeaderMouseDown(draft, refs.globalCache, nativeEvent_2, containerRef.current, refs.cellInput.current, refs.fxInput.current);
91
97
  });
92
98
  return;
93
99
  }
@@ -2,7 +2,7 @@ import { useContext, useRef } from "react";
2
2
  import { fixPositionOnFrozenCells, getSheetIndex, getFlowdata, colLocation, colLocationByIndex, updateContextWithSheetData } from "@fileverse-dev/fortune-core";
3
3
  import WorkbookContext from "../../../context";
4
4
  export function numberToColumnName(num) {
5
- var columnName = '';
5
+ var columnName = "";
6
6
  while (num >= 0) {
7
7
  var remainder = num % 26;
8
8
  columnName = String.fromCharCode(65 + remainder) + columnName;
@@ -174,7 +174,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
174
174
  var dragOffset = Math.abs(ev.pageX - dragRef.current.startX);
175
175
  if (!isDragActivated(host, dragOffset)) return;
176
176
  var lineLeftPx = computeInsertionFromPageX(ev.pageX).lineLeftPx;
177
- var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 : 120;
177
+ var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 : 80;
178
178
  if (dragRef.current.lineEl) {
179
179
  dragRef.current.lineEl.style.left = "".concat(lineLeftPx, "px");
180
180
  }
@@ -222,7 +222,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
222
222
  var sourceColName = numberToColumnName(sourceIndex_1);
223
223
  var targetColName_1 = numberToColumnName(targetIndex);
224
224
  if (cell.f) {
225
- cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
225
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
226
226
  if (/^\d+$/.test(p1)) {
227
227
  return "".concat(targetColName_1).concat(p1);
228
228
  }
@@ -249,7 +249,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
249
249
  var formula_1 = cell.f;
250
250
  var replacements_1 = [];
251
251
  otherAffectedCols.forEach(function (col) {
252
- var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
252
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
253
253
  var match;
254
254
  while ((match = regex.exec(formula_1)) !== null) {
255
255
  if (/^\d+$/.test(match[1])) {
@@ -273,16 +273,16 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
273
273
  }
274
274
  });
275
275
  });
276
- (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
276
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
277
277
  if (item.c === sourceIndex_1) {
278
278
  item.c = targetIndex;
279
279
  } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
280
- item.c = item.c - 1;
280
+ item.c -= 1;
281
281
  } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
282
- item.c = item.c + 1;
282
+ item.c += 1;
283
283
  }
284
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');
285
+ (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, "column", context.currentSheetId);
286
286
  });
287
287
  }
288
288
  }
@@ -201,12 +201,12 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
201
201
  console.log("rows", sourceIndex_1);
202
202
  var d = getFlowdata(draft);
203
203
  d === null || d === void 0 ? void 0 : d.forEach(function (row) {
204
- row.forEach(function (cell, index) {
204
+ row.forEach(function (cell) {
205
205
  if (cell) {
206
206
  var startingIndex = sourceIndex_1 + 1;
207
207
  var targetingIndex_1 = targetIndex + 1;
208
208
  if (cell.f) {
209
- cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
209
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
210
210
  return "".concat(p1).concat(targetingIndex_1);
211
211
  });
212
212
  }
@@ -232,7 +232,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
232
232
  otherAffectedRows.forEach(function (_a) {
233
233
  var source = _a.source,
234
234
  target = _a.target;
235
- var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
235
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
236
236
  var match;
237
237
  while ((match = regex.exec(formula_1)) !== null) {
238
238
  replacements_1.push({
@@ -254,16 +254,17 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
254
254
  }
255
255
  });
256
256
  });
257
- (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
257
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
258
258
  if (item.r === sourceIndex_1) {
259
259
  item.r = targetIndex;
260
260
  } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
261
- item.r = item.r - 1;
261
+ item.r -= 1;
262
262
  } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
263
- item.r = item.r + 1;
263
+ item.r += 1;
264
264
  }
265
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');
266
+ console.log("_sheet.calcChain", _sheet.calcChain);
267
+ (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
267
268
  });
268
269
  }
269
270
  }
@@ -428,7 +428,7 @@ var ContextMenu = function ContextMenu() {
428
428
  });
429
429
  }
430
430
  if (name === "insert-row-above") {
431
- return (selection === null || selection === void 0 ? void 0 : selection.row_select) ? null : ["left"].map(function (dir) {
431
+ return (selection === null || selection === void 0 ? void 0 : selection.column_select) ? null : ["left"].map(function (dir) {
432
432
  return /*#__PURE__*/_react.default.createElement(_Menu.default, {
433
433
  key: "add-row-above-".concat(dir),
434
434
  onClick: function onClick() {
@@ -442,7 +442,7 @@ var ContextMenu = function ContextMenu() {
442
442
  });
443
443
  }
444
444
  if (name === "insert-row") {
445
- return (selection === null || selection === void 0 ? void 0 : selection.row_select) ? null : ["left"].map(function (dir) {
445
+ return (selection === null || selection === void 0 ? void 0 : selection.column_select) ? null : ["left"].map(function (dir) {
446
446
  return /*#__PURE__*/_react.default.createElement(_Menu.default, {
447
447
  key: "add-row-below-".concat(dir),
448
448
  onClick: function onClick() {
@@ -82,6 +82,12 @@ var ColumnHeader = function ColumnHeader() {
82
82
  }]);
83
83
  }, [context, hoverLocation.col_index, refs.globalCache.freezen]);
84
84
  var onMouseDown = (0, _react.useCallback)(function (e) {
85
+ if (e.button === 0 && e.target.tagName === "use") {
86
+ var nativeEvent_1 = e.nativeEvent;
87
+ setContext(function (draft) {
88
+ (0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache, nativeEvent_1, containerRef.current, refs.cellInput.current, refs.fxInput.current);
89
+ });
90
+ }
85
91
  if (e.button !== 0) return;
86
92
  var targetEl = e.target;
87
93
  if (targetEl.closest(".fortune-cols-change-size") || targetEl.closest(".fortune-cols-freeze-handle") || targetEl.closest(".header-arrow")) return;
@@ -94,9 +100,9 @@ var ColumnHeader = function ColumnHeader() {
94
100
  draft.luckysheet_scroll_status = true;
95
101
  });
96
102
  } else {
97
- var nativeEvent_1 = e.nativeEvent;
103
+ var nativeEvent_2 = e.nativeEvent;
98
104
  setContext(function (draft) {
99
- (0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache, nativeEvent_1, containerRef.current, refs.cellInput.current, refs.fxInput.current);
105
+ (0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache, nativeEvent_2, containerRef.current, refs.cellInput.current, refs.fxInput.current);
100
106
  });
101
107
  return;
102
108
  }
@@ -10,7 +10,7 @@ var _fortuneCore = require("@fileverse-dev/fortune-core");
10
10
  var _context = _interopRequireDefault(require("../../../context"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function numberToColumnName(num) {
13
- var columnName = '';
13
+ var columnName = "";
14
14
  while (num >= 0) {
15
15
  var remainder = num % 26;
16
16
  columnName = String.fromCharCode(65 + remainder) + columnName;
@@ -182,7 +182,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
182
182
  var dragOffset = Math.abs(ev.pageX - dragRef.current.startX);
183
183
  if (!isDragActivated(host, dragOffset)) return;
184
184
  var lineLeftPx = computeInsertionFromPageX(ev.pageX).lineLeftPx;
185
- var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 : 120;
185
+ var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 : 80;
186
186
  if (dragRef.current.lineEl) {
187
187
  dragRef.current.lineEl.style.left = "".concat(lineLeftPx, "px");
188
188
  }
@@ -230,7 +230,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
230
230
  var sourceColName = numberToColumnName(sourceIndex_1);
231
231
  var targetColName_1 = numberToColumnName(targetIndex);
232
232
  if (cell.f) {
233
- cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
233
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
234
234
  if (/^\d+$/.test(p1)) {
235
235
  return "".concat(targetColName_1).concat(p1);
236
236
  }
@@ -257,7 +257,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
257
257
  var formula_1 = cell.f;
258
258
  var replacements_1 = [];
259
259
  otherAffectedCols.forEach(function (col) {
260
- var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
260
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
261
261
  var match;
262
262
  while ((match = regex.exec(formula_1)) !== null) {
263
263
  if (/^\d+$/.test(match[1])) {
@@ -281,16 +281,16 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
281
281
  }
282
282
  });
283
283
  });
284
- (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
284
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
285
285
  if (item.c === sourceIndex_1) {
286
286
  item.c = targetIndex;
287
287
  } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
288
- item.c = item.c - 1;
288
+ item.c -= 1;
289
289
  } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
290
- item.c = item.c + 1;
290
+ item.c += 1;
291
291
  }
292
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');
293
+ (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, "column", context.currentSheetId);
294
294
  });
295
295
  }
296
296
  }
@@ -208,12 +208,12 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
208
208
  console.log("rows", sourceIndex_1);
209
209
  var d = (0, _fortuneCore.getFlowdata)(draft);
210
210
  d === null || d === void 0 ? void 0 : d.forEach(function (row) {
211
- row.forEach(function (cell, index) {
211
+ row.forEach(function (cell) {
212
212
  if (cell) {
213
213
  var startingIndex = sourceIndex_1 + 1;
214
214
  var targetingIndex_1 = targetIndex + 1;
215
215
  if (cell.f) {
216
- cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
216
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
217
217
  return "".concat(p1).concat(targetingIndex_1);
218
218
  });
219
219
  }
@@ -239,7 +239,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
239
239
  otherAffectedRows.forEach(function (_a) {
240
240
  var source = _a.source,
241
241
  target = _a.target;
242
- var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
242
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
243
243
  var match;
244
244
  while ((match = regex.exec(formula_1)) !== null) {
245
245
  replacements_1.push({
@@ -261,16 +261,17 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
261
261
  }
262
262
  });
263
263
  });
264
- (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
264
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
265
265
  if (item.r === sourceIndex_1) {
266
266
  item.r = targetIndex;
267
267
  } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
268
- item.r = item.r - 1;
268
+ item.r -= 1;
269
269
  } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
270
- item.r = item.r + 1;
270
+ item.r += 1;
271
271
  }
272
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');
273
+ console.log("_sheet.calcChain", _sheet.calcChain);
274
+ (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
274
275
  });
275
276
  }
276
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.88",
3
+ "version": "1.1.90",
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.88",
19
+ "@fileverse-dev/fortune-core": "1.1.90",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",