@univerjs/sheets-formula-ui 1.0.0-alpha.3 → 1.0.0-alpha.4
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/lib/cjs/index.js +105 -90
- package/lib/es/index.js +107 -92
- package/lib/index.css +75 -0
- package/lib/index.js +107 -92
- package/lib/umd/index.js +4 -4
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -833,11 +833,12 @@ function createInsertFunctionCategoryMenuItemFactory(functionType, categoryKey,
|
|
|
833
833
|
} catch {
|
|
834
834
|
selections = [];
|
|
835
835
|
}
|
|
836
|
+
const localeKey = `sheets-formula-ui.functionType.${categoryKey}`;
|
|
836
837
|
return {
|
|
837
838
|
id: `${InsertFunctionOperation.id}.${categoryKey}`,
|
|
838
839
|
commandId: InsertFunctionOperation.id,
|
|
839
|
-
title:
|
|
840
|
-
tooltip:
|
|
840
|
+
title: localeKey,
|
|
841
|
+
tooltip: localeKey,
|
|
841
842
|
icon,
|
|
842
843
|
type: _univerjs_ui.MenuItemType.SELECTOR,
|
|
843
844
|
selections,
|
|
@@ -845,16 +846,16 @@ function createInsertFunctionCategoryMenuItemFactory(functionType, categoryKey,
|
|
|
845
846
|
};
|
|
846
847
|
};
|
|
847
848
|
}
|
|
848
|
-
const InsertFinancialFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Financial, "financial");
|
|
849
|
-
const InsertLogicalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Logical, "logical");
|
|
850
|
-
const InsertTextFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Text, "text");
|
|
851
|
-
const InsertDateFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Date, "date");
|
|
852
|
-
const InsertLookupFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Lookup, "lookup");
|
|
853
|
-
const InsertMathFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Math, "math");
|
|
854
|
-
const InsertStatisticalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Statistical, "statistical");
|
|
855
|
-
const InsertEngineeringFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Engineering, "engineering");
|
|
856
|
-
const InsertInformationFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Information, "information");
|
|
857
|
-
const InsertDatabaseFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Database, "database");
|
|
849
|
+
const InsertFinancialFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Financial, "financial", "FinancialFunctionIcon");
|
|
850
|
+
const InsertLogicalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Logical, "logical", "LogicalFunctionIcon");
|
|
851
|
+
const InsertTextFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Text, "text", "TextFunctionIcon");
|
|
852
|
+
const InsertDateFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Date, "date", "DateFunctionIcon");
|
|
853
|
+
const InsertLookupFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Lookup, "lookup", "LookupFunctionIcon");
|
|
854
|
+
const InsertMathFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Math, "math", "MathFunctionIcon");
|
|
855
|
+
const InsertStatisticalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Statistical, "statistical", "StatisticalFunctionIcon");
|
|
856
|
+
const InsertEngineeringFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Engineering, "engineering", "EngineeringFunctionIcon");
|
|
857
|
+
const InsertInformationFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Information, "information", "InformationFunctionIcon");
|
|
858
|
+
const InsertDatabaseFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(_univerjs_engine_formula.FunctionType.Database, "database", "DatabaseFunctionIcon");
|
|
858
859
|
function AllFunctionsMenuItemFactory(accessor) {
|
|
859
860
|
return {
|
|
860
861
|
id: MoreFunctionsOperation.id,
|
|
@@ -910,83 +911,43 @@ const menuSchema = {
|
|
|
910
911
|
},
|
|
911
912
|
[`${InsertFunctionOperation.id}.financial`]: {
|
|
912
913
|
order: 1,
|
|
913
|
-
menuItemFactory: InsertFinancialFunctionMenuItemFactory
|
|
914
|
-
[MoreFunctionsOperation.id]: {
|
|
915
|
-
order: 0,
|
|
916
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
917
|
-
}
|
|
914
|
+
menuItemFactory: InsertFinancialFunctionMenuItemFactory
|
|
918
915
|
},
|
|
919
916
|
[`${InsertFunctionOperation.id}.logical`]: {
|
|
920
917
|
order: 2,
|
|
921
|
-
menuItemFactory: InsertLogicalFunctionMenuItemFactory
|
|
922
|
-
[MoreFunctionsOperation.id]: {
|
|
923
|
-
order: 0,
|
|
924
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
925
|
-
}
|
|
918
|
+
menuItemFactory: InsertLogicalFunctionMenuItemFactory
|
|
926
919
|
},
|
|
927
920
|
[`${InsertFunctionOperation.id}.text`]: {
|
|
928
921
|
order: 3,
|
|
929
|
-
menuItemFactory: InsertTextFunctionMenuItemFactory
|
|
930
|
-
[MoreFunctionsOperation.id]: {
|
|
931
|
-
order: 0,
|
|
932
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
933
|
-
}
|
|
922
|
+
menuItemFactory: InsertTextFunctionMenuItemFactory
|
|
934
923
|
},
|
|
935
924
|
[`${InsertFunctionOperation.id}.date`]: {
|
|
936
925
|
order: 4,
|
|
937
|
-
menuItemFactory: InsertDateFunctionMenuItemFactory
|
|
938
|
-
[MoreFunctionsOperation.id]: {
|
|
939
|
-
order: 0,
|
|
940
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
941
|
-
}
|
|
926
|
+
menuItemFactory: InsertDateFunctionMenuItemFactory
|
|
942
927
|
},
|
|
943
928
|
[`${InsertFunctionOperation.id}.lookup`]: {
|
|
944
929
|
order: 5,
|
|
945
|
-
menuItemFactory: InsertLookupFunctionMenuItemFactory
|
|
946
|
-
[MoreFunctionsOperation.id]: {
|
|
947
|
-
order: 0,
|
|
948
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
949
|
-
}
|
|
930
|
+
menuItemFactory: InsertLookupFunctionMenuItemFactory
|
|
950
931
|
},
|
|
951
932
|
[`${InsertFunctionOperation.id}.math`]: {
|
|
952
933
|
order: 6,
|
|
953
|
-
menuItemFactory: InsertMathFunctionMenuItemFactory
|
|
954
|
-
[MoreFunctionsOperation.id]: {
|
|
955
|
-
order: 0,
|
|
956
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
957
|
-
}
|
|
934
|
+
menuItemFactory: InsertMathFunctionMenuItemFactory
|
|
958
935
|
},
|
|
959
936
|
[`${InsertFunctionOperation.id}.statistical`]: {
|
|
960
937
|
order: 7,
|
|
961
|
-
menuItemFactory: InsertStatisticalFunctionMenuItemFactory
|
|
962
|
-
[MoreFunctionsOperation.id]: {
|
|
963
|
-
order: 0,
|
|
964
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
965
|
-
}
|
|
938
|
+
menuItemFactory: InsertStatisticalFunctionMenuItemFactory
|
|
966
939
|
},
|
|
967
940
|
[`${InsertFunctionOperation.id}.engineering`]: {
|
|
968
941
|
order: 8,
|
|
969
|
-
menuItemFactory: InsertEngineeringFunctionMenuItemFactory
|
|
970
|
-
[MoreFunctionsOperation.id]: {
|
|
971
|
-
order: 0,
|
|
972
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
973
|
-
}
|
|
942
|
+
menuItemFactory: InsertEngineeringFunctionMenuItemFactory
|
|
974
943
|
},
|
|
975
944
|
[`${InsertFunctionOperation.id}.information`]: {
|
|
976
945
|
order: 9,
|
|
977
|
-
menuItemFactory: InsertInformationFunctionMenuItemFactory
|
|
978
|
-
[MoreFunctionsOperation.id]: {
|
|
979
|
-
order: 0,
|
|
980
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
981
|
-
}
|
|
946
|
+
menuItemFactory: InsertInformationFunctionMenuItemFactory
|
|
982
947
|
},
|
|
983
948
|
[`${InsertFunctionOperation.id}.database`]: {
|
|
984
949
|
order: 10,
|
|
985
|
-
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
986
|
-
[MoreFunctionsOperation.id]: {
|
|
987
|
-
order: 0,
|
|
988
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
989
|
-
}
|
|
950
|
+
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
990
951
|
}
|
|
991
952
|
},
|
|
992
953
|
[_univerjs_sheets_ui.COPY_SPECIAL_MENU_ID]: { [SheetCopyFormulaOnlyCommand.id]: {
|
|
@@ -1002,7 +963,7 @@ const menuSchema = {
|
|
|
1002
963
|
//#endregion
|
|
1003
964
|
//#region package.json
|
|
1004
965
|
var name = "@univerjs/sheets-formula-ui";
|
|
1005
|
-
var version = "1.0.0-alpha.
|
|
966
|
+
var version = "1.0.0-alpha.4";
|
|
1006
967
|
|
|
1007
968
|
//#endregion
|
|
1008
969
|
//#region src/config/config.ts
|
|
@@ -3296,7 +3257,7 @@ function SearchFunctionFactory(props, ref) {
|
|
|
3296
3257
|
const shortcutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IShortcutService);
|
|
3297
3258
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
3298
3259
|
const { searchList, searchText, handlerFormulaReplace, reset: resetFormulaSearch } = useFormulaSearch(isFocus, sequenceNodes, editor);
|
|
3299
|
-
const visible =
|
|
3260
|
+
const visible = searchList.length > 0;
|
|
3300
3261
|
const ulRef = (0, react.useRef)(void 0);
|
|
3301
3262
|
const [active, setActive] = (0, react.useState)(0);
|
|
3302
3263
|
const isEnableMouseEnterOrOut = (0, react.useRef)(false);
|
|
@@ -3482,7 +3443,7 @@ function syncCounterpartFormulaEditorSelection(editorService, editorId, selectio
|
|
|
3482
3443
|
(_editorService$getEdi = editorService.getEditor(syncEditorId)) === null || _editorService$getEdi === void 0 || _editorService$getEdi.setSelectionRanges(selections, false);
|
|
3483
3444
|
}
|
|
3484
3445
|
const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
3485
|
-
var _document$getBody$
|
|
3446
|
+
var _document$getBody$dat2, _document$getBody2, _configService$getCon, _configService$getCon2;
|
|
3486
3447
|
const { errorText, initValue, unitId, subUnitId, isFocus: _isFocus = true, isSupportAcrossSheet = false, onFocus = _univerjs_core.noop, onBlur = _univerjs_core.noop, onChange: propOnChange, onVerify, className, editorId: propEditorId, moveCursor = true, onFormulaSelectingChange: propOnFormulaSelectingChange, keyboardEventConfig, onMoveInEditor, resetSelectionOnBlur = true, autoScrollbar = true, isSingle = true, disableSelectionOnClick = false, autofocus = true, disableContextMenu, style, borderless = false, canvasStyle } = props;
|
|
3487
3448
|
const editorService = (0, _univerjs_ui.useDependency)(_univerjs_docs_ui.IEditorService);
|
|
3488
3449
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
@@ -3500,12 +3461,14 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
3500
3461
|
const [isFocus, setIsFocus] = (0, react.useState)(_isFocus);
|
|
3501
3462
|
const formulaEditorContainerRef = (0, react.useRef)(null);
|
|
3502
3463
|
const editorId = (0, react.useMemo)(() => propEditorId !== null && propEditorId !== void 0 ? propEditorId : (0, _univerjs_core.createInternalEditorID)(`${_univerjs_sheets_ui.EMBEDDING_FORMULA_EDITOR}-${(0, _univerjs_core.generateRandomId)(4)}`), []);
|
|
3503
|
-
const isError =
|
|
3464
|
+
const isError = errorText !== void 0;
|
|
3504
3465
|
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
3505
3466
|
const document = univerInstanceService.getUnit(editorId);
|
|
3506
|
-
(0, _univerjs_ui.useObservable)(document === null || document === void 0 ? void 0 : document.change$);
|
|
3507
3467
|
const getFormulaToken = useFormulaToken();
|
|
3508
|
-
const formulaText =
|
|
3468
|
+
const formulaText = (0, _univerjs_ui.useObservable)(document ? () => document.change$.pipe((0, rxjs.map)(() => {
|
|
3469
|
+
var _document$getBody$dat, _document$getBody;
|
|
3470
|
+
return _univerjs_core.BuildTextUtils.transform.getPlainText((_document$getBody$dat = (_document$getBody = document.getBody()) === null || _document$getBody === void 0 ? void 0 : _document$getBody.dataStream) !== null && _document$getBody$dat !== void 0 ? _document$getBody$dat : "");
|
|
3471
|
+
})) : null, _univerjs_core.BuildTextUtils.transform.getPlainText((_document$getBody$dat2 = document === null || document === void 0 || (_document$getBody2 = document.getBody()) === null || _document$getBody2 === void 0 ? void 0 : _document$getBody2.dataStream) !== null && _document$getBody$dat2 !== void 0 ? _document$getBody$dat2 : ""), false, [document]);
|
|
3509
3472
|
const formulaTextRef = useStateRef(formulaText);
|
|
3510
3473
|
const formulaWithoutEqualSymbol = (0, react.useMemo)(() => getFormulaText(formulaText), [formulaText]);
|
|
3511
3474
|
const sequenceNodes = (0, react.useMemo)(() => getFormulaToken(formulaWithoutEqualSymbol), [formulaWithoutEqualSymbol, getFormulaToken]);
|
|
@@ -3523,8 +3486,8 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
3523
3486
|
const isFocusing = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing;
|
|
3524
3487
|
const currentDoc = (0, _univerjs_ui.useObservable)((0, react.useMemo)(() => univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC), [univerInstanceService]));
|
|
3525
3488
|
const docFocusing = (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) === editorId;
|
|
3526
|
-
const
|
|
3527
|
-
const getRefSelections = (0, _univerjs_ui.useEvent)(() =>
|
|
3489
|
+
const refSelectionsRef = (0, react.useRef)([]);
|
|
3490
|
+
const getRefSelections = (0, _univerjs_ui.useEvent)(() => refSelectionsRef.current);
|
|
3528
3491
|
const getRefSelectionCount = (0, _univerjs_ui.useEvent)(() => getRefSelections().length);
|
|
3529
3492
|
const selectingMode = isSelecting;
|
|
3530
3493
|
const functionScreenTips = (_configService$getCon = (_configService$getCon2 = (0, _univerjs_ui.useDependency)(_univerjs_core.IConfigService).getConfig("sheets-formula-ui.base.config")) === null || _configService$getCon2 === void 0 ? void 0 : _configService$getCon2.functionScreenTips) !== null && _configService$getCon !== void 0 ? _configService$getCon : true;
|
|
@@ -3560,7 +3523,7 @@ const FormulaEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
3560
3523
|
const formulaStr = text[0] === "=" ? text.slice(1) : "";
|
|
3561
3524
|
const sequenceNodes = getFormulaToken(formulaStr);
|
|
3562
3525
|
const ranges = highlightDoc(editorRef.current, sequenceNodes, isNeedResetSelection, newSelections, formulaStr);
|
|
3563
|
-
|
|
3526
|
+
refSelectionsRef.current = ranges;
|
|
3564
3527
|
if (isEnd) {
|
|
3565
3528
|
const currentDocSelections = newSelections !== null && newSelections !== void 0 ? newSelections : editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges();
|
|
3566
3529
|
if ((currentDocSelections === null || currentDocSelections === void 0 ? void 0 : currentDocSelections.length) === 1) {
|
|
@@ -3859,6 +3822,13 @@ function FunctionParams(props) {
|
|
|
3859
3822
|
function InputParams(props) {
|
|
3860
3823
|
const { functionInfo, onChange } = props;
|
|
3861
3824
|
if (!functionInfo) return null;
|
|
3825
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputParamsInner, {
|
|
3826
|
+
functionInfo,
|
|
3827
|
+
onChange
|
|
3828
|
+
});
|
|
3829
|
+
}
|
|
3830
|
+
function InputParamsInner(props) {
|
|
3831
|
+
const { functionInfo, onChange } = props;
|
|
3862
3832
|
const [params, setParams] = (0, react.useState)([]);
|
|
3863
3833
|
const [functionParameter, setFunctionParameter] = (0, react.useState)(functionInfo.functionParameter);
|
|
3864
3834
|
const [activeIndex, setActiveIndex] = (0, react.useState)(-1);
|
|
@@ -4003,27 +3973,60 @@ function SelectFunction(props) {
|
|
|
4003
3973
|
}, index))
|
|
4004
3974
|
}),
|
|
4005
3975
|
functionInfo && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4006
|
-
|
|
3976
|
+
"data-u-comp": "formula-function-details",
|
|
3977
|
+
className: (0, _univerjs_design.clsx)("univer-mx-0 univer-my-3 univer-overflow-y-auto", _univerjs_design.scrollbarClassName),
|
|
4007
3978
|
children: [
|
|
4008
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
})
|
|
3979
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3980
|
+
className: "univer-rounded-lg univer-bg-gray-50 univer-p-3 dark:!univer-bg-gray-800",
|
|
3981
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3982
|
+
className: "univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-white",
|
|
3983
|
+
children: functionInfo.functionName
|
|
3984
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3985
|
+
className: "univer-mt-1 univer-text-xs univer-leading-5 univer-text-gray-600 dark:!univer-text-gray-300",
|
|
3986
|
+
children: functionInfo.description
|
|
3987
|
+
})]
|
|
4018
3988
|
}),
|
|
4019
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
4020
|
-
|
|
4021
|
-
|
|
3989
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3990
|
+
className: "univer-mt-4 univer-flex univer-flex-col univer-gap-3",
|
|
3991
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3992
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
|
|
3993
|
+
children: localeService.t("sheets-formula-ui.moreFunctions.syntax")
|
|
3994
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3995
|
+
"data-u-comp": "formula-function-syntax",
|
|
3996
|
+
className: (0, _univerjs_design.clsx)("univer-mt-1.5 univer-break-words univer-rounded-md univer-bg-gray-50 univer-px-3 univer-py-2 univer-font-mono univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-bg-gray-800 dark:!univer-text-white", _univerjs_design.borderClassName),
|
|
3997
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FunctionHelp, {
|
|
3998
|
+
prefix: functionInfo.functionName,
|
|
3999
|
+
value: functionInfo.functionParameter
|
|
4000
|
+
})
|
|
4001
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4002
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
|
|
4003
|
+
children: localeService.t("sheets-formula-ui.prompt.helpExample")
|
|
4004
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4005
|
+
"data-u-comp": "formula-function-example",
|
|
4006
|
+
className: (0, _univerjs_design.clsx)("univer-mt-1.5 univer-break-words univer-rounded-md univer-bg-gray-50 univer-px-3 univer-py-2 univer-font-mono univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-bg-gray-800 dark:!univer-text-white", _univerjs_design.borderClassName),
|
|
4007
|
+
children: `${functionInfo.functionName}(${functionInfo.functionParameter.map((item) => item.example).join(",")})`
|
|
4008
|
+
})] })]
|
|
4022
4009
|
}),
|
|
4023
|
-
functionInfo.functionParameter
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4010
|
+
functionInfo.functionParameter.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4011
|
+
className: (0, _univerjs_design.clsx)("univer-mt-4 univer-rounded-lg univer-px-3", _univerjs_design.borderClassName, _univerjs_design.divideYClassName),
|
|
4012
|
+
children: functionInfo.functionParameter.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4013
|
+
"data-u-comp": "formula-function-parameter",
|
|
4014
|
+
className: "univer-py-3",
|
|
4015
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4016
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
4017
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4018
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-900 dark:!univer-text-white",
|
|
4019
|
+
children: item.name
|
|
4020
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4021
|
+
className: (0, _univerjs_design.clsx)("univer-rounded-full univer-px-2 univer-py-0.5 univer-text-xs univer-leading-4", item.require ? "univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900 dark:!univer-text-primary-200" : "univer-bg-gray-100 univer-text-gray-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-200"),
|
|
4022
|
+
children: item.require ? required : optional
|
|
4023
|
+
})]
|
|
4024
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4025
|
+
className: "univer-mt-1 univer-text-xs univer-leading-5 univer-text-gray-600 dark:!univer-text-gray-300",
|
|
4026
|
+
children: item.detail
|
|
4027
|
+
})]
|
|
4028
|
+
}, item.name))
|
|
4029
|
+
})
|
|
4027
4030
|
]
|
|
4028
4031
|
})
|
|
4029
4032
|
] });
|
|
@@ -4509,7 +4512,19 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
4509
4512
|
this._registerComponents();
|
|
4510
4513
|
}
|
|
4511
4514
|
_registerIcons() {
|
|
4512
|
-
this.disposeWithMe(this._iconManager.register({
|
|
4515
|
+
this.disposeWithMe(this._iconManager.register({
|
|
4516
|
+
DatabaseFunctionIcon: _univerjs_icons.DatabaseFunctionIcon,
|
|
4517
|
+
DateFunctionIcon: _univerjs_icons.DateFunctionIcon,
|
|
4518
|
+
EngineeringFunctionIcon: _univerjs_icons.EngineeringFunctionIcon,
|
|
4519
|
+
FinancialFunctionIcon: _univerjs_icons.FinancialFunctionIcon,
|
|
4520
|
+
FunctionIcon: _univerjs_icons.FunctionIcon,
|
|
4521
|
+
InformationFunctionIcon: _univerjs_icons.InformationFunctionIcon,
|
|
4522
|
+
LogicalFunctionIcon: _univerjs_icons.LogicalFunctionIcon,
|
|
4523
|
+
LookupFunctionIcon: _univerjs_icons.LookupFunctionIcon,
|
|
4524
|
+
MathFunctionIcon: _univerjs_icons.MathFunctionIcon,
|
|
4525
|
+
StatisticalFunctionIcon: _univerjs_icons.StatisticalFunctionIcon,
|
|
4526
|
+
TextFunctionIcon: _univerjs_icons.TextFunctionIcon
|
|
4527
|
+
}));
|
|
4513
4528
|
}
|
|
4514
4529
|
_registerComponents() {
|
|
4515
4530
|
this.disposeWithMe(this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions));
|
package/lib/es/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTI
|
|
|
8
8
|
import { IDescriptionService, ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, QuickSumCommand, TriggerCalculationController, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
9
9
|
import { BuiltInUIPart, ComponentManager, IContextMenuService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, ProgressBar, RectPopup, RibbonFormulasGroup, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
|
|
10
10
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
11
|
-
import { CheckMarkIcon, CloseIcon, DeleteIcon, FunctionIcon, IncreaseIcon, MoreRightIcon, SelectRangeIcon } from "@univerjs/icons";
|
|
12
|
-
import { Button, Dialog, Input, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
11
|
+
import { CheckMarkIcon, CloseIcon, DatabaseFunctionIcon, DateFunctionIcon, DeleteIcon, EngineeringFunctionIcon, FinancialFunctionIcon, FunctionIcon, IncreaseIcon, InformationFunctionIcon, LogicalFunctionIcon, LookupFunctionIcon, MathFunctionIcon, MoreRightIcon, SelectRangeIcon, StatisticalFunctionIcon, TextFunctionIcon } from "@univerjs/icons";
|
|
12
|
+
import { Button, Dialog, Input, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
|
|
13
13
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
@@ -832,11 +832,12 @@ function createInsertFunctionCategoryMenuItemFactory(functionType, categoryKey,
|
|
|
832
832
|
} catch {
|
|
833
833
|
selections = [];
|
|
834
834
|
}
|
|
835
|
+
const localeKey = `sheets-formula-ui.functionType.${categoryKey}`;
|
|
835
836
|
return {
|
|
836
837
|
id: `${InsertFunctionOperation.id}.${categoryKey}`,
|
|
837
838
|
commandId: InsertFunctionOperation.id,
|
|
838
|
-
title:
|
|
839
|
-
tooltip:
|
|
839
|
+
title: localeKey,
|
|
840
|
+
tooltip: localeKey,
|
|
840
841
|
icon,
|
|
841
842
|
type: MenuItemType.SELECTOR,
|
|
842
843
|
selections,
|
|
@@ -844,16 +845,16 @@ function createInsertFunctionCategoryMenuItemFactory(functionType, categoryKey,
|
|
|
844
845
|
};
|
|
845
846
|
};
|
|
846
847
|
}
|
|
847
|
-
const InsertFinancialFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Financial, "financial");
|
|
848
|
-
const InsertLogicalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Logical, "logical");
|
|
849
|
-
const InsertTextFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Text, "text");
|
|
850
|
-
const InsertDateFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Date, "date");
|
|
851
|
-
const InsertLookupFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Lookup, "lookup");
|
|
852
|
-
const InsertMathFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Math, "math");
|
|
853
|
-
const InsertStatisticalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Statistical, "statistical");
|
|
854
|
-
const InsertEngineeringFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Engineering, "engineering");
|
|
855
|
-
const InsertInformationFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Information, "information");
|
|
856
|
-
const InsertDatabaseFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Database, "database");
|
|
848
|
+
const InsertFinancialFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Financial, "financial", "FinancialFunctionIcon");
|
|
849
|
+
const InsertLogicalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Logical, "logical", "LogicalFunctionIcon");
|
|
850
|
+
const InsertTextFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Text, "text", "TextFunctionIcon");
|
|
851
|
+
const InsertDateFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Date, "date", "DateFunctionIcon");
|
|
852
|
+
const InsertLookupFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Lookup, "lookup", "LookupFunctionIcon");
|
|
853
|
+
const InsertMathFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Math, "math", "MathFunctionIcon");
|
|
854
|
+
const InsertStatisticalFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Statistical, "statistical", "StatisticalFunctionIcon");
|
|
855
|
+
const InsertEngineeringFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Engineering, "engineering", "EngineeringFunctionIcon");
|
|
856
|
+
const InsertInformationFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Information, "information", "InformationFunctionIcon");
|
|
857
|
+
const InsertDatabaseFunctionMenuItemFactory = createInsertFunctionCategoryMenuItemFactory(FunctionType.Database, "database", "DatabaseFunctionIcon");
|
|
857
858
|
function AllFunctionsMenuItemFactory(accessor) {
|
|
858
859
|
return {
|
|
859
860
|
id: MoreFunctionsOperation.id,
|
|
@@ -909,83 +910,43 @@ const menuSchema = {
|
|
|
909
910
|
},
|
|
910
911
|
[`${InsertFunctionOperation.id}.financial`]: {
|
|
911
912
|
order: 1,
|
|
912
|
-
menuItemFactory: InsertFinancialFunctionMenuItemFactory
|
|
913
|
-
[MoreFunctionsOperation.id]: {
|
|
914
|
-
order: 0,
|
|
915
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
916
|
-
}
|
|
913
|
+
menuItemFactory: InsertFinancialFunctionMenuItemFactory
|
|
917
914
|
},
|
|
918
915
|
[`${InsertFunctionOperation.id}.logical`]: {
|
|
919
916
|
order: 2,
|
|
920
|
-
menuItemFactory: InsertLogicalFunctionMenuItemFactory
|
|
921
|
-
[MoreFunctionsOperation.id]: {
|
|
922
|
-
order: 0,
|
|
923
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
924
|
-
}
|
|
917
|
+
menuItemFactory: InsertLogicalFunctionMenuItemFactory
|
|
925
918
|
},
|
|
926
919
|
[`${InsertFunctionOperation.id}.text`]: {
|
|
927
920
|
order: 3,
|
|
928
|
-
menuItemFactory: InsertTextFunctionMenuItemFactory
|
|
929
|
-
[MoreFunctionsOperation.id]: {
|
|
930
|
-
order: 0,
|
|
931
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
932
|
-
}
|
|
921
|
+
menuItemFactory: InsertTextFunctionMenuItemFactory
|
|
933
922
|
},
|
|
934
923
|
[`${InsertFunctionOperation.id}.date`]: {
|
|
935
924
|
order: 4,
|
|
936
|
-
menuItemFactory: InsertDateFunctionMenuItemFactory
|
|
937
|
-
[MoreFunctionsOperation.id]: {
|
|
938
|
-
order: 0,
|
|
939
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
940
|
-
}
|
|
925
|
+
menuItemFactory: InsertDateFunctionMenuItemFactory
|
|
941
926
|
},
|
|
942
927
|
[`${InsertFunctionOperation.id}.lookup`]: {
|
|
943
928
|
order: 5,
|
|
944
|
-
menuItemFactory: InsertLookupFunctionMenuItemFactory
|
|
945
|
-
[MoreFunctionsOperation.id]: {
|
|
946
|
-
order: 0,
|
|
947
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
948
|
-
}
|
|
929
|
+
menuItemFactory: InsertLookupFunctionMenuItemFactory
|
|
949
930
|
},
|
|
950
931
|
[`${InsertFunctionOperation.id}.math`]: {
|
|
951
932
|
order: 6,
|
|
952
|
-
menuItemFactory: InsertMathFunctionMenuItemFactory
|
|
953
|
-
[MoreFunctionsOperation.id]: {
|
|
954
|
-
order: 0,
|
|
955
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
956
|
-
}
|
|
933
|
+
menuItemFactory: InsertMathFunctionMenuItemFactory
|
|
957
934
|
},
|
|
958
935
|
[`${InsertFunctionOperation.id}.statistical`]: {
|
|
959
936
|
order: 7,
|
|
960
|
-
menuItemFactory: InsertStatisticalFunctionMenuItemFactory
|
|
961
|
-
[MoreFunctionsOperation.id]: {
|
|
962
|
-
order: 0,
|
|
963
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
964
|
-
}
|
|
937
|
+
menuItemFactory: InsertStatisticalFunctionMenuItemFactory
|
|
965
938
|
},
|
|
966
939
|
[`${InsertFunctionOperation.id}.engineering`]: {
|
|
967
940
|
order: 8,
|
|
968
|
-
menuItemFactory: InsertEngineeringFunctionMenuItemFactory
|
|
969
|
-
[MoreFunctionsOperation.id]: {
|
|
970
|
-
order: 0,
|
|
971
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
972
|
-
}
|
|
941
|
+
menuItemFactory: InsertEngineeringFunctionMenuItemFactory
|
|
973
942
|
},
|
|
974
943
|
[`${InsertFunctionOperation.id}.information`]: {
|
|
975
944
|
order: 9,
|
|
976
|
-
menuItemFactory: InsertInformationFunctionMenuItemFactory
|
|
977
|
-
[MoreFunctionsOperation.id]: {
|
|
978
|
-
order: 0,
|
|
979
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
980
|
-
}
|
|
945
|
+
menuItemFactory: InsertInformationFunctionMenuItemFactory
|
|
981
946
|
},
|
|
982
947
|
[`${InsertFunctionOperation.id}.database`]: {
|
|
983
948
|
order: 10,
|
|
984
|
-
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
985
|
-
[MoreFunctionsOperation.id]: {
|
|
986
|
-
order: 0,
|
|
987
|
-
menuItemFactory: AllFunctionsMenuItemFactory
|
|
988
|
-
}
|
|
949
|
+
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
989
950
|
}
|
|
990
951
|
},
|
|
991
952
|
[COPY_SPECIAL_MENU_ID]: { [SheetCopyFormulaOnlyCommand.id]: {
|
|
@@ -1001,7 +962,7 @@ const menuSchema = {
|
|
|
1001
962
|
//#endregion
|
|
1002
963
|
//#region package.json
|
|
1003
964
|
var name = "@univerjs/sheets-formula-ui";
|
|
1004
|
-
var version = "1.0.0-alpha.
|
|
965
|
+
var version = "1.0.0-alpha.4";
|
|
1005
966
|
|
|
1006
967
|
//#endregion
|
|
1007
968
|
//#region src/config/config.ts
|
|
@@ -3295,7 +3256,7 @@ function SearchFunctionFactory(props, ref) {
|
|
|
3295
3256
|
const shortcutService = useDependency(IShortcutService);
|
|
3296
3257
|
const commandService = useDependency(ICommandService);
|
|
3297
3258
|
const { searchList, searchText, handlerFormulaReplace, reset: resetFormulaSearch } = useFormulaSearch(isFocus, sequenceNodes, editor);
|
|
3298
|
-
const visible =
|
|
3259
|
+
const visible = searchList.length > 0;
|
|
3299
3260
|
const ulRef = useRef(void 0);
|
|
3300
3261
|
const [active, setActive] = useState(0);
|
|
3301
3262
|
const isEnableMouseEnterOrOut = useRef(false);
|
|
@@ -3481,7 +3442,7 @@ function syncCounterpartFormulaEditorSelection(editorService, editorId, selectio
|
|
|
3481
3442
|
(_editorService$getEdi = editorService.getEditor(syncEditorId)) === null || _editorService$getEdi === void 0 || _editorService$getEdi.setSelectionRanges(selections, false);
|
|
3482
3443
|
}
|
|
3483
3444
|
const FormulaEditor = forwardRef((props, ref) => {
|
|
3484
|
-
var _document$getBody$
|
|
3445
|
+
var _document$getBody$dat2, _document$getBody2, _configService$getCon, _configService$getCon2;
|
|
3485
3446
|
const { errorText, initValue, unitId, subUnitId, isFocus: _isFocus = true, isSupportAcrossSheet = false, onFocus = noop, onBlur = noop, onChange: propOnChange, onVerify, className, editorId: propEditorId, moveCursor = true, onFormulaSelectingChange: propOnFormulaSelectingChange, keyboardEventConfig, onMoveInEditor, resetSelectionOnBlur = true, autoScrollbar = true, isSingle = true, disableSelectionOnClick = false, autofocus = true, disableContextMenu, style, borderless = false, canvasStyle } = props;
|
|
3486
3447
|
const editorService = useDependency(IEditorService);
|
|
3487
3448
|
const commandService = useDependency(ICommandService);
|
|
@@ -3499,12 +3460,14 @@ const FormulaEditor = forwardRef((props, ref) => {
|
|
|
3499
3460
|
const [isFocus, setIsFocus] = useState(_isFocus);
|
|
3500
3461
|
const formulaEditorContainerRef = useRef(null);
|
|
3501
3462
|
const editorId = useMemo(() => propEditorId !== null && propEditorId !== void 0 ? propEditorId : createInternalEditorID(`${EMBEDDING_FORMULA_EDITOR}-${generateRandomId(4)}`), []);
|
|
3502
|
-
const isError =
|
|
3463
|
+
const isError = errorText !== void 0;
|
|
3503
3464
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
3504
3465
|
const document = univerInstanceService.getUnit(editorId);
|
|
3505
|
-
useObservable(document === null || document === void 0 ? void 0 : document.change$);
|
|
3506
3466
|
const getFormulaToken = useFormulaToken();
|
|
3507
|
-
const formulaText =
|
|
3467
|
+
const formulaText = useObservable(document ? () => document.change$.pipe(map(() => {
|
|
3468
|
+
var _document$getBody$dat, _document$getBody;
|
|
3469
|
+
return BuildTextUtils.transform.getPlainText((_document$getBody$dat = (_document$getBody = document.getBody()) === null || _document$getBody === void 0 ? void 0 : _document$getBody.dataStream) !== null && _document$getBody$dat !== void 0 ? _document$getBody$dat : "");
|
|
3470
|
+
})) : null, BuildTextUtils.transform.getPlainText((_document$getBody$dat2 = document === null || document === void 0 || (_document$getBody2 = document.getBody()) === null || _document$getBody2 === void 0 ? void 0 : _document$getBody2.dataStream) !== null && _document$getBody$dat2 !== void 0 ? _document$getBody$dat2 : ""), false, [document]);
|
|
3508
3471
|
const formulaTextRef = useStateRef(formulaText);
|
|
3509
3472
|
const formulaWithoutEqualSymbol = useMemo(() => getFormulaText(formulaText), [formulaText]);
|
|
3510
3473
|
const sequenceNodes = useMemo(() => getFormulaToken(formulaWithoutEqualSymbol), [formulaWithoutEqualSymbol, getFormulaToken]);
|
|
@@ -3522,8 +3485,8 @@ const FormulaEditor = forwardRef((props, ref) => {
|
|
|
3522
3485
|
const isFocusing = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing;
|
|
3523
3486
|
const currentDoc = useObservable(useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), [univerInstanceService]));
|
|
3524
3487
|
const docFocusing = (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) === editorId;
|
|
3525
|
-
const
|
|
3526
|
-
const getRefSelections = useEvent(() =>
|
|
3488
|
+
const refSelectionsRef = useRef([]);
|
|
3489
|
+
const getRefSelections = useEvent(() => refSelectionsRef.current);
|
|
3527
3490
|
const getRefSelectionCount = useEvent(() => getRefSelections().length);
|
|
3528
3491
|
const selectingMode = isSelecting;
|
|
3529
3492
|
const functionScreenTips = (_configService$getCon = (_configService$getCon2 = useDependency(IConfigService).getConfig("sheets-formula-ui.base.config")) === null || _configService$getCon2 === void 0 ? void 0 : _configService$getCon2.functionScreenTips) !== null && _configService$getCon !== void 0 ? _configService$getCon : true;
|
|
@@ -3559,7 +3522,7 @@ const FormulaEditor = forwardRef((props, ref) => {
|
|
|
3559
3522
|
const formulaStr = text[0] === "=" ? text.slice(1) : "";
|
|
3560
3523
|
const sequenceNodes = getFormulaToken(formulaStr);
|
|
3561
3524
|
const ranges = highlightDoc(editorRef.current, sequenceNodes, isNeedResetSelection, newSelections, formulaStr);
|
|
3562
|
-
|
|
3525
|
+
refSelectionsRef.current = ranges;
|
|
3563
3526
|
if (isEnd) {
|
|
3564
3527
|
const currentDocSelections = newSelections !== null && newSelections !== void 0 ? newSelections : editor === null || editor === void 0 ? void 0 : editor.getSelectionRanges();
|
|
3565
3528
|
if ((currentDocSelections === null || currentDocSelections === void 0 ? void 0 : currentDocSelections.length) === 1) {
|
|
@@ -3858,6 +3821,13 @@ function FunctionParams(props) {
|
|
|
3858
3821
|
function InputParams(props) {
|
|
3859
3822
|
const { functionInfo, onChange } = props;
|
|
3860
3823
|
if (!functionInfo) return null;
|
|
3824
|
+
return /* @__PURE__ */ jsx(InputParamsInner, {
|
|
3825
|
+
functionInfo,
|
|
3826
|
+
onChange
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
function InputParamsInner(props) {
|
|
3830
|
+
const { functionInfo, onChange } = props;
|
|
3861
3831
|
const [params, setParams] = useState([]);
|
|
3862
3832
|
const [functionParameter, setFunctionParameter] = useState(functionInfo.functionParameter);
|
|
3863
3833
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
@@ -4002,27 +3972,60 @@ function SelectFunction(props) {
|
|
|
4002
3972
|
}, index))
|
|
4003
3973
|
}),
|
|
4004
3974
|
functionInfo && /* @__PURE__ */ jsxs("div", {
|
|
4005
|
-
|
|
3975
|
+
"data-u-comp": "formula-function-details",
|
|
3976
|
+
className: clsx("univer-mx-0 univer-my-3 univer-overflow-y-auto", scrollbarClassName),
|
|
4006
3977
|
children: [
|
|
4007
|
-
/* @__PURE__ */
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
})
|
|
3978
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3979
|
+
className: "univer-rounded-lg univer-bg-gray-50 univer-p-3 dark:!univer-bg-gray-800",
|
|
3980
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3981
|
+
className: "univer-text-sm univer-font-semibold univer-text-gray-900 dark:!univer-text-white",
|
|
3982
|
+
children: functionInfo.functionName
|
|
3983
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3984
|
+
className: "univer-mt-1 univer-text-xs univer-leading-5 univer-text-gray-600 dark:!univer-text-gray-300",
|
|
3985
|
+
children: functionInfo.description
|
|
3986
|
+
})]
|
|
4017
3987
|
}),
|
|
4018
|
-
/* @__PURE__ */
|
|
4019
|
-
|
|
4020
|
-
|
|
3988
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3989
|
+
className: "univer-mt-4 univer-flex univer-flex-col univer-gap-3",
|
|
3990
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
3991
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
|
|
3992
|
+
children: localeService.t("sheets-formula-ui.moreFunctions.syntax")
|
|
3993
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3994
|
+
"data-u-comp": "formula-function-syntax",
|
|
3995
|
+
className: clsx("univer-mt-1.5 univer-break-words univer-rounded-md univer-bg-gray-50 univer-px-3 univer-py-2 univer-font-mono univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-bg-gray-800 dark:!univer-text-white", borderClassName),
|
|
3996
|
+
children: /* @__PURE__ */ jsx(FunctionHelp, {
|
|
3997
|
+
prefix: functionInfo.functionName,
|
|
3998
|
+
value: functionInfo.functionParameter
|
|
3999
|
+
})
|
|
4000
|
+
})] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
4001
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-300",
|
|
4002
|
+
children: localeService.t("sheets-formula-ui.prompt.helpExample")
|
|
4003
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4004
|
+
"data-u-comp": "formula-function-example",
|
|
4005
|
+
className: clsx("univer-mt-1.5 univer-break-words univer-rounded-md univer-bg-gray-50 univer-px-3 univer-py-2 univer-font-mono univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-bg-gray-800 dark:!univer-text-white", borderClassName),
|
|
4006
|
+
children: `${functionInfo.functionName}(${functionInfo.functionParameter.map((item) => item.example).join(",")})`
|
|
4007
|
+
})] })]
|
|
4021
4008
|
}),
|
|
4022
|
-
functionInfo.functionParameter
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4009
|
+
functionInfo.functionParameter.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
4010
|
+
className: clsx("univer-mt-4 univer-rounded-lg univer-px-3", borderClassName, divideYClassName),
|
|
4011
|
+
children: functionInfo.functionParameter.map((item) => /* @__PURE__ */ jsxs("div", {
|
|
4012
|
+
"data-u-comp": "formula-function-parameter",
|
|
4013
|
+
className: "univer-py-3",
|
|
4014
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4015
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
4016
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4017
|
+
className: "univer-text-xs univer-font-medium univer-text-gray-900 dark:!univer-text-white",
|
|
4018
|
+
children: item.name
|
|
4019
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
4020
|
+
className: clsx("univer-rounded-full univer-px-2 univer-py-0.5 univer-text-xs univer-leading-4", item.require ? "univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900 dark:!univer-text-primary-200" : "univer-bg-gray-100 univer-text-gray-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-200"),
|
|
4021
|
+
children: item.require ? required : optional
|
|
4022
|
+
})]
|
|
4023
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4024
|
+
className: "univer-mt-1 univer-text-xs univer-leading-5 univer-text-gray-600 dark:!univer-text-gray-300",
|
|
4025
|
+
children: item.detail
|
|
4026
|
+
})]
|
|
4027
|
+
}, item.name))
|
|
4028
|
+
})
|
|
4026
4029
|
]
|
|
4027
4030
|
})
|
|
4028
4031
|
] });
|
|
@@ -4508,7 +4511,19 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
4508
4511
|
this._registerComponents();
|
|
4509
4512
|
}
|
|
4510
4513
|
_registerIcons() {
|
|
4511
|
-
this.disposeWithMe(this._iconManager.register({
|
|
4514
|
+
this.disposeWithMe(this._iconManager.register({
|
|
4515
|
+
DatabaseFunctionIcon,
|
|
4516
|
+
DateFunctionIcon,
|
|
4517
|
+
EngineeringFunctionIcon,
|
|
4518
|
+
FinancialFunctionIcon,
|
|
4519
|
+
FunctionIcon,
|
|
4520
|
+
InformationFunctionIcon,
|
|
4521
|
+
LogicalFunctionIcon,
|
|
4522
|
+
LookupFunctionIcon,
|
|
4523
|
+
MathFunctionIcon,
|
|
4524
|
+
StatisticalFunctionIcon,
|
|
4525
|
+
TextFunctionIcon
|
|
4526
|
+
}));
|
|
4512
4527
|
}
|
|
4513
4528
|
_registerComponents() {
|
|
4514
4529
|
this.disposeWithMe(this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions));
|