@fileverse-dev/fortune-react 1.0.2-mod-28-patch-1 → 1.0.2-mod-28-patch-2

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.
package/dist/index.esm.js CHANGED
@@ -820,7 +820,7 @@ var FormulaSearch = function FormulaSearch(props) {
820
820
  })), v.API_KEY && (/*#__PURE__*/React.createElement("div", {
821
821
  style: {
822
822
  borderRadius: "4px",
823
- backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#F9A92B"),
823
+ backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#e8ebec"),
824
824
  width: "16px",
825
825
  height: "16px"
826
826
  },
@@ -856,6 +856,10 @@ var FormulaHint = function FormulaHint(props) {
856
856
  _useState6 = _slicedToArray(_useState5, 2),
857
857
  isKeyAdded = _useState6[0],
858
858
  setApiKeyAdded = _useState6[1];
859
+ var _useState7 = useState(false),
860
+ _useState8 = _slicedToArray(_useState7, 2),
861
+ showFunctionBody = _useState8[0],
862
+ setShouldShowFunctionBody = _useState8[1];
859
863
  useEffect(function () {
860
864
  if (fn) {
861
865
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
@@ -863,12 +867,16 @@ var FormulaHint = function FormulaHint(props) {
863
867
  setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
864
868
  }
865
869
  }, [fn]);
870
+ var apiKeyPlaceholder = {
871
+ ETHERSCAN_API_KEY: "Etherscan API key"
872
+ };
866
873
  if (!fn) return null;
867
874
  return /*#__PURE__*/React.createElement("div", _objectSpread2(_objectSpread2({}, props), {}, {
868
875
  id: "luckysheet-formula-help-c",
869
876
  className: "luckysheet-formula-help-c",
870
877
  style: {
871
- border: "1px solid ".concat(fn.BRAND_COLOR),
878
+ borderWidth: "1px",
879
+ borderColor: (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) ? fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR : "#F8F9FA",
872
880
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
873
881
  width: "340px",
874
882
  padding: "0px"
@@ -886,13 +894,14 @@ var FormulaHint = function FormulaHint(props) {
886
894
  className: "fa fa-angle-up",
887
895
  "aria-hidden": "true"
888
896
  })), /*#__PURE__*/React.createElement("div", {
889
- className: "flex items-center justify-between",
897
+ className: "flex roun items-center justify-between",
890
898
  style: {
891
899
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
892
- padding: "10px"
900
+ padding: "10px",
901
+ borderRadius: "10px"
893
902
  }
894
903
  }, /*#__PURE__*/React.createElement("div", {
895
- className: "luckysheet-formula-help-title-formula color-text-default"
904
+ className: " flex-grow color-text-default"
896
905
  }, /*#__PURE__*/React.createElement("code", {
897
906
  style: {
898
907
  fontWeight: 500
@@ -947,7 +956,15 @@ var FormulaHint = function FormulaHint(props) {
947
956
  width: "12px",
948
957
  height: "12px"
949
958
  }
950
- }))))), /*#__PURE__*/React.createElement("div", {
959
+ }))), /*#__PURE__*/React.createElement("div", {
960
+ onClick: function onClick() {
961
+ setShouldShowFunctionBody(!showFunctionBody);
962
+ }
963
+ }, /*#__PURE__*/React.createElement(LucideIcon, {
964
+ name: "ChevronDown",
965
+ width: 16,
966
+ height: 16
967
+ })))), showFunctionBody && (/*#__PURE__*/React.createElement("div", {
951
968
  className: "luckysheet-formula-help-content",
952
969
  style: {
953
970
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA")
@@ -983,13 +1000,13 @@ var FormulaHint = function FormulaHint(props) {
983
1000
  margin: "0 0 16px 0"
984
1001
  },
985
1002
  className: "text-body-sm color-text-default"
986
- }, "This function is require API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React.createElement("div", {
1003
+ }, "This function requires an API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React.createElement("div", {
987
1004
  className: "w-full"
988
1005
  }, /*#__PURE__*/React.createElement(TextField, {
989
1006
  value: API_KEY,
990
1007
  id: "function-api-key",
991
1008
  type: "text",
992
- placeholder: "API key",
1009
+ placeholder: apiKeyPlaceholder[fn.API_KEY],
993
1010
  onChange: function onChange(e) {
994
1011
  setAPI_KEY(e.target.value);
995
1012
  setApiKeyAdded(false);
@@ -1041,7 +1058,7 @@ var FormulaHint = function FormulaHint(props) {
1041
1058
  }, ")")))), /*#__PURE__*/React.createElement("div", {
1042
1059
  className: "luckysheet-formula-help-content-detail",
1043
1060
  style: {
1044
- paddingBottom: "8px"
1061
+ paddingBottom: "16px"
1045
1062
  }
1046
1063
  }, /*#__PURE__*/React.createElement("div", {
1047
1064
  className: ""
@@ -1056,7 +1073,7 @@ var FormulaHint = function FormulaHint(props) {
1056
1073
  className: "luckysheet-arguments-help-parameter-content text-helper-text-sm"
1057
1074
  }, fn.d))), /*#__PURE__*/React.createElement("div", {
1058
1075
  style: {
1059
- paddingTop: "6px"
1076
+ paddingTop: "16px"
1060
1077
  },
1061
1078
  className: "luckysheet-formula-help-content-param"
1062
1079
  }, fn.p.map(function (param) {
@@ -1079,10 +1096,12 @@ var FormulaHint = function FormulaHint(props) {
1079
1096
  marginTop: "2px"
1080
1097
  }
1081
1098
  }, param.detail));
1082
- })))), /*#__PURE__*/React.createElement("div", {
1099
+ }))))), /*#__PURE__*/React.createElement("div", {
1083
1100
  style: {
1084
1101
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
1085
- padding: "8px"
1102
+ padding: "8px",
1103
+ borderBottomLeftRadius: "10px",
1104
+ borderBottomRightRadius: "10px"
1086
1105
  },
1087
1106
  className: "w-full"
1088
1107
  }, /*#__PURE__*/React.createElement("p", {
@@ -1233,6 +1252,48 @@ var InputBox = function InputBox() {
1233
1252
  e.stopPropagation();
1234
1253
  }
1235
1254
  }, [getActiveFormula, setContext]);
1255
+ var selectActiveFormulaOnClick = useCallback(function (e) {
1256
+ var activeFormula = getActiveFormula();
1257
+ var formulaNameDiv = activeFormula === null || activeFormula === void 0 ? void 0 : activeFormula.querySelector(".luckysheet-formula-search-func");
1258
+ if (formulaNameDiv) {
1259
+ var formulaName = formulaNameDiv.textContent;
1260
+ var textEditor = document.getElementById("luckysheet-rich-text-editor");
1261
+ if (textEditor) {
1262
+ var _getrangeseleciton2;
1263
+ var searchTxt = ((_getrangeseleciton2 = getrangeseleciton()) === null || _getrangeseleciton2 === void 0 ? void 0 : _getrangeseleciton2.textContent) || "";
1264
+ var deleteCount = searchTxt.length;
1265
+ textEditor.focus();
1266
+ var selection = window.getSelection();
1267
+ if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) === 0) return;
1268
+ var range = selection === null || selection === void 0 ? void 0 : selection.getRangeAt(0);
1269
+ if (deleteCount !== 0 && range) {
1270
+ var startOffset = Math.max(range.startOffset - deleteCount, 0);
1271
+ var endOffset = range.startOffset;
1272
+ range.setStart(range.startContainer, startOffset);
1273
+ range.setEnd(range.startContainer, endOffset);
1274
+ range.deleteContents();
1275
+ }
1276
+ var functionStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span>");
1277
+ var lParStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>";
1278
+ var functionNode = new DOMParser().parseFromString(functionStr, "text/html").body.childNodes[0];
1279
+ var lParNode = new DOMParser().parseFromString(lParStr, "text/html").body.childNodes[0];
1280
+ if (range === null || range === void 0 ? void 0 : range.startContainer.parentNode) {
1281
+ range === null || range === void 0 ? void 0 : range.setStart(range.startContainer.parentNode, 1);
1282
+ }
1283
+ range === null || range === void 0 ? void 0 : range.insertNode(lParNode);
1284
+ range === null || range === void 0 ? void 0 : range.insertNode(functionNode);
1285
+ range === null || range === void 0 ? void 0 : range.collapse();
1286
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
1287
+ if (range) selection === null || selection === void 0 ? void 0 : selection.addRange(range);
1288
+ setContext(function (draftCtx) {
1289
+ draftCtx.functionCandidates = [];
1290
+ draftCtx.functionHint = formulaName;
1291
+ });
1292
+ }
1293
+ e.preventDefault();
1294
+ e.stopPropagation();
1295
+ }
1296
+ }, [getActiveFormula, setContext]);
1236
1297
  var onKeyDown = useCallback(function (e) {
1237
1298
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
1238
1299
  preText.current = inputRef.current.innerText;
@@ -1352,6 +1413,18 @@ var InputBox = function InputBox() {
1352
1413
  })), document.activeElement === inputRef.current && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormulaSearch, {
1353
1414
  style: {
1354
1415
  top: ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0) + 4
1416
+ },
1417
+ onMouseOver: function onMouseOver(e) {
1418
+ if (document.getElementById("luckysheet-formula-search-c")) {
1419
+ var hoveredItem = e.target.closest(".luckysheet-formula-search-item");
1420
+ if (!hoveredItem) return;
1421
+ clearSearchItemActiveClass();
1422
+ hoveredItem.classList.add("luckysheet-formula-search-item-active");
1423
+ }
1424
+ e.preventDefault();
1425
+ },
1426
+ onClick: function onClick(e) {
1427
+ selectActiveFormulaOnClick(e);
1355
1428
  }
1356
1429
  }), /*#__PURE__*/React.createElement(FormulaHint, {
1357
1430
  style: {
package/dist/index.js CHANGED
@@ -832,7 +832,7 @@ var FormulaSearch = function FormulaSearch(props) {
832
832
  })), v.API_KEY && (/*#__PURE__*/React__default['default'].createElement("div", {
833
833
  style: {
834
834
  borderRadius: "4px",
835
- backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#F9A92B"),
835
+ backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#e8ebec"),
836
836
  width: "16px",
837
837
  height: "16px"
838
838
  },
@@ -868,6 +868,10 @@ var FormulaHint = function FormulaHint(props) {
868
868
  _useState6 = _slicedToArray(_useState5, 2),
869
869
  isKeyAdded = _useState6[0],
870
870
  setApiKeyAdded = _useState6[1];
871
+ var _useState7 = React.useState(false),
872
+ _useState8 = _slicedToArray(_useState7, 2),
873
+ showFunctionBody = _useState8[0],
874
+ setShouldShowFunctionBody = _useState8[1];
871
875
  React.useEffect(function () {
872
876
  if (fn) {
873
877
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
@@ -875,12 +879,16 @@ var FormulaHint = function FormulaHint(props) {
875
879
  setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
876
880
  }
877
881
  }, [fn]);
882
+ var apiKeyPlaceholder = {
883
+ ETHERSCAN_API_KEY: "Etherscan API key"
884
+ };
878
885
  if (!fn) return null;
879
886
  return /*#__PURE__*/React__default['default'].createElement("div", _objectSpread2(_objectSpread2({}, props), {}, {
880
887
  id: "luckysheet-formula-help-c",
881
888
  className: "luckysheet-formula-help-c",
882
889
  style: {
883
- border: "1px solid ".concat(fn.BRAND_COLOR),
890
+ borderWidth: "1px",
891
+ borderColor: (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) ? fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR : "#F8F9FA",
884
892
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
885
893
  width: "340px",
886
894
  padding: "0px"
@@ -898,13 +906,14 @@ var FormulaHint = function FormulaHint(props) {
898
906
  className: "fa fa-angle-up",
899
907
  "aria-hidden": "true"
900
908
  })), /*#__PURE__*/React__default['default'].createElement("div", {
901
- className: "flex items-center justify-between",
909
+ className: "flex roun items-center justify-between",
902
910
  style: {
903
911
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
904
- padding: "10px"
912
+ padding: "10px",
913
+ borderRadius: "10px"
905
914
  }
906
915
  }, /*#__PURE__*/React__default['default'].createElement("div", {
907
- className: "luckysheet-formula-help-title-formula color-text-default"
916
+ className: " flex-grow color-text-default"
908
917
  }, /*#__PURE__*/React__default['default'].createElement("code", {
909
918
  style: {
910
919
  fontWeight: 500
@@ -959,7 +968,15 @@ var FormulaHint = function FormulaHint(props) {
959
968
  width: "12px",
960
969
  height: "12px"
961
970
  }
962
- }))))), /*#__PURE__*/React__default['default'].createElement("div", {
971
+ }))), /*#__PURE__*/React__default['default'].createElement("div", {
972
+ onClick: function onClick() {
973
+ setShouldShowFunctionBody(!showFunctionBody);
974
+ }
975
+ }, /*#__PURE__*/React__default['default'].createElement(ui.LucideIcon, {
976
+ name: "ChevronDown",
977
+ width: 16,
978
+ height: 16
979
+ })))), showFunctionBody && (/*#__PURE__*/React__default['default'].createElement("div", {
963
980
  className: "luckysheet-formula-help-content",
964
981
  style: {
965
982
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA")
@@ -995,13 +1012,13 @@ var FormulaHint = function FormulaHint(props) {
995
1012
  margin: "0 0 16px 0"
996
1013
  },
997
1014
  className: "text-body-sm color-text-default"
998
- }, "This function is require API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React__default['default'].createElement("div", {
1015
+ }, "This function requires an API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React__default['default'].createElement("div", {
999
1016
  className: "w-full"
1000
1017
  }, /*#__PURE__*/React__default['default'].createElement(ui.TextField, {
1001
1018
  value: API_KEY,
1002
1019
  id: "function-api-key",
1003
1020
  type: "text",
1004
- placeholder: "API key",
1021
+ placeholder: apiKeyPlaceholder[fn.API_KEY],
1005
1022
  onChange: function onChange(e) {
1006
1023
  setAPI_KEY(e.target.value);
1007
1024
  setApiKeyAdded(false);
@@ -1053,7 +1070,7 @@ var FormulaHint = function FormulaHint(props) {
1053
1070
  }, ")")))), /*#__PURE__*/React__default['default'].createElement("div", {
1054
1071
  className: "luckysheet-formula-help-content-detail",
1055
1072
  style: {
1056
- paddingBottom: "8px"
1073
+ paddingBottom: "16px"
1057
1074
  }
1058
1075
  }, /*#__PURE__*/React__default['default'].createElement("div", {
1059
1076
  className: ""
@@ -1068,7 +1085,7 @@ var FormulaHint = function FormulaHint(props) {
1068
1085
  className: "luckysheet-arguments-help-parameter-content text-helper-text-sm"
1069
1086
  }, fn.d))), /*#__PURE__*/React__default['default'].createElement("div", {
1070
1087
  style: {
1071
- paddingTop: "6px"
1088
+ paddingTop: "16px"
1072
1089
  },
1073
1090
  className: "luckysheet-formula-help-content-param"
1074
1091
  }, fn.p.map(function (param) {
@@ -1091,10 +1108,12 @@ var FormulaHint = function FormulaHint(props) {
1091
1108
  marginTop: "2px"
1092
1109
  }
1093
1110
  }, param.detail));
1094
- })))), /*#__PURE__*/React__default['default'].createElement("div", {
1111
+ }))))), /*#__PURE__*/React__default['default'].createElement("div", {
1095
1112
  style: {
1096
1113
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
1097
- padding: "8px"
1114
+ padding: "8px",
1115
+ borderBottomLeftRadius: "10px",
1116
+ borderBottomRightRadius: "10px"
1098
1117
  },
1099
1118
  className: "w-full"
1100
1119
  }, /*#__PURE__*/React__default['default'].createElement("p", {
@@ -1245,6 +1264,48 @@ var InputBox = function InputBox() {
1245
1264
  e.stopPropagation();
1246
1265
  }
1247
1266
  }, [getActiveFormula, setContext]);
1267
+ var selectActiveFormulaOnClick = React.useCallback(function (e) {
1268
+ var activeFormula = getActiveFormula();
1269
+ var formulaNameDiv = activeFormula === null || activeFormula === void 0 ? void 0 : activeFormula.querySelector(".luckysheet-formula-search-func");
1270
+ if (formulaNameDiv) {
1271
+ var formulaName = formulaNameDiv.textContent;
1272
+ var textEditor = document.getElementById("luckysheet-rich-text-editor");
1273
+ if (textEditor) {
1274
+ var _getrangeseleciton2;
1275
+ var searchTxt = ((_getrangeseleciton2 = fortuneCore.getrangeseleciton()) === null || _getrangeseleciton2 === void 0 ? void 0 : _getrangeseleciton2.textContent) || "";
1276
+ var deleteCount = searchTxt.length;
1277
+ textEditor.focus();
1278
+ var selection = window.getSelection();
1279
+ if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) === 0) return;
1280
+ var range = selection === null || selection === void 0 ? void 0 : selection.getRangeAt(0);
1281
+ if (deleteCount !== 0 && range) {
1282
+ var startOffset = Math.max(range.startOffset - deleteCount, 0);
1283
+ var endOffset = range.startOffset;
1284
+ range.setStart(range.startContainer, startOffset);
1285
+ range.setEnd(range.startContainer, endOffset);
1286
+ range.deleteContents();
1287
+ }
1288
+ var functionStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span>");
1289
+ var lParStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>";
1290
+ var functionNode = new DOMParser().parseFromString(functionStr, "text/html").body.childNodes[0];
1291
+ var lParNode = new DOMParser().parseFromString(lParStr, "text/html").body.childNodes[0];
1292
+ if (range === null || range === void 0 ? void 0 : range.startContainer.parentNode) {
1293
+ range === null || range === void 0 ? void 0 : range.setStart(range.startContainer.parentNode, 1);
1294
+ }
1295
+ range === null || range === void 0 ? void 0 : range.insertNode(lParNode);
1296
+ range === null || range === void 0 ? void 0 : range.insertNode(functionNode);
1297
+ range === null || range === void 0 ? void 0 : range.collapse();
1298
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
1299
+ if (range) selection === null || selection === void 0 ? void 0 : selection.addRange(range);
1300
+ setContext(function (draftCtx) {
1301
+ draftCtx.functionCandidates = [];
1302
+ draftCtx.functionHint = formulaName;
1303
+ });
1304
+ }
1305
+ e.preventDefault();
1306
+ e.stopPropagation();
1307
+ }
1308
+ }, [getActiveFormula, setContext]);
1248
1309
  var onKeyDown = React.useCallback(function (e) {
1249
1310
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
1250
1311
  preText.current = inputRef.current.innerText;
@@ -1364,6 +1425,18 @@ var InputBox = function InputBox() {
1364
1425
  })), document.activeElement === inputRef.current && (/*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(FormulaSearch, {
1365
1426
  style: {
1366
1427
  top: ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0) + 4
1428
+ },
1429
+ onMouseOver: function onMouseOver(e) {
1430
+ if (document.getElementById("luckysheet-formula-search-c")) {
1431
+ var hoveredItem = e.target.closest(".luckysheet-formula-search-item");
1432
+ if (!hoveredItem) return;
1433
+ clearSearchItemActiveClass();
1434
+ hoveredItem.classList.add("luckysheet-formula-search-item-active");
1435
+ }
1436
+ e.preventDefault();
1437
+ },
1438
+ onClick: function onClick(e) {
1439
+ selectActiveFormulaOnClick(e);
1367
1440
  }
1368
1441
  }), /*#__PURE__*/React__default['default'].createElement(FormulaHint, {
1369
1442
  style: {
package/dist/index.umd.js CHANGED
@@ -102134,7 +102134,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102134
102134
  })), v.API_KEY && (/*#__PURE__*/React__default['default'].createElement("div", {
102135
102135
  style: {
102136
102136
  borderRadius: "4px",
102137
- backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#F9A92B"),
102137
+ backgroundColor: "".concat(localStorage.getItem(v.API_KEY) ? "#177E23" : "#e8ebec"),
102138
102138
  width: "16px",
102139
102139
  height: "16px"
102140
102140
  },
@@ -102170,6 +102170,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102170
102170
  _useState6 = _slicedToArray(_useState5, 2),
102171
102171
  isKeyAdded = _useState6[0],
102172
102172
  setApiKeyAdded = _useState6[1];
102173
+ var _useState7 = React.useState(false),
102174
+ _useState8 = _slicedToArray(_useState7, 2),
102175
+ showFunctionBody = _useState8[0],
102176
+ setShouldShowFunctionBody = _useState8[1];
102173
102177
  React.useEffect(function () {
102174
102178
  if (fn) {
102175
102179
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
@@ -102177,12 +102181,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102177
102181
  setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
102178
102182
  }
102179
102183
  }, [fn]);
102184
+ var apiKeyPlaceholder = {
102185
+ ETHERSCAN_API_KEY: "Etherscan API key"
102186
+ };
102180
102187
  if (!fn) return null;
102181
102188
  return /*#__PURE__*/React__default['default'].createElement("div", _objectSpread2(_objectSpread2({}, props), {}, {
102182
102189
  id: "luckysheet-formula-help-c",
102183
102190
  className: "luckysheet-formula-help-c",
102184
102191
  style: {
102185
- border: "1px solid ".concat(fn.BRAND_COLOR),
102192
+ borderWidth: "1px",
102193
+ borderColor: (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) ? fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR : "#F8F9FA",
102186
102194
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
102187
102195
  width: "340px",
102188
102196
  padding: "0px"
@@ -102200,13 +102208,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102200
102208
  className: "fa fa-angle-up",
102201
102209
  "aria-hidden": "true"
102202
102210
  })), /*#__PURE__*/React__default['default'].createElement("div", {
102203
- className: "flex items-center justify-between",
102211
+ className: "flex roun items-center justify-between",
102204
102212
  style: {
102205
102213
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
102206
- padding: "10px"
102214
+ padding: "10px",
102215
+ borderRadius: "10px"
102207
102216
  }
102208
102217
  }, /*#__PURE__*/React__default['default'].createElement("div", {
102209
- className: "luckysheet-formula-help-title-formula color-text-default"
102218
+ className: " flex-grow color-text-default"
102210
102219
  }, /*#__PURE__*/React__default['default'].createElement("code", {
102211
102220
  style: {
102212
102221
  fontWeight: 500
@@ -102261,7 +102270,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102261
102270
  width: "12px",
102262
102271
  height: "12px"
102263
102272
  }
102264
- }))))), /*#__PURE__*/React__default['default'].createElement("div", {
102273
+ }))), /*#__PURE__*/React__default['default'].createElement("div", {
102274
+ onClick: function onClick() {
102275
+ setShouldShowFunctionBody(!showFunctionBody);
102276
+ }
102277
+ }, /*#__PURE__*/React__default['default'].createElement(be, {
102278
+ name: "ChevronDown",
102279
+ width: 16,
102280
+ height: 16
102281
+ })))), showFunctionBody && (/*#__PURE__*/React__default['default'].createElement("div", {
102265
102282
  className: "luckysheet-formula-help-content",
102266
102283
  style: {
102267
102284
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA")
@@ -102297,13 +102314,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102297
102314
  margin: "0 0 16px 0"
102298
102315
  },
102299
102316
  className: "text-body-sm color-text-default"
102300
- }, "This function is require API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React__default['default'].createElement("div", {
102317
+ }, "This function requires an API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React__default['default'].createElement("div", {
102301
102318
  className: "w-full"
102302
102319
  }, /*#__PURE__*/React__default['default'].createElement(I0, {
102303
102320
  value: API_KEY,
102304
102321
  id: "function-api-key",
102305
102322
  type: "text",
102306
- placeholder: "API key",
102323
+ placeholder: apiKeyPlaceholder[fn.API_KEY],
102307
102324
  onChange: function onChange(e) {
102308
102325
  setAPI_KEY(e.target.value);
102309
102326
  setApiKeyAdded(false);
@@ -102355,7 +102372,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102355
102372
  }, ")")))), /*#__PURE__*/React__default['default'].createElement("div", {
102356
102373
  className: "luckysheet-formula-help-content-detail",
102357
102374
  style: {
102358
- paddingBottom: "8px"
102375
+ paddingBottom: "16px"
102359
102376
  }
102360
102377
  }, /*#__PURE__*/React__default['default'].createElement("div", {
102361
102378
  className: ""
@@ -102370,7 +102387,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102370
102387
  className: "luckysheet-arguments-help-parameter-content text-helper-text-sm"
102371
102388
  }, fn.d))), /*#__PURE__*/React__default['default'].createElement("div", {
102372
102389
  style: {
102373
- paddingTop: "6px"
102390
+ paddingTop: "16px"
102374
102391
  },
102375
102392
  className: "luckysheet-formula-help-content-param"
102376
102393
  }, fn.p.map(function (param) {
@@ -102393,10 +102410,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102393
102410
  marginTop: "2px"
102394
102411
  }
102395
102412
  }, param.detail));
102396
- })))), /*#__PURE__*/React__default['default'].createElement("div", {
102413
+ }))))), /*#__PURE__*/React__default['default'].createElement("div", {
102397
102414
  style: {
102398
102415
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
102399
- padding: "8px"
102416
+ padding: "8px",
102417
+ borderBottomLeftRadius: "10px",
102418
+ borderBottomRightRadius: "10px"
102400
102419
  },
102401
102420
  className: "w-full"
102402
102421
  }, /*#__PURE__*/React__default['default'].createElement("p", {
@@ -102547,6 +102566,48 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102547
102566
  e.stopPropagation();
102548
102567
  }
102549
102568
  }, [getActiveFormula, setContext]);
102569
+ var selectActiveFormulaOnClick = React.useCallback(function (e) {
102570
+ var activeFormula = getActiveFormula();
102571
+ var formulaNameDiv = activeFormula === null || activeFormula === void 0 ? void 0 : activeFormula.querySelector(".luckysheet-formula-search-func");
102572
+ if (formulaNameDiv) {
102573
+ var formulaName = formulaNameDiv.textContent;
102574
+ var textEditor = document.getElementById("luckysheet-rich-text-editor");
102575
+ if (textEditor) {
102576
+ var _getrangeseleciton2;
102577
+ var searchTxt = ((_getrangeseleciton2 = getrangeseleciton()) === null || _getrangeseleciton2 === void 0 ? void 0 : _getrangeseleciton2.textContent) || "";
102578
+ var deleteCount = searchTxt.length;
102579
+ textEditor.focus();
102580
+ var selection = window.getSelection();
102581
+ if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) === 0) return;
102582
+ var range = selection === null || selection === void 0 ? void 0 : selection.getRangeAt(0);
102583
+ if (deleteCount !== 0 && range) {
102584
+ var startOffset = Math.max(range.startOffset - deleteCount, 0);
102585
+ var endOffset = range.startOffset;
102586
+ range.setStart(range.startContainer, startOffset);
102587
+ range.setEnd(range.startContainer, endOffset);
102588
+ range.deleteContents();
102589
+ }
102590
+ var functionStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span>");
102591
+ var lParStr = "<span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>";
102592
+ var functionNode = new DOMParser().parseFromString(functionStr, "text/html").body.childNodes[0];
102593
+ var lParNode = new DOMParser().parseFromString(lParStr, "text/html").body.childNodes[0];
102594
+ if (range === null || range === void 0 ? void 0 : range.startContainer.parentNode) {
102595
+ range === null || range === void 0 ? void 0 : range.setStart(range.startContainer.parentNode, 1);
102596
+ }
102597
+ range === null || range === void 0 ? void 0 : range.insertNode(lParNode);
102598
+ range === null || range === void 0 ? void 0 : range.insertNode(functionNode);
102599
+ range === null || range === void 0 ? void 0 : range.collapse();
102600
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
102601
+ if (range) selection === null || selection === void 0 ? void 0 : selection.addRange(range);
102602
+ setContext(function (draftCtx) {
102603
+ draftCtx.functionCandidates = [];
102604
+ draftCtx.functionHint = formulaName;
102605
+ });
102606
+ }
102607
+ e.preventDefault();
102608
+ e.stopPropagation();
102609
+ }
102610
+ }, [getActiveFormula, setContext]);
102550
102611
  var onKeyDown = React.useCallback(function (e) {
102551
102612
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
102552
102613
  preText.current = inputRef.current.innerText;
@@ -102666,6 +102727,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
102666
102727
  })), document.activeElement === inputRef.current && (/*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(FormulaSearch, {
102667
102728
  style: {
102668
102729
  top: ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0) + 4
102730
+ },
102731
+ onMouseOver: function onMouseOver(e) {
102732
+ if (document.getElementById("luckysheet-formula-search-c")) {
102733
+ var hoveredItem = e.target.closest(".luckysheet-formula-search-item");
102734
+ if (!hoveredItem) return;
102735
+ clearSearchItemActiveClass();
102736
+ hoveredItem.classList.add("luckysheet-formula-search-item-active");
102737
+ }
102738
+ e.preventDefault();
102739
+ },
102740
+ onClick: function onClick(e) {
102741
+ selectActiveFormulaOnClick(e);
102669
102742
  }
102670
102743
  }), /*#__PURE__*/React__default['default'].createElement(FormulaHint, {
102671
102744
  style: {