@fileverse-dev/fortune-react 1.3.10 → 1.3.11-mixed

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.
Files changed (27) hide show
  1. package/es/components/ConditionFormat/ConditionRules.js +15 -5
  2. package/es/components/ConditionFormat/index.js +3 -0
  3. package/es/components/DataVerification/ColorPicker.js +1 -1
  4. package/es/components/SheetOverlay/InputBox.js +112 -75
  5. package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +25 -1
  6. package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +26 -2
  7. package/es/components/SheetOverlay/index.css +6 -0
  8. package/es/components/SheetOverlay/index.js +3 -3
  9. package/es/components/Toolbar/index.js +17 -12
  10. package/es/components/Workbook/api.d.ts +3 -0
  11. package/es/components/Workbook/index.d.ts +3 -0
  12. package/es/components/Workbook/index.js +146 -10
  13. package/es/utils/convertCellsToCrypto.js +17 -0
  14. package/lib/components/ConditionFormat/ConditionRules.js +15 -5
  15. package/lib/components/ConditionFormat/index.js +3 -0
  16. package/lib/components/DataVerification/ColorPicker.js +1 -1
  17. package/lib/components/SheetOverlay/InputBox.js +111 -74
  18. package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +25 -1
  19. package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +26 -2
  20. package/lib/components/SheetOverlay/index.css +6 -0
  21. package/lib/components/SheetOverlay/index.js +3 -3
  22. package/lib/components/Toolbar/index.js +16 -11
  23. package/lib/components/Workbook/api.d.ts +3 -0
  24. package/lib/components/Workbook/index.d.ts +3 -0
  25. package/lib/components/Workbook/index.js +146 -10
  26. package/lib/utils/convertCellsToCrypto.js +17 -0
  27. package/package.json +2 -2
@@ -294,6 +294,10 @@ var ConditionRules = function ConditionRules(_a) {
294
294
  text: "textContains",
295
295
  value: "()",
296
296
  label: "Text Contains"
297
+ }, {
298
+ text: "empty",
299
+ value: "",
300
+ label: "Empty"
297
301
  }, {
298
302
  text: "occurrenceDate",
299
303
  value: conditionformat.yesterday,
@@ -334,7 +338,7 @@ var ConditionRules = function ConditionRules(_a) {
334
338
  marginBottom: "16px"
335
339
  }
336
340
  }, matchedConditionFormatKey.map(function (key) {
337
- var _a, _b;
341
+ var _a, _b, _c;
338
342
  return /*#__PURE__*/React.createElement("div", {
339
343
  onClick: function onClick() {
340
344
  var _a;
@@ -385,10 +389,10 @@ var ConditionRules = function ConditionRules(_a) {
385
389
  }, /*#__PURE__*/React.createElement("h3", {
386
390
  className: "fortune-condition-rules__heading condition-list-type",
387
391
  "data-testid": "condition-rules-heading-".concat(key)
388
- }, conditionformat[allConditionFormats[key].conditionName], " ", (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]), /*#__PURE__*/React.createElement("p", {
392
+ }, conditionformat[allConditionFormats[key].conditionName], allConditionFormats[key].conditionName !== "empty" && " ".concat((_b = (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : "")), /*#__PURE__*/React.createElement("p", {
389
393
  className: "fortune-condition-rules__para condition-list-range",
390
394
  "data-testid": "condition-rules-para-".concat(key)
391
- }, (_b = allConditionFormats[key].cellrange) === null || _b === void 0 ? void 0 : _b.map(function (range) {
395
+ }, (_c = allConditionFormats[key].cellrange) === null || _c === void 0 ? void 0 : _c.map(function (range) {
392
396
  var startCol = numberToColumn(range.column[0] + 1);
393
397
  var endCol = numberToColumn(range.column[1] + 1);
394
398
  var startRow = range.row[0] + 1;
@@ -467,6 +471,12 @@ var ConditionRules = function ConditionRules(_a) {
467
471
  }, "Format cells if"), /*#__PURE__*/React.createElement(Select, {
468
472
  value: type,
469
473
  onValueChange: function onValueChange(value) {
474
+ if (value === "empty" || type === "empty") {
475
+ setContext(function (ctx) {
476
+ ctx.conditionRules.rulesValue = "";
477
+ });
478
+ setEditConditionFormatValue(null);
479
+ }
470
480
  setType(value);
471
481
  }
472
482
  }, /*#__PURE__*/React.createElement(SelectTrigger, null, /*#__PURE__*/React.createElement(SelectValue, null, /*#__PURE__*/React.createElement("div", {
@@ -804,7 +814,7 @@ var ConditionRules = function ConditionRules(_a) {
804
814
  },
805
815
  tabIndex: 0
806
816
  }, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/React.createElement(Button, {
807
- disabled: context.conditionRules.rulesValue === "",
817
+ disabled: context.conditionRules.rulesValue === "" && type !== "empty",
808
818
  variant: "default",
809
819
  style: {
810
820
  minWidth: "80px"
@@ -814,7 +824,7 @@ var ConditionRules = function ConditionRules(_a) {
814
824
  },
815
825
  tabIndex: 0
816
826
  }, "Update rule")) : (/*#__PURE__*/React.createElement(Button, {
817
- disabled: context.conditionRules.rulesValue === "",
827
+ disabled: context.conditionRules.rulesValue === "" && type !== "empty",
818
828
  variant: "default",
819
829
  style: {
820
830
  minWidth: "80px"
@@ -107,6 +107,9 @@ var ConditionalFormat = function ConditionalFormat(_a) {
107
107
  }, {
108
108
  text: "textContains",
109
109
  value: "()"
110
+ }, {
111
+ text: "empty",
112
+ value: ""
110
113
  }, {
111
114
  text: "occurrenceDate",
112
115
  value: conditionformat.yesterday
@@ -6,7 +6,7 @@ export var TEXT_COLORS = [{
6
6
  value: "228, 232, 237"
7
7
  }, {
8
8
  name: "White",
9
- value: "249, 249, 249"
9
+ value: "219, 233, 236"
10
10
  }, {
11
11
  name: "Pink",
12
12
  value: "244, 217, 227"
@@ -17,50 +17,50 @@ import ContentEditable from "./ContentEditable";
17
17
  import FormulaSearch from "./FormulaSearch";
18
18
  import FormulaHint from "./FormulaHint";
19
19
  import usePrevious from "../../hooks/usePrevious";
20
- import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, incrementColumn, decrementColumn, incrementRow, decrementRow, countCommasBeforeCursor } from "./helper";
20
+ import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, countCommasBeforeCursor } from "./helper";
21
21
  import { LucideIcon } from "./LucideIcon";
22
22
  var InputBox = function InputBox() {
23
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
24
- var _m = useContext(WorkbookContext),
25
- context = _m.context,
26
- setContext = _m.setContext,
27
- refs = _m.refs;
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
24
+ var _p = useContext(WorkbookContext),
25
+ context = _p.context,
26
+ setContext = _p.setContext,
27
+ refs = _p.refs;
28
28
  var inputRef = useRef(null);
29
29
  var lastKeyDownEventRef = useRef(null);
30
30
  var prevCellUpdate = usePrevious(context.luckysheetCellUpdate);
31
31
  var prevSheetId = usePrevious(context.currentSheetId);
32
- var _o = useState(false),
33
- isHidenRC = _o[0],
34
- setIsHidenRC = _o[1];
35
- var _p = useState(false),
36
- isInputBoxActive = _p[0],
37
- setIsInputBoxActive = _p[1];
38
- var _q = useState(""),
39
- activeCell = _q[0],
40
- setActiveCell = _q[1];
41
- var _r = useState(""),
42
- activeRefCell = _r[0],
43
- setActiveRefCell = _r[1];
44
- var _s = useState({
32
+ var _q = useState(false),
33
+ isHidenRC = _q[0],
34
+ setIsHidenRC = _q[1];
35
+ var _r = useState(false),
36
+ isInputBoxActive = _r[0],
37
+ setIsInputBoxActive = _r[1];
38
+ var _s = useState(""),
39
+ activeCell = _s[0],
40
+ setActiveCell = _s[1];
41
+ var _t = useState(""),
42
+ activeRefCell = _t[0],
43
+ setActiveRefCell = _t[1];
44
+ var _u = useState({
45
45
  left: 0,
46
46
  top: 0
47
47
  }),
48
- frozenPosition = _s[0],
49
- setFrozenPosition = _s[1];
48
+ frozenPosition = _u[0],
49
+ setFrozenPosition = _u[1];
50
50
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
51
- var _t = useState({}),
52
- firstSelectionActiveCell = _t[0],
53
- setFirstSelectionActiveCell = _t[1];
54
- var _u = useState(0),
55
- commaCount = _u[0],
56
- setCommaCount = _u[1];
51
+ var _v = useState({}),
52
+ firstSelectionActiveCell = _v[0],
53
+ setFirstSelectionActiveCell = _v[1];
54
+ var _w = useState(0),
55
+ commaCount = _w[0],
56
+ setCommaCount = _w[1];
57
57
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
58
- var _v = useState(!hideFormulaHintLocal),
59
- showFormulaHint = _v[0],
60
- setShowFormulaHint = _v[1];
61
- var _w = useState(false),
62
- showSearchHint = _w[0],
63
- setShowSearchHint = _w[1];
58
+ var _x = useState(!hideFormulaHintLocal),
59
+ showFormulaHint = _x[0],
60
+ setShowFormulaHint = _x[1];
61
+ var _y = useState(false),
62
+ showSearchHint = _y[0],
63
+ setShowSearchHint = _y[1];
64
64
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
65
65
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
66
66
  var preText = useRef("");
@@ -68,9 +68,9 @@ var InputBox = function InputBox() {
68
68
  var isComposingRef = useRef(false);
69
69
  var ZWSP = "\u200B";
70
70
  var inputBoxInnerRef = useRef(null);
71
- var _x = useState([]),
72
- linkSelectionHighlightRects = _x[0],
73
- setLinkSelectionHighlightRects = _x[1];
71
+ var _z = useState([]),
72
+ linkSelectionHighlightRects = _z[0],
73
+ setLinkSelectionHighlightRects = _z[1];
74
74
  var ensureNotEmpty = function ensureNotEmpty() {
75
75
  var el = inputRef.current;
76
76
  if (!el) return;
@@ -106,7 +106,7 @@ var InputBox = function InputBox() {
106
106
  return style;
107
107
  }
108
108
  return {};
109
- }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, (_b = context === null || context === void 0 ? void 0 : context.luckysheetCellUpdate) === null || _b === void 0 ? void 0 : _b.length, firstSelectionActiveCell]);
109
+ }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, (_b = context === null || context === void 0 ? void 0 : context.luckysheetCellUpdate) === null || _b === void 0 ? void 0 : _b.length, firstSelectionActiveCell, (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.innerText]);
110
110
  useLayoutEffect(function () {
111
111
  var _a;
112
112
  if (!context.allowEdit) {
@@ -129,6 +129,8 @@ var InputBox = function InputBox() {
129
129
  var flowdata = getFlowdata(context);
130
130
  var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
131
131
  var value_1 = "";
132
+ var wasOverwrite = refs.globalCache.overwriteCell;
133
+ var overwriteFirstChar = refs.globalCache.overwriteCellFirstChar;
132
134
  if (cell && !refs.globalCache.overwriteCell) {
133
135
  if (isInlineStringCell(cell)) {
134
136
  value_1 = getInlineStringHTML(row_index, col_index, flowdata);
@@ -145,9 +147,15 @@ var InputBox = function InputBox() {
145
147
  }
146
148
  }
147
149
  refs.globalCache.overwriteCell = false;
148
- if (!refs.globalCache.ignoreWriteCell && inputRef.current && value_1) {
150
+ delete refs.globalCache.overwriteCellFirstChar;
151
+ if (wasOverwrite && inputRef.current) {
152
+ inputRef.current.innerText = overwriteFirstChar !== null && overwriteFirstChar !== void 0 ? overwriteFirstChar : "";
153
+ if (overwriteFirstChar) {
154
+ moveToEnd(inputRef.current);
155
+ }
156
+ } else if (!refs.globalCache.ignoreWriteCell && inputRef.current && value_1) {
149
157
  inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
150
- } else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1) {
158
+ } else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1 && !wasOverwrite) {
151
159
  var valueD = getCellValue(row_index, col_index, flowdata, "f");
152
160
  inputRef.current.innerText = valueD;
153
161
  }
@@ -175,7 +183,7 @@ var InputBox = function InputBox() {
175
183
  if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _.isEmpty(context.luckysheetCellUpdate)) {
176
184
  setIsInputBoxActive(false);
177
185
  }
178
- }, [firstSelection, (_c = context.rangeDialog) === null || _c === void 0 ? void 0 : _c.show, context.luckysheetCellUpdate]);
186
+ }, [firstSelection, (_d = context.rangeDialog) === null || _d === void 0 ? void 0 : _d.show, context.luckysheetCellUpdate]);
179
187
  var getActiveFormula = useCallback(function () {
180
188
  return document.querySelector(".luckysheet-formula-search-item-active");
181
189
  }, []);
@@ -270,6 +278,54 @@ var InputBox = function InputBox() {
270
278
  event.stopPropagation();
271
279
  event.preventDefault();
272
280
  };
281
+ useEffect(function () {
282
+ var _a, _b;
283
+ var selection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
284
+ var editor = inputRef.current;
285
+ if (!selection || !editor || !isInputBoxActive || ((_b = context.rangeDialog) === null || _b === void 0 ? void 0 : _b.show)) {
286
+ return;
287
+ }
288
+ var rowSel = selection.row;
289
+ var colSel = selection.column;
290
+ if (!rowSel || !colSel || rowSel.length < 2 || colSel.length < 2) return;
291
+ var rowStart = Math.min(rowSel[0], rowSel[1]);
292
+ var rowEnd = Math.max(rowSel[0], rowSel[1]);
293
+ var colStart = Math.min(colSel[0], colSel[1]);
294
+ var colEnd = Math.max(colSel[0], colSel[1]);
295
+ var startRef = "".concat(indexToColumnChar(colStart)).concat(rowStart + 1);
296
+ var endRef = "".concat(indexToColumnChar(colEnd)).concat(rowEnd + 1);
297
+ var refText = startRef === endRef ? startRef : "".concat(startRef, ":").concat(endRef);
298
+ var editorText = editor.innerText || "";
299
+ if (!editorText.startsWith("=")) return;
300
+ var spans = editor.querySelectorAll("span");
301
+ var lastSpan = spans[spans.length - 1];
302
+ var lastSpanText = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) || "";
303
+ var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
304
+ var notFunctionInit = !editorText.includes("(");
305
+ var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_.includes(["="], lastSpanText);
306
+ var shouldHandleRef = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) || isLetterNumberPattern(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText);
307
+ if (!shouldHandleRef) return;
308
+ var refSpanHtml = "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">".concat(refText, "</span>");
309
+ if (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) {
310
+ if (lastSpan.textContent !== refText) lastSpan.textContent = refText;
311
+ setTimeout(function () {
312
+ return moveCursorToEnd(editor);
313
+ }, 1);
314
+ return;
315
+ }
316
+ if (isLetterNumberPattern(lastSpanText) || isA1RangePattern) {
317
+ var htmlR = removeLastSpan(editor.innerHTML);
318
+ editor.innerHTML = "".concat(htmlR).concat(refSpanHtml);
319
+ setTimeout(function () {
320
+ return moveCursorToEnd(editor);
321
+ }, 1);
322
+ return;
323
+ }
324
+ editor.innerHTML = "".concat(editor.innerHTML).concat(refSpanHtml);
325
+ setTimeout(function () {
326
+ return moveCursorToEnd(editor);
327
+ }, 1);
328
+ }, [context.luckysheet_select_save, (_e = context.rangeDialog) === null || _e === void 0 ? void 0 : _e.show, isInputBoxActive]);
273
329
  var onKeyDown = useCallback(function (e) {
274
330
  var _a, _b;
275
331
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
@@ -302,37 +358,18 @@ var InputBox = function InputBox() {
302
358
  }, 5);
303
359
  }
304
360
  }
305
- var refCell = placeRef.current;
306
- if (e.key === "ArrowUp") {
307
- refCell = decrementRow(placeRef.current);
308
- } else if (e.key === "ArrowDown") {
309
- refCell = incrementRow(placeRef.current);
310
- } else if (e.key === "ArrowLeft") {
311
- refCell = decrementColumn(placeRef.current);
312
- } else if (e.key === "ArrowRight") {
313
- refCell = incrementColumn(placeRef.current);
314
- }
315
- if ((e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") && !(getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
316
- var parser = new DOMParser();
317
- var doc = parser.parseFromString("<div>".concat((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML, "</div>"), "text/html");
318
- var spans = doc.querySelectorAll("span");
319
- var lastSpan = spans[spans.length - 1];
320
- var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
321
- var arrowRefNotAllowed = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !_.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText);
322
- if (((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "(" || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "," || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(":")) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== ")") && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('"')) && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !arrowRefNotAllowed && !/^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
323
- allowListNavigation = false;
324
- inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
325
- setTimeout(function () {
326
- moveCursorToEnd(inputRef.current);
327
- }, 1);
328
- }
329
- if (isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
361
+ var isArrowKey = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight";
362
+ if (isArrowKey && !(getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
363
+ var editorText = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
364
+ var lastSpanText = getLastInputSpanText() || "";
365
+ var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
366
+ var notFunctionInit = !editorText.includes("(");
367
+ var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_.includes(["="], lastSpanText);
368
+ var shouldTreatAsRefNavigation = editorText.startsWith("=") && (Boolean((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(".fortune-formula-functionrange-cell")) || isLetterNumberPattern(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText));
369
+ if (shouldTreatAsRefNavigation) {
330
370
  allowListNavigation = false;
331
- var htmlR = removeLastSpan(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerHTML);
332
- inputRef.current.innerHTML = "".concat(htmlR, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
333
- moveCursorToEnd(inputRef.current);
334
371
  setTimeout(function () {
335
- moveCursorToEnd(inputRef.current);
372
+ if (inputRef.current) moveCursorToEnd(inputRef.current);
336
373
  }, 1);
337
374
  }
338
375
  }
@@ -390,7 +427,7 @@ var InputBox = function InputBox() {
390
427
  }
391
428
  e.preventDefault();
392
429
  }
393
- }, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext, firstSelection]);
430
+ }, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext]);
394
431
  var handleHideShowHint = function handleHideShowHint() {
395
432
  var _a, _b, _c, _d;
396
433
  var searchElFx = (_a = document.getElementsByClassName("fx-search")) === null || _a === void 0 ? void 0 : _a[0];
@@ -480,7 +517,7 @@ var InputBox = function InputBox() {
480
517
  zIndex: _.isEmpty(context.luckysheetCellUpdate) ? -1 : 19,
481
518
  display: "block"
482
519
  };
483
- }, [firstSelection, (_d = context.rangeDialog) === null || _d === void 0 ? void 0 : _d.show, context.luckysheetCellUpdate, refs.cellArea, isInputBoxActive, frozenPosition, context.scrollLeft, context.scrollTop]);
520
+ }, [firstSelection, (_f = context.rangeDialog) === null || _f === void 0 ? void 0 : _f.show, context.luckysheetCellUpdate, refs.cellArea, isInputBoxActive, frozenPosition, context.scrollLeft, context.scrollTop]);
484
521
  useEffect(function () {
485
522
  var _a;
486
523
  if (firstSelection && !((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) && !isInputBoxActive && !_.isEmpty(context.luckysheetCellUpdate)) {
@@ -496,7 +533,7 @@ var InputBox = function InputBox() {
496
533
  setIsInputBoxActive(true);
497
534
  }
498
535
  }
499
- }, [firstSelection, (_e = context.rangeDialog) === null || _e === void 0 ? void 0 : _e.show, context.luckysheetCellUpdate, isInputBoxActive, context.scrollLeft, context.scrollTop, refs.cellArea]);
536
+ }, [firstSelection, (_g = context.rangeDialog) === null || _g === void 0 ? void 0 : _g.show, context.luckysheetCellUpdate, isInputBoxActive, context.scrollLeft, context.scrollTop, refs.cellArea]);
500
537
  var getAddressIndicatorPosition = useCallback(function () {
501
538
  var _a;
502
539
  if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show)) {
@@ -509,7 +546,7 @@ var InputBox = function InputBox() {
509
546
  left: "0",
510
547
  display: "block"
511
548
  };
512
- }, [firstSelection, (_f = context.rangeDialog) === null || _f === void 0 ? void 0 : _f.show]);
549
+ }, [firstSelection, (_h = context.rangeDialog) === null || _h === void 0 ? void 0 : _h.show]);
513
550
  var getCellAddress = useCallback(function () {
514
551
  if (!firstSelection) return "";
515
552
  var rowIndex = firstSelection.row_focus || 0;
@@ -559,7 +596,7 @@ var InputBox = function InputBox() {
559
596
  };
560
597
  });
561
598
  setLinkSelectionHighlightRects(relative);
562
- }, [(_g = context.linkCard) === null || _g === void 0 ? void 0 : _g.applyToSelection, (_h = context.linkCard) === null || _h === void 0 ? void 0 : _h.selectionOffsets, (_j = context.linkCard) === null || _j === void 0 ? void 0 : _j.r, (_k = context.linkCard) === null || _k === void 0 ? void 0 : _k.c, context.luckysheetCellUpdate]);
599
+ }, [(_j = context.linkCard) === null || _j === void 0 ? void 0 : _j.applyToSelection, (_k = context.linkCard) === null || _k === void 0 ? void 0 : _k.selectionOffsets, (_l = context.linkCard) === null || _l === void 0 ? void 0 : _l.r, (_m = context.linkCard) === null || _m === void 0 ? void 0 : _m.c, context.luckysheetCellUpdate]);
563
600
  var wraperGetCell = function wraperGetCell() {
564
601
  var cell = getCellAddress();
565
602
  placeRef.current = cell;
@@ -596,7 +633,7 @@ var InputBox = function InputBox() {
596
633
  onMouseUp: function onMouseUp(e) {
597
634
  return e.stopPropagation();
598
635
  }
599
- }, firstSelection && !((_l = context.rangeDialog) === null || _l === void 0 ? void 0 : _l.show) && (/*#__PURE__*/React.createElement("div", {
636
+ }, firstSelection && !((_o = context.rangeDialog) === null || _o === void 0 ? void 0 : _o.show) && (/*#__PURE__*/React.createElement("div", {
600
637
  className: "luckysheet-cell-address-indicator",
601
638
  style: getAddressIndicatorPosition()
602
639
  }, wraperGetCell())), /*#__PURE__*/React.createElement("div", {
@@ -211,7 +211,7 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
211
211
  var sheetIdx_1 = getSheetIndex(context, context.currentSheetId);
212
212
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
213
213
  setContext(function (draft) {
214
- var _a, _b, _c, _d, _e, _f, _g;
214
+ var _a, _b, _c, _d, _e, _f, _g, _h;
215
215
  var _sheet = draft.luckysheetfile[sheetIdx_1];
216
216
  if (!(_sheet === null || _sheet === void 0 ? void 0 : _sheet.data)) return;
217
217
  var rows = _sheet.data;
@@ -374,6 +374,30 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
374
374
  }
375
375
  });
376
376
  (_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);
377
+ var cellChanges = [];
378
+ var affectedColStart = Math.min(sourceIndex_1, targetIndex);
379
+ var affectedColEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceCol.length - 1;
380
+ var numRows = rows.length;
381
+ for (var r = 0; r < numRows; r += 1) {
382
+ var row = rows[r];
383
+ for (var c = affectedColStart; c <= affectedColEnd; c += 1) {
384
+ var cell = row === null || row === void 0 ? void 0 : row[c];
385
+ cellChanges.push({
386
+ sheetId: draft.currentSheetId,
387
+ path: ["celldata"],
388
+ value: {
389
+ r: r,
390
+ c: c,
391
+ v: cell !== null && cell !== void 0 ? cell : null
392
+ },
393
+ key: "".concat(r, "_").concat(c),
394
+ type: "update"
395
+ });
396
+ }
397
+ }
398
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
399
+ draft.hooks.updateCellYdoc(cellChanges);
400
+ }
377
401
  var rowLen = (d === null || d === void 0 ? void 0 : d.length) || 0;
378
402
  api.setSelection(draft, [{
379
403
  row: [0, rowLen],
@@ -207,7 +207,7 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
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, _f;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
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;
@@ -364,7 +364,31 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
364
364
  }
365
365
  });
366
366
  (_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);
367
- var colLen = ((_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) || 0;
367
+ var cellChanges = [];
368
+ var affectedRowStart = Math.min(sourceIndex_1, targetIndex);
369
+ var affectedRowEnd = Math.max(sourceIndex_1, targetIndex) + selectedSourceRow.length - 1;
370
+ var numCols = (_g = (_f = d === null || d === void 0 ? void 0 : d[0]) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
371
+ for (var r = affectedRowStart; r <= affectedRowEnd; r += 1) {
372
+ var row = rows[r];
373
+ for (var c = 0; c < numCols; c += 1) {
374
+ var cell = row === null || row === void 0 ? void 0 : row[c];
375
+ cellChanges.push({
376
+ sheetId: draft.currentSheetId,
377
+ path: ["celldata"],
378
+ value: {
379
+ r: r,
380
+ c: c,
381
+ v: cell !== null && cell !== void 0 ? cell : null
382
+ },
383
+ key: "".concat(r, "_").concat(c),
384
+ type: "update"
385
+ });
386
+ }
387
+ }
388
+ if (cellChanges.length > 0 && ((_h = draft.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
389
+ draft.hooks.updateCellYdoc(cellChanges);
390
+ }
391
+ var colLen = ((_j = d === null || d === void 0 ? void 0 : d[0]) === null || _j === void 0 ? void 0 : _j.length) || 0;
368
392
  api.setSelection(draft, [{
369
393
  row: [selectedTargetRow[0], selectedTargetRow[selectedTargetRow.length - 1]],
370
394
  column: [0, colLen]
@@ -830,6 +830,12 @@
830
830
  cursor: se-resize;
831
831
  }
832
832
 
833
+ /* FLV: show blue dashed border for active selection while in edit mode */
834
+ .luckysheet-cell-selected-edit-mode .luckysheet-cs-inner-border {
835
+ border: 2px dashed #12a5ff;
836
+ border-radius: 1px;
837
+ }
838
+
833
839
  .fortune-formula-functionrange-highlight .luckysheet-highlight {
834
840
  position: absolute;
835
841
  z-index: 19;
@@ -375,18 +375,18 @@ var SheetOverlay = function SheetOverlay() {
375
375
  }), ((_h = (_g = context.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) > 0 && (/*#__PURE__*/React.createElement("div", {
376
376
  id: "luckysheet-cell-selected-boxs"
377
377
  }, context.luckysheet_select_save.map(function (selection, index) {
378
- var _a, _b;
378
+ var _a, _b, _c, _d;
379
379
  return /*#__PURE__*/React.createElement("div", {
380
380
  key: index,
381
381
  id: "luckysheet-cell-selected",
382
- className: "luckysheet-cell-selected",
382
+ className: "luckysheet-cell-selected".concat(((_b = (_a = context.luckysheetCellUpdate) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? " luckysheet-cell-selected-edit-mode" : ""),
383
383
  style: _.assign({
384
384
  left: selection.left_move,
385
385
  top: selection.top_move,
386
386
  width: selection.width_move ? selection.width_move - 1.8 : selection.width_move,
387
387
  height: selection.height_move ? selection.height_move - 1.8 : selection.height_move,
388
388
  display: "block"
389
- }, fixRowStyleOverflowInFreeze(context, selection.row[0], selection.row[1], (_a = refs.globalCache.freezen) === null || _a === void 0 ? void 0 : _a[context.currentSheetId]), fixColumnStyleOverflowInFreeze(context, selection.column[0], selection.column[1], (_b = refs.globalCache.freezen) === null || _b === void 0 ? void 0 : _b[context.currentSheetId])),
389
+ }, fixRowStyleOverflowInFreeze(context, selection.row[0], selection.row[1], (_c = refs.globalCache.freezen) === null || _c === void 0 ? void 0 : _c[context.currentSheetId]), fixColumnStyleOverflowInFreeze(context, selection.column[0], selection.column[1], (_d = refs.globalCache.freezen) === null || _d === void 0 ? void 0 : _d[context.currentSheetId])),
390
390
  onMouseDown: function onMouseDown(e) {
391
391
  e.stopPropagation();
392
392
  var nativeEvent = e.nativeEvent;
@@ -123,7 +123,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
123
123
  return to.concat(ar || Array.prototype.slice.call(from));
124
124
  };
125
125
  import React, { useContext, useCallback, useRef, useEffect, useState } from "react";
126
- import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart, api, getSheetIndex } from "@fileverse-dev/fortune-core";
126
+ import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart, api, getSheetIndex, is_date } from "@fileverse-dev/fortune-core";
127
127
  import _ from "lodash";
128
128
  import { IconButton, LucideIcon, Tooltip, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@fileverse/ui";
129
129
  import DataVerificationPortal from "./dataVerificationPortal";
@@ -649,7 +649,7 @@ var Toolbar = function Toolbar(_a) {
649
649
  }
650
650
  }, [cell, refs.globalCache]);
651
651
  var getToolbarItem = useCallback(function (name, i) {
652
- var _a, _b, _c, _d, _e, _f, _g;
652
+ var _a, _b, _c, _d, _e, _f;
653
653
  var tooltip = toolbar[name];
654
654
  if (name === "|") {
655
655
  return /*#__PURE__*/React.createElement(Divider, {
@@ -714,10 +714,15 @@ var Toolbar = function Toolbar(_a) {
714
714
  return v.value === (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa);
715
715
  });
716
716
  if ((curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) != null) {
717
- if (format != null) {
718
- currentFmt_1 = format.text;
719
- } else if (((_a = curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === null || _a === void 0 ? void 0 : _a.includes("#,##0")) || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0" || (curr_2 === null || curr_2 === void 0 ? void 0 : curr_2.fa) === "0.00") {
717
+ var hasTime = /[hH]:/.test(curr_2.fa);
718
+ if (curr_2.t === "d") {
719
+ currentFmt_1 = hasTime ? "Date time" : "Date";
720
+ } else if (curr_2.t === "n" || curr_2.fa.includes("#,##0") || curr_2.fa === "0" || curr_2.fa === "0.00") {
720
721
  currentFmt_1 = "Number";
722
+ } else if (is_date(curr_2.fa)) {
723
+ currentFmt_1 = hasTime ? "Date time" : "Date";
724
+ } else if (format != null) {
725
+ currentFmt_1 = format.text;
721
726
  } else {
722
727
  currentFmt_1 = defaultFormat[defaultFormat.length - 1].text;
723
728
  }
@@ -872,9 +877,9 @@ var Toolbar = function Toolbar(_a) {
872
877
  value: 2
873
878
  }];
874
879
  return /*#__PURE__*/React.createElement(Combo, {
875
- iconId: ((_b = _.find(items_1, function (item) {
880
+ iconId: ((_a = _.find(items_1, function (item) {
876
881
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.ht);
877
- })) === null || _b === void 0 ? void 0 : _b.title) || "align-left",
882
+ })) === null || _a === void 0 ? void 0 : _a.title) || "align-left",
878
883
  key: name,
879
884
  tooltip: toolbar.horizontalAlign,
880
885
  showArrow: false
@@ -924,9 +929,9 @@ var Toolbar = function Toolbar(_a) {
924
929
  value: 2
925
930
  }];
926
931
  return /*#__PURE__*/React.createElement(Combo, {
927
- iconId: ((_c = _.find(items_2, function (item) {
932
+ iconId: ((_b = _.find(items_2, function (item) {
928
933
  return "".concat(item.value) === "".concat(cell === null || cell === void 0 ? void 0 : cell.vt);
929
- })) === null || _c === void 0 ? void 0 : _c.title) || "align-top",
934
+ })) === null || _b === void 0 ? void 0 : _b.title) || "align-top",
930
935
  key: name,
931
936
  tooltip: toolbar.verticalAlign,
932
937
  showArrow: false
@@ -1167,7 +1172,7 @@ var Toolbar = function Toolbar(_a) {
1167
1172
  });
1168
1173
  }
1169
1174
  if (name === "comment") {
1170
- var last = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[context.luckysheet_select_save.length - 1];
1175
+ var last = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[context.luckysheet_select_save.length - 1];
1171
1176
  var row_index_1 = last === null || last === void 0 ? void 0 : last.row_focus;
1172
1177
  var col_index_1 = last === null || last === void 0 ? void 0 : last.column_focus;
1173
1178
  if (!last) {
@@ -1182,7 +1187,7 @@ var Toolbar = function Toolbar(_a) {
1182
1187
  }
1183
1188
  }
1184
1189
  var itemData_1;
1185
- if (((_f = (_e = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _e === void 0 ? void 0 : _e[col_index_1]) === null || _f === void 0 ? void 0 : _f.ps) != null) {
1190
+ if (((_e = (_d = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index_1]) === null || _d === void 0 ? void 0 : _d[col_index_1]) === null || _e === void 0 ? void 0 : _e.ps) != null) {
1186
1191
  itemData_1 = [{
1187
1192
  key: "edit",
1188
1193
  text: comment.edit,
@@ -1695,7 +1700,7 @@ var Toolbar = function Toolbar(_a) {
1695
1700
  iconId: name,
1696
1701
  tooltip: tooltip,
1697
1702
  key: name,
1698
- selected: (_g = toolbarItemSelectedFunc(name)) === null || _g === void 0 ? void 0 : _g(cell),
1703
+ selected: (_f = toolbarItemSelectedFunc(name)) === null || _f === void 0 ? void 0 : _f(cell),
1699
1704
  onClick: function onClick() {
1700
1705
  return setContext(function (draftCtx) {
1701
1706
  var _a;
@@ -728,6 +728,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
728
728
  conditionformat_equal_title: string;
729
729
  conditionformat_textContains: string;
730
730
  conditionformat_textContains_title: string;
731
+ conditionformat_empty: string;
732
+ conditionformat_empty_title: string;
731
733
  conditionformat_occurrenceDate: string;
732
734
  conditionformat_occurrenceDate_title: string;
733
735
  conditionformat_duplicateValue: string;
@@ -830,6 +832,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
830
832
  between2: string;
831
833
  contain: string;
832
834
  textContains: string;
835
+ empty: string;
833
836
  duplicateValue: string;
834
837
  uniqueValue: string;
835
838
  top: string;
@@ -735,6 +735,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
735
735
  conditionformat_equal_title: string;
736
736
  conditionformat_textContains: string;
737
737
  conditionformat_textContains_title: string;
738
+ conditionformat_empty: string;
739
+ conditionformat_empty_title: string;
738
740
  conditionformat_occurrenceDate: string;
739
741
  conditionformat_occurrenceDate_title: string;
740
742
  conditionformat_duplicateValue: string;
@@ -837,6 +839,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
837
839
  between2: string;
838
840
  contain: string;
839
841
  textContains: string;
842
+ empty: string;
840
843
  duplicateValue: string;
841
844
  uniqueValue: string;
842
845
  top: string;