@fileverse-dev/fortune-react 1.1.88 → 1.1.90-hot.1

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
  }
@@ -194,7 +194,6 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
194
194
  var sourceIndex_1 = dragRef.current.source;
195
195
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
196
196
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
197
- console.log("sourceIndex", sourceIndex_1);
198
197
  setContext(function (draft) {
199
198
  var _a, _b, _c, _d;
200
199
  var _sheet = draft.luckysheetfile[sheetIdx_1];
@@ -222,7 +221,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
222
221
  var sourceColName = numberToColumnName(sourceIndex_1);
223
222
  var targetColName_1 = numberToColumnName(targetIndex);
224
223
  if (cell.f) {
225
- cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
224
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
226
225
  if (/^\d+$/.test(p1)) {
227
226
  return "".concat(targetColName_1).concat(p1);
228
227
  }
@@ -249,7 +248,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
249
248
  var formula_1 = cell.f;
250
249
  var replacements_1 = [];
251
250
  otherAffectedCols.forEach(function (col) {
252
- var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
251
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
253
252
  var match;
254
253
  while ((match = regex.exec(formula_1)) !== null) {
255
254
  if (/^\d+$/.test(match[1])) {
@@ -273,16 +272,16 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
273
272
  }
274
273
  });
275
274
  });
276
- (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
275
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
277
276
  if (item.c === sourceIndex_1) {
278
277
  item.c = targetIndex;
279
278
  } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
280
- item.c = item.c - 1;
279
+ item.c -= 1;
281
280
  } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
282
- item.c = item.c + 1;
281
+ item.c += 1;
283
282
  }
284
283
  });
285
- (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, 'column');
284
+ (_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
285
  });
287
286
  }
288
287
  }
@@ -299,7 +298,6 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
299
298
  dragRef.current.startX = startX;
300
299
  dragRef.current.source = clickedColIndex;
301
300
  dragRef.current.active = false;
302
- console.log("initiateDrag", startX);
303
301
  dragRef.current.onDocMove = handleColumnDrag;
304
302
  dragRef.current.onDocUp = handleColumnDragEnd;
305
303
  document.addEventListener("mousemove", handleColumnDrag);
@@ -198,15 +198,14 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
198
198
  rows.splice(targetIndex, 0, rowData);
199
199
  _sheet.data = rows;
200
200
  updateContextWithSheetData(draft, _sheet.data);
201
- console.log("rows", sourceIndex_1);
202
201
  var d = getFlowdata(draft);
203
202
  d === null || d === void 0 ? void 0 : d.forEach(function (row) {
204
- row.forEach(function (cell, index) {
203
+ row.forEach(function (cell) {
205
204
  if (cell) {
206
205
  var startingIndex = sourceIndex_1 + 1;
207
206
  var targetingIndex_1 = targetIndex + 1;
208
207
  if (cell.f) {
209
- cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
208
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
210
209
  return "".concat(p1).concat(targetingIndex_1);
211
210
  });
212
211
  }
@@ -232,7 +231,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
232
231
  otherAffectedRows.forEach(function (_a) {
233
232
  var source = _a.source,
234
233
  target = _a.target;
235
- var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
234
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
236
235
  var match;
237
236
  while ((match = regex.exec(formula_1)) !== null) {
238
237
  replacements_1.push({
@@ -254,16 +253,16 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
254
253
  }
255
254
  });
256
255
  });
257
- (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
256
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
258
257
  if (item.r === sourceIndex_1) {
259
258
  item.r = targetIndex;
260
259
  } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
261
- item.r = item.r - 1;
260
+ item.r -= 1;
262
261
  } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
263
- item.r = item.r + 1;
262
+ item.r += 1;
264
263
  }
265
264
  });
266
- (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, 'row');
265
+ (_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
266
  });
268
267
  }
269
268
  }
@@ -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
  }
@@ -202,7 +202,6 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
202
202
  var sourceIndex_1 = dragRef.current.source;
203
203
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
204
204
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
205
- console.log("sourceIndex", sourceIndex_1);
206
205
  setContext(function (draft) {
207
206
  var _a, _b, _c, _d;
208
207
  var _sheet = draft.luckysheetfile[sheetIdx_1];
@@ -230,7 +229,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
230
229
  var sourceColName = numberToColumnName(sourceIndex_1);
231
230
  var targetColName_1 = numberToColumnName(targetIndex);
232
231
  if (cell.f) {
233
- cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), 'g'), function (match, p1) {
232
+ cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
234
233
  if (/^\d+$/.test(p1)) {
235
234
  return "".concat(targetColName_1).concat(p1);
236
235
  }
@@ -257,7 +256,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
257
256
  var formula_1 = cell.f;
258
257
  var replacements_1 = [];
259
258
  otherAffectedCols.forEach(function (col) {
260
- var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), 'g');
259
+ var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
261
260
  var match;
262
261
  while ((match = regex.exec(formula_1)) !== null) {
263
262
  if (/^\d+$/.test(match[1])) {
@@ -281,16 +280,16 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
281
280
  }
282
281
  });
283
282
  });
284
- (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.map(function (item) {
283
+ (_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
285
284
  if (item.c === sourceIndex_1) {
286
285
  item.c = targetIndex;
287
286
  } else if (item.c > sourceIndex_1 && item.c < targetIndex) {
288
- item.c = item.c - 1;
287
+ item.c -= 1;
289
288
  } else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
290
- item.c = item.c + 1;
289
+ item.c += 1;
291
290
  }
292
291
  });
293
- (_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, 'column');
292
+ (_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
293
  });
295
294
  }
296
295
  }
@@ -307,7 +306,6 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
307
306
  dragRef.current.startX = startX;
308
307
  dragRef.current.source = clickedColIndex;
309
308
  dragRef.current.active = false;
310
- console.log("initiateDrag", startX);
311
309
  dragRef.current.onDocMove = handleColumnDrag;
312
310
  dragRef.current.onDocUp = handleColumnDragEnd;
313
311
  document.addEventListener("mousemove", handleColumnDrag);
@@ -205,15 +205,14 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
205
205
  rows.splice(targetIndex, 0, rowData);
206
206
  _sheet.data = rows;
207
207
  (0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
208
- console.log("rows", sourceIndex_1);
209
208
  var d = (0, _fortuneCore.getFlowdata)(draft);
210
209
  d === null || d === void 0 ? void 0 : d.forEach(function (row) {
211
- row.forEach(function (cell, index) {
210
+ row.forEach(function (cell) {
212
211
  if (cell) {
213
212
  var startingIndex = sourceIndex_1 + 1;
214
213
  var targetingIndex_1 = targetIndex + 1;
215
214
  if (cell.f) {
216
- cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), 'g'), function (match, p1) {
215
+ cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
217
216
  return "".concat(p1).concat(targetingIndex_1);
218
217
  });
219
218
  }
@@ -239,7 +238,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
239
238
  otherAffectedRows.forEach(function (_a) {
240
239
  var source = _a.source,
241
240
  target = _a.target;
242
- var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), 'g');
241
+ var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
243
242
  var match;
244
243
  while ((match = regex.exec(formula_1)) !== null) {
245
244
  replacements_1.push({
@@ -261,16 +260,16 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
261
260
  }
262
261
  });
263
262
  });
264
- (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.map(function (item) {
263
+ (_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
265
264
  if (item.r === sourceIndex_1) {
266
265
  item.r = targetIndex;
267
266
  } else if (item.r > sourceIndex_1 && item.r < targetIndex) {
268
- item.r = item.r - 1;
267
+ item.r -= 1;
269
268
  } else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
270
- item.r = item.r + 1;
269
+ item.r += 1;
271
270
  }
272
271
  });
273
- (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, 'row');
272
+ (_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
273
  });
275
274
  }
276
275
  }
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-hot.1",
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",