@fileverse-dev/fortune-react 1.2.79 → 1.2.81-yield

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,6 +1,6 @@
1
1
  import React, { useRef, useCallback, useContext, useEffect, useState } from "react";
2
2
  import "./index.css";
3
- import { cn, Button, IconButton, LucideIcon, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, TextField } from "@fileverse/ui";
3
+ import { cn, Button, IconButton, LucideIcon, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SelectGroup, SelectLabel, TextField } from "@fileverse/ui";
4
4
  import { locale, setConditionRules, getSheetIndex } from "@fileverse-dev/fortune-core";
5
5
  import produce from "immer";
6
6
  import { numberToColumn } from "../SheetOverlay/helper";
@@ -27,6 +27,7 @@ var ConditionRules = function ConditionRules(_a) {
27
27
  editConditionFormatKey = _d[0],
28
28
  setEditConditionFormatKey = _d[1];
29
29
  var editKeyRef = useRef(null);
30
+ var firstRenderRef = useRef(true);
30
31
  var _e = useState(""),
31
32
  editConditionRange = _e[0],
32
33
  setEditConditionRange = _e[1];
@@ -47,8 +48,8 @@ var ConditionRules = function ConditionRules(_a) {
47
48
  protection = _j.protection,
48
49
  generalDialog = _j.generalDialog;
49
50
  var _k = useState({
50
- textColor: "#FFFFFF",
51
- cellColor: "#D82E2A"
51
+ textColor: "#177E23",
52
+ cellColor: "#DDFBDF"
52
53
  }),
53
54
  colorRules = _k[0],
54
55
  setColorRules = _k[1];
@@ -66,6 +67,7 @@ var ConditionRules = function ConditionRules(_a) {
66
67
  setStrikethrough = _p[1];
67
68
  useEffect(function () {
68
69
  var _a, _b;
70
+ if (create) return;
69
71
  var index = getSheetIndex(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
70
72
  var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
71
73
  setAllConditionFormats(allCondition);
@@ -89,11 +91,13 @@ var ConditionRules = function ConditionRules(_a) {
89
91
  setMatchedConditionFormatKey(matchedCondition);
90
92
  }
91
93
  if (buttonClickCreateRef.current) return;
92
- if (matchedCondition.length === 0) {
93
- setCreate(true);
94
- } else if (matchedCondition.length > 0) {
94
+ if (matchedCondition.length >= 0) {
95
95
  setCreate(false);
96
96
  }
97
+ if (firstRenderRef.current && matchedCondition.length <= 0) {
98
+ setCreate(true);
99
+ firstRenderRef.current = false;
100
+ }
97
101
  }, [context]);
98
102
  var updateCacheRules = function updateCacheRules() {
99
103
  setContext(function (ctx) {
@@ -146,7 +150,6 @@ var ConditionRules = function ConditionRules(_a) {
146
150
  buttonClickCreateRef.current = false;
147
151
  setCreate(false);
148
152
  setContext(function (ctx) {
149
- console.log("whole rule", ctx.conditionRules);
150
153
  ctx.conditionRules.textColor.color = colorRules.textColor;
151
154
  ctx.conditionRules.cellColor.color = colorRules.cellColor;
152
155
  ctx.conditionRules.font = {
@@ -203,6 +206,14 @@ var ConditionRules = function ConditionRules(_a) {
203
206
  projectValue: "10"
204
207
  };
205
208
  });
209
+ setBold(false);
210
+ setItalic(false);
211
+ setUnderline(false);
212
+ setStrikethrough(false);
213
+ setColorRules({
214
+ textColor: "#177E23",
215
+ cellColor: "#DDFBDF"
216
+ });
206
217
  updateCacheRules();
207
218
  setEditConditionFormatKey(null);
208
219
  setContext(function (ctx) {
@@ -257,7 +268,7 @@ var ConditionRules = function ConditionRules(_a) {
257
268
  ctx.rangeDialog.rangeTxt = "";
258
269
  });
259
270
  }, [type]);
260
- var conditionList = [{
271
+ var cellHighlightConditionList = [{
261
272
  text: "greaterThan",
262
273
  value: ">",
263
274
  label: "Greater Than"
@@ -293,7 +304,8 @@ var ConditionRules = function ConditionRules(_a) {
293
304
  text: "duplicateValue",
294
305
  value: "##",
295
306
  label: "Duplicate Value"
296
- }, {
307
+ }];
308
+ var itemSelectionConditionList = [{
297
309
  text: "top10",
298
310
  value: conditionformat.top10
299
311
  }, {
@@ -330,11 +342,9 @@ var ConditionRules = function ConditionRules(_a) {
330
342
  var _a;
331
343
  setEditConditionFormatKey(key);
332
344
  setContext(function (ctx) {
333
- var _a, _b, _c, _d;
345
+ var _a, _b;
334
346
  var index = getSheetIndex(ctx, ctx.currentSheetId);
335
- console.log("why set editkey", (_b = (_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.conditionRules) === null || _b === void 0 ? void 0 : _b.editKey);
336
- if (((_d = (_c = ctx.luckysheetfile[index]) === null || _c === void 0 ? void 0 : _c.conditionRules) === null || _d === void 0 ? void 0 : _d.editKey) === undefined) {
337
- console.log("set editkey");
347
+ if (((_b = (_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.conditionRules) === null || _b === void 0 ? void 0 : _b.editKey) === undefined) {
338
348
  ctx.luckysheetfile[index].conditionRules.editKey = key;
339
349
  }
340
350
  });
@@ -459,19 +469,28 @@ var ConditionRules = function ConditionRules(_a) {
459
469
  sideOffset: 4,
460
470
  className: "z-[100]",
461
471
  "data-dropdown-content": "true"
462
- }, conditionList.map(function (option) {
472
+ }, /*#__PURE__*/React.createElement(SelectGroup, null, /*#__PURE__*/React.createElement(SelectLabel, null, "Cell highlight rules"), cellHighlightConditionList.map(function (option) {
463
473
  return /*#__PURE__*/React.createElement(SelectItem, {
464
474
  key: option.value,
465
475
  value: option.text
466
476
  }, /*#__PURE__*/React.createElement("div", {
467
477
  className: "flex items-center gap-2"
468
478
  }, /*#__PURE__*/React.createElement("span", null, conditionformat[option.text])));
469
- })))), !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/React.createElement("div", {
479
+ })), /*#__PURE__*/React.createElement(SelectGroup, null, /*#__PURE__*/React.createElement(SelectLabel, null, "Item selections rules"), itemSelectionConditionList.map(function (option) {
480
+ return /*#__PURE__*/React.createElement(SelectItem, {
481
+ key: option.value,
482
+ value: option.text
483
+ }, /*#__PURE__*/React.createElement("div", {
484
+ className: "flex items-center gap-2"
485
+ }, /*#__PURE__*/React.createElement("span", null, conditionformat[option.text])));
486
+ }))))), !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/React.createElement("div", {
470
487
  className: "flex flex-col"
471
488
  }, (type === "greaterThan" || type === "greaterThanOrEqual" || type === "lessThan" || type === "lessThanOrEqual" || type === "equal" || type === "textContains") && (/*#__PURE__*/React.createElement("div", {
472
489
  className: "w-full"
473
490
  }, /*#__PURE__*/React.createElement(TextField, {
474
- placeholder: "Value",
491
+ label: "Value for condition",
492
+ required: true,
493
+ placeholder: "Value is required",
475
494
  onKeyDown: function onKeyDown(e) {
476
495
  e.stopPropagation();
477
496
  },
@@ -595,9 +614,19 @@ var ConditionRules = function ConditionRules(_a) {
595
614
  }, "Formatting styles"), /*#__PURE__*/React.createElement("div", {
596
615
  className: "toolbar-container"
597
616
  }, /*#__PURE__*/React.createElement("div", {
598
- className: "toolbar-header"
617
+ className: "toolbar-header",
618
+ style: {
619
+ backgroundColor: colorRules.cellColor,
620
+ color: colorRules.textColor,
621
+ textDecoration: underline ? "underline" : "",
622
+ textDecorationLine: strikethrough ? "line-through" : ""
623
+ }
599
624
  }, /*#__PURE__*/React.createElement("h2", {
600
- className: "toolbar-title"
625
+ className: "toolbar-title",
626
+ style: {
627
+ fontWeight: bold ? "bold" : "",
628
+ fontStyle: italic ? "italic" : ""
629
+ }
601
630
  }, "Formatting styles preview")), /*#__PURE__*/React.createElement("div", {
602
631
  className: "toolbar-content"
603
632
  }, /*#__PURE__*/React.createElement(Button, {
@@ -766,6 +795,7 @@ var ConditionRules = function ConditionRules(_a) {
766
795
  },
767
796
  tabIndex: 0
768
797
  }, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/React.createElement(Button, {
798
+ disabled: context.conditionRules.rulesValue === "",
769
799
  variant: "default",
770
800
  style: {
771
801
  minWidth: "80px"
@@ -774,7 +804,8 @@ var ConditionRules = function ConditionRules(_a) {
774
804
  close("edit");
775
805
  },
776
806
  tabIndex: 0
777
- }, "Edit rule")) : (/*#__PURE__*/React.createElement(Button, {
807
+ }, "Update rule")) : (/*#__PURE__*/React.createElement(Button, {
808
+ disabled: context.conditionRules.rulesValue === "",
778
809
  variant: "default",
779
810
  style: {
780
811
  minWidth: "80px"
@@ -8,26 +8,25 @@
8
8
  }
9
9
 
10
10
  .toolbar-header {
11
- background-color: #dcfce7;
11
+ height: 36px;
12
12
  padding: 4px 16px;
13
13
  border-radius: var(--border-radius-sm, 4px) var(--border-radius-sm, 4px) var(--border-radius-none, 0) var(--border-radius-none, 0);
14
- border-bottom: 1px solid hsl(var(--color-border-default, #E8EBEC));
15
- background: hsl(var(--color-bg-success-light, #DDFBDF));
14
+ border-bottom: 1px solid hsl(var(--color-border-default, #E8EBEC));
15
+ background: hsl(var(--color-bg-success-light, #DDFBDF));
16
16
  }
17
17
 
18
18
  .toolbar-title {
19
- color: hsl(var(--color-text-success, #177E23));
20
- font-family: "Helvetica Neue";
21
- font-size: 14px;
22
- font-style: normal;
23
- font-weight: 400;
24
- line-height: 20px;
19
+ font-family: "Helvetica Neue";
20
+ font-size: 14px;
21
+ font-style: normal;
22
+ font-weight: 400;
23
+ line-height: 20px;
25
24
  }
26
25
 
27
26
  .toolbar-content {
28
27
  padding: 4px;
29
28
  display: flex;
30
- gap: 16px;
29
+ gap: 12px;
31
30
  align-items: center;
32
31
  }
33
32
 
@@ -100,4 +99,4 @@ line-height: 20px;
100
99
  width: 24px;
101
100
  height: 24px;
102
101
  color: #1f2937;
103
- }
102
+ }
@@ -22,7 +22,7 @@ var ErrorBoxes = function ErrorBoxes() {
22
22
  zIndex: 100,
23
23
  borderRadius: "4px"
24
24
  },
25
- className: "shadow-lg flex flex-col gap-2"
25
+ className: "shadow-lg flex flex-col gap-2 break-all"
26
26
  }, /*#__PURE__*/React.createElement("h3", {
27
27
  className: "text-heading-xsm color-text-danger"
28
28
  }, title), /*#__PURE__*/React.createElement("div", {
@@ -11,26 +11,26 @@ import usePrevious from "../../hooks/usePrevious";
11
11
  import { LucideIcon } from "../../components/SheetOverlay/LucideIcon";
12
12
  import { countCommasBeforeCursor, isLetterNumberPattern, moveCursorToEnd } from "../../components/SheetOverlay/helper";
13
13
  var FxEditor = function FxEditor() {
14
- var _a, _b, _c;
14
+ var _a;
15
15
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
16
- var _d = useState(false),
17
- showSearchHint = _d[0],
18
- setShowSearchHint = _d[1];
19
- var _e = useState(!hideFormulaHintLocal),
20
- showFormulaHint = _e[0],
21
- setShowFormulaHint = _e[1];
22
- var _f = useState(0),
23
- commaCount = _f[0],
24
- setCommaCount = _f[1];
25
- var _g = useContext(WorkbookContext),
26
- context = _g.context,
27
- setContext = _g.setContext,
28
- refs = _g.refs;
16
+ var _b = useState(false),
17
+ showSearchHint = _b[0],
18
+ setShowSearchHint = _b[1];
19
+ var _c = useState(!hideFormulaHintLocal),
20
+ showFormulaHint = _c[0],
21
+ setShowFormulaHint = _c[1];
22
+ var _d = useState(0),
23
+ commaCount = _d[0],
24
+ setCommaCount = _d[1];
25
+ var _e = useContext(WorkbookContext),
26
+ context = _e.context,
27
+ setContext = _e.setContext,
28
+ refs = _e.refs;
29
29
  var lastKeyDownEventRef = useRef(null);
30
30
  var inputContainerRef = useRef(null);
31
- var _h = useState(false),
32
- isHidenRC = _h[0],
33
- setIsHidenRC = _h[1];
31
+ var _f = useState(false),
32
+ isHidenRC = _f[0],
33
+ setIsHidenRC = _f[1];
34
34
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
35
35
  var prevFirstSelection = usePrevious(firstSelection);
36
36
  var prevSheetId = usePrevious(context.currentSheetId);
@@ -267,6 +267,24 @@ var FxEditor = function FxEditor() {
267
267
  });
268
268
  }
269
269
  }, [refs.cellInput, refs.fxInput, setContext]);
270
+ var getFunctionNameFromInput = useCallback(function () {
271
+ var _a, _b, _c, _d;
272
+ var inputText = ((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText) || "";
273
+ if (!inputText.startsWith("=")) return null;
274
+ var functionMatch = inputText.match(/^=([A-Za-z_][A-Za-z0-9_]*)\s*\(/);
275
+ if (functionMatch) {
276
+ return functionMatch[1].toUpperCase();
277
+ }
278
+ if ((_c = refs.fxInput) === null || _c === void 0 ? void 0 : _c.current) {
279
+ var funcSpan = refs.fxInput.current.querySelector(".luckysheet-formula-text-func");
280
+ if (funcSpan) {
281
+ return ((_d = funcSpan.textContent) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || null;
282
+ }
283
+ }
284
+ return null;
285
+ }, []);
286
+ var functionName = context.functionHint || getFunctionNameFromInput();
287
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : null;
270
288
  var allowEdit = useMemo(function () {
271
289
  if (context.allowEdit === false) {
272
290
  return false;
@@ -280,9 +298,9 @@ var FxEditor = function FxEditor() {
280
298
  return true;
281
299
  }, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, isHidenRC]);
282
300
  var divRef = useRef(null);
283
- var _j = useState(false),
284
- isResizing = _j[0],
285
- setIsResizing = _j[1];
301
+ var _g = useState(false),
302
+ isResizing = _g[0],
303
+ setIsResizing = _g[1];
286
304
  var startResize = function startResize(e) {
287
305
  e.preventDefault();
288
306
  setIsResizing(true);
@@ -358,11 +376,12 @@ var FxEditor = function FxEditor() {
358
376
  }
359
377
  })), /*#__PURE__*/React.createElement("div", {
360
378
  className: "fx-hint"
361
- }, context.functionHint && ((_c = (_b = refs.fxInput) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.innerText.includes("(")) && (/*#__PURE__*/React.createElement(FormulaHint, {
379
+ }, showFormulaHint && fn && (/*#__PURE__*/React.createElement(FormulaHint, {
362
380
  handleShowFormulaHint: handleShowFormulaHint,
363
381
  showFormulaHint: showFormulaHint,
364
- commaCount: commaCount
365
- })), context.functionHint && !showFormulaHint && (/*#__PURE__*/React.createElement("div", {
382
+ commaCount: commaCount,
383
+ functionName: functionName
384
+ })), !showFormulaHint && fn && (/*#__PURE__*/React.createElement("div", {
366
385
  className: "luckysheet-hin absolute show-more-btn",
367
386
  onClick: function onClick() {
368
387
  handleShowFormulaHint();
@@ -18,12 +18,13 @@ var FormulaHint = function FormulaHint(props) {
18
18
  var _a;
19
19
  var showFormulaHint = props.showFormulaHint,
20
20
  handleShowFormulaHint = props.handleShowFormulaHint,
21
- commaCount = props.commaCount;
21
+ commaCount = props.commaCount,
22
+ functionName = props.functionName;
22
23
  var dragHasMoved = useRef(false);
23
24
  var context = useContext(WorkbookContext).context;
24
25
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
25
26
  var formulaMore = locale(context).formulaMore;
26
- var fn = context.formulaCache.functionlistMap[context.functionHint];
27
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : context.formulaCache.functionlistMap[(context === null || context === void 0 ? void 0 : context.functionHint) || ""];
27
28
  var _b = useState(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
28
29
  API_KEY = _b[0],
29
30
  setAPI_KEY = _b[1];
@@ -20,47 +20,47 @@ import usePrevious from "../../hooks/usePrevious";
20
20
  import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, incrementColumn, decrementColumn, incrementRow, decrementRow, 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;
24
- var _j = useContext(WorkbookContext),
25
- context = _j.context,
26
- setContext = _j.setContext,
27
- refs = _j.refs;
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ var _h = useContext(WorkbookContext),
25
+ context = _h.context,
26
+ setContext = _h.setContext,
27
+ refs = _h.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 _j = useState(false),
33
+ isHidenRC = _j[0],
34
+ setIsHidenRC = _j[1];
32
35
  var _k = useState(false),
33
- isHidenRC = _k[0],
34
- setIsHidenRC = _k[1];
35
- var _l = useState(false),
36
- isInputBoxActive = _l[0],
37
- setIsInputBoxActive = _l[1];
36
+ isInputBoxActive = _k[0],
37
+ setIsInputBoxActive = _k[1];
38
+ var _l = useState(""),
39
+ activeCell = _l[0],
40
+ setActiveCell = _l[1];
38
41
  var _m = useState(""),
39
- activeCell = _m[0],
40
- setActiveCell = _m[1];
41
- var _o = useState(""),
42
- activeRefCell = _o[0],
43
- setActiveRefCell = _o[1];
44
- var _p = useState({
42
+ activeRefCell = _m[0],
43
+ setActiveRefCell = _m[1];
44
+ var _o = useState({
45
45
  left: 0,
46
46
  top: 0
47
47
  }),
48
- frozenPosition = _p[0],
49
- setFrozenPosition = _p[1];
48
+ frozenPosition = _o[0],
49
+ setFrozenPosition = _o[1];
50
50
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
51
- var _q = useState({}),
52
- firstSelectionActiveCell = _q[0],
53
- setFirstSelectionActiveCell = _q[1];
54
- var _r = useState(0),
55
- commaCount = _r[0],
56
- setCommaCount = _r[1];
51
+ var _p = useState({}),
52
+ firstSelectionActiveCell = _p[0],
53
+ setFirstSelectionActiveCell = _p[1];
54
+ var _q = useState(0),
55
+ commaCount = _q[0],
56
+ setCommaCount = _q[1];
57
57
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
58
- var _s = useState(!hideFormulaHintLocal),
59
- showFormulaHint = _s[0],
60
- setShowFormulaHint = _s[1];
61
- var _t = useState(false),
62
- showSearchHint = _t[0],
63
- setShowSearchHint = _t[1];
58
+ var _r = useState(!hideFormulaHintLocal),
59
+ showFormulaHint = _r[0],
60
+ setShowFormulaHint = _r[1];
61
+ var _s = useState(false),
62
+ showSearchHint = _s[0],
63
+ setShowSearchHint = _s[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("");
@@ -517,7 +517,24 @@ var InputBox = function InputBox() {
517
517
  }
518
518
  return activeCell || cell;
519
519
  };
520
- var fn = context.formulaCache.functionlistMap[context.functionHint];
520
+ var getFunctionNameFromInput = useCallback(function () {
521
+ var _a, _b;
522
+ var inputText = ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
523
+ if (!inputText.startsWith("=")) return null;
524
+ var functionMatch = inputText.match(/^=([A-Za-z_][A-Za-z0-9_]*)\s*\(/);
525
+ if (functionMatch) {
526
+ return functionMatch[1].toUpperCase();
527
+ }
528
+ if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
529
+ var funcSpan = inputRef.current.querySelector(".luckysheet-formula-text-func");
530
+ if (funcSpan) {
531
+ return ((_b = funcSpan.textContent) === null || _b === void 0 ? void 0 : _b.toUpperCase()) || null;
532
+ }
533
+ }
534
+ return null;
535
+ }, []);
536
+ var functionName = context.functionHint || getFunctionNameFromInput();
537
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : null;
521
538
  return /*#__PURE__*/React.createElement("div", {
522
539
  className: "luckysheet-input-box",
523
540
  id: "luckysheet-input-box",
@@ -561,7 +578,7 @@ var InputBox = function InputBox() {
561
578
  onKeyDown: onKeyDown,
562
579
  onPaste: onPaste,
563
580
  allowEdit: edit ? !isHidenRC : edit
564
- })), (context.functionCandidates.length > 0 || context.functionHint || context.defaultCandidates.length > 0) && (/*#__PURE__*/React.createElement(React.Fragment, null, showSearchHint && (/*#__PURE__*/React.createElement(FormulaSearch, {
581
+ })), (context.functionCandidates.length > 0 || context.functionHint || context.defaultCandidates.length > 0 || fn) && (/*#__PURE__*/React.createElement(React.Fragment, null, showSearchHint && (/*#__PURE__*/React.createElement(FormulaSearch, {
565
582
  onMouseMove: function onMouseMove(e) {
566
583
  if (document.getElementById("luckysheet-formula-search-c")) {
567
584
  var hoveredItem = e.target.closest(".luckysheet-formula-search-item");
@@ -576,10 +593,11 @@ var InputBox = function InputBox() {
576
593
  }
577
594
  })), /*#__PURE__*/React.createElement("div", {
578
595
  className: "cell-hint"
579
- }, showFormulaHint && fn && ((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.innerText.includes("(")) && (/*#__PURE__*/React.createElement(FormulaHint, {
596
+ }, showFormulaHint && fn && (/*#__PURE__*/React.createElement(FormulaHint, {
580
597
  handleShowFormulaHint: handleShowFormulaHint,
581
598
  showFormulaHint: showFormulaHint,
582
- commaCount: commaCount
599
+ commaCount: commaCount,
600
+ functionName: functionName
583
601
  })), !showFormulaHint && fn && (/*#__PURE__*/React.createElement(Tooltip, {
584
602
  text: "Turn on formula suggestions (F10)",
585
603
  placement: "top",
@@ -36,6 +36,7 @@ var ConditionRules = function ConditionRules(_a) {
36
36
  editConditionFormatKey = _d[0],
37
37
  setEditConditionFormatKey = _d[1];
38
38
  var editKeyRef = (0, _react.useRef)(null);
39
+ var firstRenderRef = (0, _react.useRef)(true);
39
40
  var _e = (0, _react.useState)(""),
40
41
  editConditionRange = _e[0],
41
42
  setEditConditionRange = _e[1];
@@ -56,8 +57,8 @@ var ConditionRules = function ConditionRules(_a) {
56
57
  protection = _j.protection,
57
58
  generalDialog = _j.generalDialog;
58
59
  var _k = (0, _react.useState)({
59
- textColor: "#FFFFFF",
60
- cellColor: "#D82E2A"
60
+ textColor: "#177E23",
61
+ cellColor: "#DDFBDF"
61
62
  }),
62
63
  colorRules = _k[0],
63
64
  setColorRules = _k[1];
@@ -75,6 +76,7 @@ var ConditionRules = function ConditionRules(_a) {
75
76
  setStrikethrough = _p[1];
76
77
  (0, _react.useEffect)(function () {
77
78
  var _a, _b;
79
+ if (create) return;
78
80
  var index = (0, _fortuneCore.getSheetIndex)(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
79
81
  var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
80
82
  setAllConditionFormats(allCondition);
@@ -98,11 +100,13 @@ var ConditionRules = function ConditionRules(_a) {
98
100
  setMatchedConditionFormatKey(matchedCondition);
99
101
  }
100
102
  if (buttonClickCreateRef.current) return;
101
- if (matchedCondition.length === 0) {
102
- setCreate(true);
103
- } else if (matchedCondition.length > 0) {
103
+ if (matchedCondition.length >= 0) {
104
104
  setCreate(false);
105
105
  }
106
+ if (firstRenderRef.current && matchedCondition.length <= 0) {
107
+ setCreate(true);
108
+ firstRenderRef.current = false;
109
+ }
106
110
  }, [context]);
107
111
  var updateCacheRules = function updateCacheRules() {
108
112
  setContext(function (ctx) {
@@ -155,7 +159,6 @@ var ConditionRules = function ConditionRules(_a) {
155
159
  buttonClickCreateRef.current = false;
156
160
  setCreate(false);
157
161
  setContext(function (ctx) {
158
- console.log("whole rule", ctx.conditionRules);
159
162
  ctx.conditionRules.textColor.color = colorRules.textColor;
160
163
  ctx.conditionRules.cellColor.color = colorRules.cellColor;
161
164
  ctx.conditionRules.font = {
@@ -212,6 +215,14 @@ var ConditionRules = function ConditionRules(_a) {
212
215
  projectValue: "10"
213
216
  };
214
217
  });
218
+ setBold(false);
219
+ setItalic(false);
220
+ setUnderline(false);
221
+ setStrikethrough(false);
222
+ setColorRules({
223
+ textColor: "#177E23",
224
+ cellColor: "#DDFBDF"
225
+ });
215
226
  updateCacheRules();
216
227
  setEditConditionFormatKey(null);
217
228
  setContext(function (ctx) {
@@ -266,7 +277,7 @@ var ConditionRules = function ConditionRules(_a) {
266
277
  ctx.rangeDialog.rangeTxt = "";
267
278
  });
268
279
  }, [type]);
269
- var conditionList = [{
280
+ var cellHighlightConditionList = [{
270
281
  text: "greaterThan",
271
282
  value: ">",
272
283
  label: "Greater Than"
@@ -302,7 +313,8 @@ var ConditionRules = function ConditionRules(_a) {
302
313
  text: "duplicateValue",
303
314
  value: "##",
304
315
  label: "Duplicate Value"
305
- }, {
316
+ }];
317
+ var itemSelectionConditionList = [{
306
318
  text: "top10",
307
319
  value: conditionformat.top10
308
320
  }, {
@@ -339,11 +351,9 @@ var ConditionRules = function ConditionRules(_a) {
339
351
  var _a;
340
352
  setEditConditionFormatKey(key);
341
353
  setContext(function (ctx) {
342
- var _a, _b, _c, _d;
354
+ var _a, _b;
343
355
  var index = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
344
- console.log("why set editkey", (_b = (_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.conditionRules) === null || _b === void 0 ? void 0 : _b.editKey);
345
- if (((_d = (_c = ctx.luckysheetfile[index]) === null || _c === void 0 ? void 0 : _c.conditionRules) === null || _d === void 0 ? void 0 : _d.editKey) === undefined) {
346
- console.log("set editkey");
356
+ if (((_b = (_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.conditionRules) === null || _b === void 0 ? void 0 : _b.editKey) === undefined) {
347
357
  ctx.luckysheetfile[index].conditionRules.editKey = key;
348
358
  }
349
359
  });
@@ -468,19 +478,28 @@ var ConditionRules = function ConditionRules(_a) {
468
478
  sideOffset: 4,
469
479
  className: "z-[100]",
470
480
  "data-dropdown-content": "true"
471
- }, conditionList.map(function (option) {
481
+ }, /*#__PURE__*/_react.default.createElement(_ui.SelectGroup, null, /*#__PURE__*/_react.default.createElement(_ui.SelectLabel, null, "Cell highlight rules"), cellHighlightConditionList.map(function (option) {
472
482
  return /*#__PURE__*/_react.default.createElement(_ui.SelectItem, {
473
483
  key: option.value,
474
484
  value: option.text
475
485
  }, /*#__PURE__*/_react.default.createElement("div", {
476
486
  className: "flex items-center gap-2"
477
487
  }, /*#__PURE__*/_react.default.createElement("span", null, conditionformat[option.text])));
478
- })))), !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/_react.default.createElement("div", {
488
+ })), /*#__PURE__*/_react.default.createElement(_ui.SelectGroup, null, /*#__PURE__*/_react.default.createElement(_ui.SelectLabel, null, "Item selections rules"), itemSelectionConditionList.map(function (option) {
489
+ return /*#__PURE__*/_react.default.createElement(_ui.SelectItem, {
490
+ key: option.value,
491
+ value: option.text
492
+ }, /*#__PURE__*/_react.default.createElement("div", {
493
+ className: "flex items-center gap-2"
494
+ }, /*#__PURE__*/_react.default.createElement("span", null, conditionformat[option.text])));
495
+ }))))), !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/_react.default.createElement("div", {
479
496
  className: "flex flex-col"
480
497
  }, (type === "greaterThan" || type === "greaterThanOrEqual" || type === "lessThan" || type === "lessThanOrEqual" || type === "equal" || type === "textContains") && (/*#__PURE__*/_react.default.createElement("div", {
481
498
  className: "w-full"
482
499
  }, /*#__PURE__*/_react.default.createElement(_ui.TextField, {
483
- placeholder: "Value",
500
+ label: "Value for condition",
501
+ required: true,
502
+ placeholder: "Value is required",
484
503
  onKeyDown: function onKeyDown(e) {
485
504
  e.stopPropagation();
486
505
  },
@@ -604,9 +623,19 @@ var ConditionRules = function ConditionRules(_a) {
604
623
  }, "Formatting styles"), /*#__PURE__*/_react.default.createElement("div", {
605
624
  className: "toolbar-container"
606
625
  }, /*#__PURE__*/_react.default.createElement("div", {
607
- className: "toolbar-header"
626
+ className: "toolbar-header",
627
+ style: {
628
+ backgroundColor: colorRules.cellColor,
629
+ color: colorRules.textColor,
630
+ textDecoration: underline ? "underline" : "",
631
+ textDecorationLine: strikethrough ? "line-through" : ""
632
+ }
608
633
  }, /*#__PURE__*/_react.default.createElement("h2", {
609
- className: "toolbar-title"
634
+ className: "toolbar-title",
635
+ style: {
636
+ fontWeight: bold ? "bold" : "",
637
+ fontStyle: italic ? "italic" : ""
638
+ }
610
639
  }, "Formatting styles preview")), /*#__PURE__*/_react.default.createElement("div", {
611
640
  className: "toolbar-content"
612
641
  }, /*#__PURE__*/_react.default.createElement(_ui.Button, {
@@ -775,6 +804,7 @@ var ConditionRules = function ConditionRules(_a) {
775
804
  },
776
805
  tabIndex: 0
777
806
  }, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/_react.default.createElement(_ui.Button, {
807
+ disabled: context.conditionRules.rulesValue === "",
778
808
  variant: "default",
779
809
  style: {
780
810
  minWidth: "80px"
@@ -783,7 +813,8 @@ var ConditionRules = function ConditionRules(_a) {
783
813
  close("edit");
784
814
  },
785
815
  tabIndex: 0
786
- }, "Edit rule")) : (/*#__PURE__*/_react.default.createElement(_ui.Button, {
816
+ }, "Update rule")) : (/*#__PURE__*/_react.default.createElement(_ui.Button, {
817
+ disabled: context.conditionRules.rulesValue === "",
787
818
  variant: "default",
788
819
  style: {
789
820
  minWidth: "80px"
@@ -8,26 +8,25 @@
8
8
  }
9
9
 
10
10
  .toolbar-header {
11
- background-color: #dcfce7;
11
+ height: 36px;
12
12
  padding: 4px 16px;
13
13
  border-radius: var(--border-radius-sm, 4px) var(--border-radius-sm, 4px) var(--border-radius-none, 0) var(--border-radius-none, 0);
14
- border-bottom: 1px solid hsl(var(--color-border-default, #E8EBEC));
15
- background: hsl(var(--color-bg-success-light, #DDFBDF));
14
+ border-bottom: 1px solid hsl(var(--color-border-default, #E8EBEC));
15
+ background: hsl(var(--color-bg-success-light, #DDFBDF));
16
16
  }
17
17
 
18
18
  .toolbar-title {
19
- color: hsl(var(--color-text-success, #177E23));
20
- font-family: "Helvetica Neue";
21
- font-size: 14px;
22
- font-style: normal;
23
- font-weight: 400;
24
- line-height: 20px;
19
+ font-family: "Helvetica Neue";
20
+ font-size: 14px;
21
+ font-style: normal;
22
+ font-weight: 400;
23
+ line-height: 20px;
25
24
  }
26
25
 
27
26
  .toolbar-content {
28
27
  padding: 4px;
29
28
  display: flex;
30
- gap: 16px;
29
+ gap: 12px;
31
30
  align-items: center;
32
31
  }
33
32
 
@@ -100,4 +99,4 @@ line-height: 20px;
100
99
  width: 24px;
101
100
  height: 24px;
102
101
  color: #1f2937;
103
- }
102
+ }
@@ -31,7 +31,7 @@ var ErrorBoxes = function ErrorBoxes() {
31
31
  zIndex: 100,
32
32
  borderRadius: "4px"
33
33
  },
34
- className: "shadow-lg flex flex-col gap-2"
34
+ className: "shadow-lg flex flex-col gap-2 break-all"
35
35
  }, /*#__PURE__*/_react.default.createElement("h3", {
36
36
  className: "text-heading-xsm color-text-danger"
37
37
  }, title), /*#__PURE__*/_react.default.createElement("div", {
@@ -20,26 +20,26 @@ var _helper = require("../../components/SheetOverlay/helper");
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
22
22
  var FxEditor = function FxEditor() {
23
- var _a, _b, _c;
23
+ var _a;
24
24
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
25
- var _d = (0, _react.useState)(false),
26
- showSearchHint = _d[0],
27
- setShowSearchHint = _d[1];
28
- var _e = (0, _react.useState)(!hideFormulaHintLocal),
29
- showFormulaHint = _e[0],
30
- setShowFormulaHint = _e[1];
31
- var _f = (0, _react.useState)(0),
32
- commaCount = _f[0],
33
- setCommaCount = _f[1];
34
- var _g = (0, _react.useContext)(_context.default),
35
- context = _g.context,
36
- setContext = _g.setContext,
37
- refs = _g.refs;
25
+ var _b = (0, _react.useState)(false),
26
+ showSearchHint = _b[0],
27
+ setShowSearchHint = _b[1];
28
+ var _c = (0, _react.useState)(!hideFormulaHintLocal),
29
+ showFormulaHint = _c[0],
30
+ setShowFormulaHint = _c[1];
31
+ var _d = (0, _react.useState)(0),
32
+ commaCount = _d[0],
33
+ setCommaCount = _d[1];
34
+ var _e = (0, _react.useContext)(_context.default),
35
+ context = _e.context,
36
+ setContext = _e.setContext,
37
+ refs = _e.refs;
38
38
  var lastKeyDownEventRef = (0, _react.useRef)(null);
39
39
  var inputContainerRef = (0, _react.useRef)(null);
40
- var _h = (0, _react.useState)(false),
41
- isHidenRC = _h[0],
42
- setIsHidenRC = _h[1];
40
+ var _f = (0, _react.useState)(false),
41
+ isHidenRC = _f[0],
42
+ setIsHidenRC = _f[1];
43
43
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
44
44
  var prevFirstSelection = (0, _usePrevious.default)(firstSelection);
45
45
  var prevSheetId = (0, _usePrevious.default)(context.currentSheetId);
@@ -276,6 +276,24 @@ var FxEditor = function FxEditor() {
276
276
  });
277
277
  }
278
278
  }, [refs.cellInput, refs.fxInput, setContext]);
279
+ var getFunctionNameFromInput = (0, _react.useCallback)(function () {
280
+ var _a, _b, _c, _d;
281
+ var inputText = ((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText) || "";
282
+ if (!inputText.startsWith("=")) return null;
283
+ var functionMatch = inputText.match(/^=([A-Za-z_][A-Za-z0-9_]*)\s*\(/);
284
+ if (functionMatch) {
285
+ return functionMatch[1].toUpperCase();
286
+ }
287
+ if ((_c = refs.fxInput) === null || _c === void 0 ? void 0 : _c.current) {
288
+ var funcSpan = refs.fxInput.current.querySelector(".luckysheet-formula-text-func");
289
+ if (funcSpan) {
290
+ return ((_d = funcSpan.textContent) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || null;
291
+ }
292
+ }
293
+ return null;
294
+ }, []);
295
+ var functionName = context.functionHint || getFunctionNameFromInput();
296
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : null;
279
297
  var allowEdit = (0, _react.useMemo)(function () {
280
298
  if (context.allowEdit === false) {
281
299
  return false;
@@ -289,9 +307,9 @@ var FxEditor = function FxEditor() {
289
307
  return true;
290
308
  }, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, isHidenRC]);
291
309
  var divRef = (0, _react.useRef)(null);
292
- var _j = (0, _react.useState)(false),
293
- isResizing = _j[0],
294
- setIsResizing = _j[1];
310
+ var _g = (0, _react.useState)(false),
311
+ isResizing = _g[0],
312
+ setIsResizing = _g[1];
295
313
  var startResize = function startResize(e) {
296
314
  e.preventDefault();
297
315
  setIsResizing(true);
@@ -367,11 +385,12 @@ var FxEditor = function FxEditor() {
367
385
  }
368
386
  })), /*#__PURE__*/_react.default.createElement("div", {
369
387
  className: "fx-hint"
370
- }, context.functionHint && ((_c = (_b = refs.fxInput) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.innerText.includes("(")) && (/*#__PURE__*/_react.default.createElement(_FormulaHint.default, {
388
+ }, showFormulaHint && fn && (/*#__PURE__*/_react.default.createElement(_FormulaHint.default, {
371
389
  handleShowFormulaHint: handleShowFormulaHint,
372
390
  showFormulaHint: showFormulaHint,
373
- commaCount: commaCount
374
- })), context.functionHint && !showFormulaHint && (/*#__PURE__*/_react.default.createElement("div", {
391
+ commaCount: commaCount,
392
+ functionName: functionName
393
+ })), !showFormulaHint && fn && (/*#__PURE__*/_react.default.createElement("div", {
375
394
  className: "luckysheet-hin absolute show-more-btn",
376
395
  onClick: function onClick() {
377
396
  handleShowFormulaHint();
@@ -27,12 +27,13 @@ var FormulaHint = function FormulaHint(props) {
27
27
  var _a;
28
28
  var showFormulaHint = props.showFormulaHint,
29
29
  handleShowFormulaHint = props.handleShowFormulaHint,
30
- commaCount = props.commaCount;
30
+ commaCount = props.commaCount,
31
+ functionName = props.functionName;
31
32
  var dragHasMoved = (0, _react.useRef)(false);
32
33
  var context = (0, _react.useContext)(_context.default).context;
33
34
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
34
35
  var formulaMore = (0, _fortuneCore.locale)(context).formulaMore;
35
- var fn = context.formulaCache.functionlistMap[context.functionHint];
36
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : context.formulaCache.functionlistMap[(context === null || context === void 0 ? void 0 : context.functionHint) || ""];
36
37
  var _b = (0, _react.useState)(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
37
38
  API_KEY = _b[0],
38
39
  setAPI_KEY = _b[1];
@@ -17,7 +17,7 @@ var _usePrevious = _interopRequireDefault(require("../../hooks/usePrevious"));
17
17
  var _helper = require("./helper");
18
18
  var _LucideIcon = require("./LucideIcon");
19
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
20
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
21
  var __assign = void 0 && (void 0).__assign || function () {
22
22
  __assign = Object.assign || function (t) {
23
23
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -29,47 +29,47 @@ var __assign = void 0 && (void 0).__assign || function () {
29
29
  return __assign.apply(this, arguments);
30
30
  };
31
31
  var InputBox = function InputBox() {
32
- var _a, _b, _c, _d, _e, _f, _g, _h;
33
- var _j = (0, _react.useContext)(_context.default),
34
- context = _j.context,
35
- setContext = _j.setContext,
36
- refs = _j.refs;
32
+ var _a, _b, _c, _d, _e, _f, _g;
33
+ var _h = (0, _react.useContext)(_context.default),
34
+ context = _h.context,
35
+ setContext = _h.setContext,
36
+ refs = _h.refs;
37
37
  var inputRef = (0, _react.useRef)(null);
38
38
  var lastKeyDownEventRef = (0, _react.useRef)(null);
39
39
  var prevCellUpdate = (0, _usePrevious.default)(context.luckysheetCellUpdate);
40
40
  var prevSheetId = (0, _usePrevious.default)(context.currentSheetId);
41
+ var _j = (0, _react.useState)(false),
42
+ isHidenRC = _j[0],
43
+ setIsHidenRC = _j[1];
41
44
  var _k = (0, _react.useState)(false),
42
- isHidenRC = _k[0],
43
- setIsHidenRC = _k[1];
44
- var _l = (0, _react.useState)(false),
45
- isInputBoxActive = _l[0],
46
- setIsInputBoxActive = _l[1];
45
+ isInputBoxActive = _k[0],
46
+ setIsInputBoxActive = _k[1];
47
+ var _l = (0, _react.useState)(""),
48
+ activeCell = _l[0],
49
+ setActiveCell = _l[1];
47
50
  var _m = (0, _react.useState)(""),
48
- activeCell = _m[0],
49
- setActiveCell = _m[1];
50
- var _o = (0, _react.useState)(""),
51
- activeRefCell = _o[0],
52
- setActiveRefCell = _o[1];
53
- var _p = (0, _react.useState)({
51
+ activeRefCell = _m[0],
52
+ setActiveRefCell = _m[1];
53
+ var _o = (0, _react.useState)({
54
54
  left: 0,
55
55
  top: 0
56
56
  }),
57
- frozenPosition = _p[0],
58
- setFrozenPosition = _p[1];
57
+ frozenPosition = _o[0],
58
+ setFrozenPosition = _o[1];
59
59
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
60
- var _q = (0, _react.useState)({}),
61
- firstSelectionActiveCell = _q[0],
62
- setFirstSelectionActiveCell = _q[1];
63
- var _r = (0, _react.useState)(0),
64
- commaCount = _r[0],
65
- setCommaCount = _r[1];
60
+ var _p = (0, _react.useState)({}),
61
+ firstSelectionActiveCell = _p[0],
62
+ setFirstSelectionActiveCell = _p[1];
63
+ var _q = (0, _react.useState)(0),
64
+ commaCount = _q[0],
65
+ setCommaCount = _q[1];
66
66
  var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
67
- var _s = (0, _react.useState)(!hideFormulaHintLocal),
68
- showFormulaHint = _s[0],
69
- setShowFormulaHint = _s[1];
70
- var _t = (0, _react.useState)(false),
71
- showSearchHint = _t[0],
72
- setShowSearchHint = _t[1];
67
+ var _r = (0, _react.useState)(!hideFormulaHintLocal),
68
+ showFormulaHint = _r[0],
69
+ setShowFormulaHint = _r[1];
70
+ var _s = (0, _react.useState)(false),
71
+ showSearchHint = _s[0],
72
+ setShowSearchHint = _s[1];
73
73
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
74
74
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
75
75
  var preText = (0, _react.useRef)("");
@@ -526,7 +526,24 @@ var InputBox = function InputBox() {
526
526
  }
527
527
  return activeCell || cell;
528
528
  };
529
- var fn = context.formulaCache.functionlistMap[context.functionHint];
529
+ var getFunctionNameFromInput = (0, _react.useCallback)(function () {
530
+ var _a, _b;
531
+ var inputText = ((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
532
+ if (!inputText.startsWith("=")) return null;
533
+ var functionMatch = inputText.match(/^=([A-Za-z_][A-Za-z0-9_]*)\s*\(/);
534
+ if (functionMatch) {
535
+ return functionMatch[1].toUpperCase();
536
+ }
537
+ if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
538
+ var funcSpan = inputRef.current.querySelector(".luckysheet-formula-text-func");
539
+ if (funcSpan) {
540
+ return ((_b = funcSpan.textContent) === null || _b === void 0 ? void 0 : _b.toUpperCase()) || null;
541
+ }
542
+ }
543
+ return null;
544
+ }, []);
545
+ var functionName = context.functionHint || getFunctionNameFromInput();
546
+ var fn = functionName ? context.formulaCache.functionlistMap[functionName] : null;
530
547
  return /*#__PURE__*/_react.default.createElement("div", {
531
548
  className: "luckysheet-input-box",
532
549
  id: "luckysheet-input-box",
@@ -570,7 +587,7 @@ var InputBox = function InputBox() {
570
587
  onKeyDown: onKeyDown,
571
588
  onPaste: onPaste,
572
589
  allowEdit: edit ? !isHidenRC : edit
573
- })), (context.functionCandidates.length > 0 || context.functionHint || context.defaultCandidates.length > 0) && (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showSearchHint && (/*#__PURE__*/_react.default.createElement(_FormulaSearch.default, {
590
+ })), (context.functionCandidates.length > 0 || context.functionHint || context.defaultCandidates.length > 0 || fn) && (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showSearchHint && (/*#__PURE__*/_react.default.createElement(_FormulaSearch.default, {
574
591
  onMouseMove: function onMouseMove(e) {
575
592
  if (document.getElementById("luckysheet-formula-search-c")) {
576
593
  var hoveredItem = e.target.closest(".luckysheet-formula-search-item");
@@ -585,10 +602,11 @@ var InputBox = function InputBox() {
585
602
  }
586
603
  })), /*#__PURE__*/_react.default.createElement("div", {
587
604
  className: "cell-hint"
588
- }, showFormulaHint && fn && ((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.innerText.includes("(")) && (/*#__PURE__*/_react.default.createElement(_FormulaHint.default, {
605
+ }, showFormulaHint && fn && (/*#__PURE__*/_react.default.createElement(_FormulaHint.default, {
589
606
  handleShowFormulaHint: handleShowFormulaHint,
590
607
  showFormulaHint: showFormulaHint,
591
- commaCount: commaCount
608
+ commaCount: commaCount,
609
+ functionName: functionName
592
610
  })), !showFormulaHint && fn && (/*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
593
611
  text: "Turn on formula suggestions (F10)",
594
612
  placement: "top",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.79",
3
+ "version": "1.2.81-yield",
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.2.79",
19
+ "@fileverse-dev/fortune-core": "1.2.81-yield",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",