@univerjs/sheets-formula-ui 1.0.4 → 1.2.0
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 +317 -173
- package/lib/cjs/locale/ar-SA.js +14 -0
- package/lib/cjs/locale/ca-ES.js +14 -0
- package/lib/cjs/locale/de-DE.js +14 -0
- package/lib/cjs/locale/en-US.js +14 -0
- package/lib/cjs/locale/es-ES.js +14 -0
- package/lib/cjs/locale/fa-IR.js +14 -0
- package/lib/cjs/locale/fr-FR.js +14 -0
- package/lib/cjs/locale/id-ID.js +14 -0
- package/lib/cjs/locale/it-IT.js +14 -0
- package/lib/cjs/locale/ja-JP.js +14 -0
- package/lib/cjs/locale/ko-KR.js +14 -0
- package/lib/cjs/locale/pl-PL.js +14 -0
- package/lib/cjs/locale/pt-BR.js +14 -0
- package/lib/cjs/locale/ru-RU.js +14 -0
- package/lib/cjs/locale/sk-SK.js +14 -0
- package/lib/cjs/locale/vi-VN.js +14 -0
- package/lib/cjs/locale/zh-CN.js +14 -0
- package/lib/cjs/locale/zh-HK.js +14 -0
- package/lib/cjs/locale/zh-TW.js +14 -0
- package/lib/es/index.js +323 -173
- package/lib/es/locale/ar-SA.js +14 -0
- package/lib/es/locale/ca-ES.js +14 -0
- package/lib/es/locale/de-DE.js +14 -0
- package/lib/es/locale/en-US.js +14 -0
- package/lib/es/locale/es-ES.js +14 -0
- package/lib/es/locale/fa-IR.js +14 -0
- package/lib/es/locale/fr-FR.js +14 -0
- package/lib/es/locale/id-ID.js +14 -0
- package/lib/es/locale/it-IT.js +14 -0
- package/lib/es/locale/ja-JP.js +14 -0
- package/lib/es/locale/ko-KR.js +14 -0
- package/lib/es/locale/pl-PL.js +14 -0
- package/lib/es/locale/pt-BR.js +14 -0
- package/lib/es/locale/ru-RU.js +14 -0
- package/lib/es/locale/sk-SK.js +14 -0
- package/lib/es/locale/vi-VN.js +14 -0
- package/lib/es/locale/zh-CN.js +14 -0
- package/lib/es/locale/zh-HK.js +14 -0
- package/lib/es/locale/zh-TW.js +14 -0
- package/lib/index.css +4 -20
- package/lib/index.js +323 -173
- package/lib/locale/ar-SA.js +14 -0
- package/lib/locale/ca-ES.js +14 -0
- package/lib/locale/de-DE.js +14 -0
- package/lib/locale/en-US.js +14 -0
- package/lib/locale/es-ES.js +14 -0
- package/lib/locale/fa-IR.js +14 -0
- package/lib/locale/fr-FR.js +14 -0
- package/lib/locale/id-ID.js +14 -0
- package/lib/locale/it-IT.js +14 -0
- package/lib/locale/ja-JP.js +14 -0
- package/lib/locale/ko-KR.js +14 -0
- package/lib/locale/pl-PL.js +14 -0
- package/lib/locale/pt-BR.js +14 -0
- package/lib/locale/ru-RU.js +14 -0
- package/lib/locale/sk-SK.js +14 -0
- package/lib/locale/vi-VN.js +14 -0
- package/lib/locale/zh-CN.js +14 -0
- package/lib/locale/zh-HK.js +14 -0
- package/lib/locale/zh-TW.js +14 -0
- package/lib/types/commands/operations/calculation-options.operation.d.ts +19 -0
- package/lib/types/controllers/formula-alert-render.controller.d.ts +14 -6
- package/lib/types/index.d.ts +0 -1
- package/lib/types/locale/en-US.d.ts +14 -0
- package/lib/types/menu/menu.d.ts +1 -0
- package/lib/types/mobile-plugin.d.ts +0 -1
- package/lib/types/plugin.d.ts +0 -1
- package/lib/types/views/calculation-options/CalculationOptions.d.ts +19 -0
- package/lib/types/views/calculation-options/interface.d.ts +17 -0
- package/lib/types/views/formula-editor/hooks/use-highlight.d.ts +2 -8
- package/lib/umd/index.js +5 -5
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +16 -16
- package/lib/types/controllers/formula-reorder.controller.d.ts +0 -27
package/lib/es/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { AbsoluteRefType, BuildTextUtils, CellValueType, ColorKit, CommandType, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, HorizontalAlign, ICommandService, IConfigService, IContextService, ILogService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RANGE_TYPE,
|
|
2
|
-
import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand,
|
|
3
|
-
import { ErrorType, FormulaDataModel, FunctionType, IDescriptionService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, UniverFormulaEnginePlugin, buildFormulaTextRuns, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReplaceResult, handleRefStringInfo, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, matchRefDrawToken, matchToken, operatorToken, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
|
|
1
|
+
import { AbsoluteRefType, BuildTextUtils, CellValueType, ColorKit, CommandType, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, FOCUSING_FX_BAR_EDITOR, HorizontalAlign, ICommandService, IConfigService, IContextService, ILogService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, MAX_ITERATION_COUNT, ObjectMatrix, Plugin, RANGE_TYPE, Rectangle, RichTextBuilder, RxDisposable, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, createInternalEditorID, generateRandomId, getCellValueType, getEmptyCell, isFormulaId, isFormulaString, isICellData, isRealNum, merge, noop, normalizeWorkbookCalculationSettings, regexp, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
+
import { BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, ExpandSelectionCommand, IEditorBridgeService, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, JumpOver, MOBILE_EXPANDING_SELECTION, MOBILE_FORMULA_FUNCTION_PANEL_OPEN, MOBILE_PINCH_ZOOMING, MobileSelectionControl, MoveSelectionCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, SELECTION_SHAPE_DEPTH, SelectionControl, SetCellEditVisibleOperation, SheetPasteCommand, SheetSkeletonManagerService, SheetsUIPart, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, checkInHeaderRanges, genNormalSelectionStyle, getAllSelection, getCoordByOffset, getCurrentRangeDisable$, getSheetObject, menuClipboardDisabledObservable, useActiveWorkbook, whenSheetEditorActivated, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
3
|
+
import { ErrorType, FormulaDataModel, FunctionType, IDescriptionService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStopMutation, UniverFormulaEnginePlugin, buildFormulaTextRuns, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, extractFormulaError, generateStringWithSequence, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReplaceResult, handleRefStringInfo, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, matchRefDrawToken, matchToken, operatorToken, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet } from "@univerjs/engine-formula";
|
|
4
4
|
import { BehaviorSubject, Subject, combineLatestWith, debounceTime, distinctUntilChanged, filter, map, merge as merge$1, throttleTime } from "rxjs";
|
|
5
5
|
import { DocBackScrollRenderController, DocSelectionRenderService, IEditorService, MoveCursorOperation, MoveSelectionOperation, ReplaceTextRunsCommand, RichTextEditor, createEditorUndoRedoKeyboardConfig, useKeyboardEvent, useResize } from "@univerjs/docs-ui";
|
|
6
|
-
import { DeviceInputEventType, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimer, ScrollTimerType, UniverRenderEnginePlugin, Vector2 } from "@univerjs/engine-render";
|
|
7
|
-
import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint,
|
|
6
|
+
import { DeviceInputEventType, ICanvasColorService, IRenderManagerService, SHEET_VIEWPORT_KEY, ScrollTimer, ScrollTimerType, UniverRenderEnginePlugin, Vector2 } from "@univerjs/engine-render";
|
|
7
|
+
import { BEFORE_CELL_EDIT, INTERCEPTOR_POINT, IRefSelectionsService, REF_SELECTIONS_ENABLED, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, SelectionMoveType, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetSelectionsOperation, SetWorkbookCalculationSettingsCommand, SetWorkbookCalculationSettingsMutation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookCopyPermission, WorkbookEditablePermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetSetCellValuePermission, attachSelectionWithCoord, convertSelectionDataToRange, getCellAtRowCol, getSheetCommandTarget, setEndForRange } from "@univerjs/sheets";
|
|
8
8
|
import { ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, TriggerCalculationController, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
9
|
-
import { BuiltInUIPart, ComponentManager, IContextMenuService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, ProgressBar, RectPopup, RibbonFormulasGroup, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
|
|
9
|
+
import { BuiltInUIPart, ComponentManager, IContextMenuService, IDialogService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, ProgressBar, RectPopup, RibbonFormulasGroup, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useDependency, useEvent, useObservable, useUpdateEffect } from "@univerjs/ui";
|
|
10
10
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
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, ConfigContext, Dialog, Input, MobileActionRowGroup, MobileSelect, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
|
|
11
|
+
import { CalculationOptionsIcon, CheckMarkIcon, CloseIcon, DatabaseFunctionIcon, DateFunctionIcon, DeleteIcon, EngineeringFunctionIcon, FinancialFunctionIcon, FunctionIcon, IncreaseIcon, InformationFunctionIcon, LogicalFunctionIcon, LookupFunctionIcon, MathFunctionIcon, MoreRightIcon, SelectRangeIcon, StatisticalFunctionIcon, TextFunctionIcon } from "@univerjs/icons";
|
|
12
|
+
import { Button, Checkbox, ConfigContext, Dialog, Input, MobileActionRowGroup, MobileSelect, Select, Tooltip, borderClassName, borderLeftClassName, borderTopClassName, clsx, divideYClassName, scrollbarClassName } from "@univerjs/design";
|
|
13
13
|
import { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { debounceTime as debounceTime$1 } from "rxjs/operators";
|
|
15
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -32,7 +32,7 @@ const SheetOnlyPasteFormulaCommand = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region \0@oxc-project+runtime@0.
|
|
35
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
36
36
|
function _typeof(o) {
|
|
37
37
|
"@babel/helpers - typeof";
|
|
38
38
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -43,7 +43,7 @@ function _typeof(o) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
|
-
//#region \0@oxc-project+runtime@0.
|
|
46
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
47
47
|
function toPrimitive(t, r) {
|
|
48
48
|
if ("object" != _typeof(t) || !t) return t;
|
|
49
49
|
var e = t[Symbol.toPrimitive];
|
|
@@ -56,14 +56,14 @@ function toPrimitive(t, r) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
60
60
|
function toPropertyKey(t) {
|
|
61
61
|
var i = toPrimitive(t, "string");
|
|
62
62
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region \0@oxc-project+runtime@0.
|
|
66
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
67
67
|
function _defineProperty(e, r, t) {
|
|
68
68
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
69
69
|
value: t,
|
|
@@ -74,7 +74,7 @@ function _defineProperty(e, r, t) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
//#endregion
|
|
77
|
-
//#region \0@oxc-project+runtime@0.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
78
78
|
function __decorateParam(paramIndex, decorator) {
|
|
79
79
|
return function(target, key) {
|
|
80
80
|
decorator(target, key, paramIndex);
|
|
@@ -82,7 +82,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
85
|
-
//#region \0@oxc-project+runtime@0.
|
|
85
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
86
86
|
function __decorate(decorators, target, key, desc) {
|
|
87
87
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
88
88
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -726,86 +726,49 @@ function genFormulaRefSelectionStyle(themeService, refColor, id) {
|
|
|
726
726
|
}
|
|
727
727
|
|
|
728
728
|
//#endregion
|
|
729
|
-
//#region src/
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
const formulaString = this._formulaDataModel.getFormulaStringByCell(targetRow, col, subUnitId, unitId);
|
|
769
|
-
const shiftedFormula = this._lexerTreeBuilder.moveFormulaRefOffset(formulaString, 0, row - targetRow);
|
|
770
|
-
const newCell = Tools.deepClone(targetCell);
|
|
771
|
-
newCell.f = shiftedFormula;
|
|
772
|
-
newCell.si = null;
|
|
773
|
-
redoFormulaMatrix.setValue(row, col, newCell);
|
|
774
|
-
} else redoFormulaMatrix.setValue(row, col, targetCell);
|
|
775
|
-
undoFormulaMatrix.setValue(row, col, cellMatrix.getValue(row, col));
|
|
776
|
-
});
|
|
777
|
-
if (!hasFormula) return {
|
|
778
|
-
redos,
|
|
779
|
-
undos
|
|
780
|
-
};
|
|
781
|
-
redos.push({
|
|
782
|
-
id: SetRangeValuesMutation.id,
|
|
783
|
-
params: {
|
|
784
|
-
unitId,
|
|
785
|
-
subUnitId,
|
|
786
|
-
cellValue: redoFormulaMatrix.getMatrix()
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
undos.push({
|
|
790
|
-
id: SetRangeValuesMutation.id,
|
|
791
|
-
params: {
|
|
792
|
-
unitId,
|
|
793
|
-
subUnitId,
|
|
794
|
-
cellValue: undoFormulaMatrix.getMatrix()
|
|
795
|
-
}
|
|
729
|
+
//#region src/views/calculation-options/interface.ts
|
|
730
|
+
/**
|
|
731
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
732
|
+
*
|
|
733
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
734
|
+
* you may not use this file except in compliance with the License.
|
|
735
|
+
* You may obtain a copy of the License at
|
|
736
|
+
*
|
|
737
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
738
|
+
*
|
|
739
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
740
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
741
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
742
|
+
* See the License for the specific language governing permissions and
|
|
743
|
+
* limitations under the License.
|
|
744
|
+
*/
|
|
745
|
+
const CALCULATION_OPTIONS_COMPONENT = "sheets-formula-ui.calculation-options";
|
|
746
|
+
const CALCULATION_OPTIONS_DIALOG = "sheets-formula-ui.calculation-options-dialog";
|
|
747
|
+
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/commands/operations/calculation-options.operation.ts
|
|
750
|
+
const CalculationOptionsOperation = {
|
|
751
|
+
id: "sheets-formula-ui.operation.calculation-options",
|
|
752
|
+
type: CommandType.OPERATION,
|
|
753
|
+
handler: (accessor, params) => {
|
|
754
|
+
const instanceService = accessor.get(IUniverInstanceService);
|
|
755
|
+
const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? instanceService.getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET) : instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
756
|
+
if (!workbook) return false;
|
|
757
|
+
const dialogService = accessor.get(IDialogService);
|
|
758
|
+
dialogService.close(CALCULATION_OPTIONS_DIALOG);
|
|
759
|
+
dialogService.open({
|
|
760
|
+
id: CALCULATION_OPTIONS_DIALOG,
|
|
761
|
+
title: { title: "sheets-formula-ui.calculation.title" },
|
|
762
|
+
children: { label: {
|
|
763
|
+
name: CALCULATION_OPTIONS_COMPONENT,
|
|
764
|
+
props: { unitId: workbook.getUnitId() }
|
|
765
|
+
} },
|
|
766
|
+
width: 420,
|
|
767
|
+
onClose: () => dialogService.close(CALCULATION_OPTIONS_DIALOG)
|
|
796
768
|
});
|
|
797
|
-
return
|
|
798
|
-
redos,
|
|
799
|
-
undos
|
|
800
|
-
};
|
|
769
|
+
return true;
|
|
801
770
|
}
|
|
802
771
|
};
|
|
803
|
-
FormulaReorderController = __decorate([
|
|
804
|
-
__decorateParam(0, Inject(SheetInterceptorService)),
|
|
805
|
-
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
806
|
-
__decorateParam(2, Inject(FormulaDataModel)),
|
|
807
|
-
__decorateParam(3, Inject(LexerTreeBuilder))
|
|
808
|
-
], FormulaReorderController);
|
|
809
772
|
|
|
810
773
|
//#endregion
|
|
811
774
|
//#region src/menu/menu.ts
|
|
@@ -925,6 +888,16 @@ function PasteFormulaMenuItemFactory(accessor) {
|
|
|
925
888
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
|
|
926
889
|
};
|
|
927
890
|
}
|
|
891
|
+
function CalculationOptionsMenuItemFactory(accessor) {
|
|
892
|
+
return {
|
|
893
|
+
id: CalculationOptionsOperation.id,
|
|
894
|
+
type: MenuItemType.BUTTON,
|
|
895
|
+
icon: "CalculationOptionsIcon",
|
|
896
|
+
title: "sheets-formula-ui.calculation.title",
|
|
897
|
+
tooltip: "sheets-formula-ui.calculation.title",
|
|
898
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
|
|
899
|
+
};
|
|
900
|
+
}
|
|
928
901
|
|
|
929
902
|
//#endregion
|
|
930
903
|
//#region src/menu/schema.ts
|
|
@@ -985,6 +958,17 @@ const menuSchema = {
|
|
|
985
958
|
menuItemFactory: InsertDatabaseFunctionMenuItemFactory
|
|
986
959
|
}
|
|
987
960
|
},
|
|
961
|
+
[RibbonFormulasGroup.OTHERS]: { [CalculationOptionsOperation.id]: {
|
|
962
|
+
order: 0,
|
|
963
|
+
gridLayout: {
|
|
964
|
+
row: 1,
|
|
965
|
+
column: 1,
|
|
966
|
+
rowSpan: 2,
|
|
967
|
+
columnSpan: 2,
|
|
968
|
+
showLabel: true
|
|
969
|
+
},
|
|
970
|
+
menuItemFactory: CalculationOptionsMenuItemFactory
|
|
971
|
+
} },
|
|
988
972
|
[COPY_SPECIAL_MENU_ID]: { [SheetCopyFormulaOnlyCommand.id]: {
|
|
989
973
|
order: 0,
|
|
990
974
|
menuItemFactory: CopyFormulaOnlyMenuItemFactory
|
|
@@ -998,7 +982,7 @@ const menuSchema = {
|
|
|
998
982
|
//#endregion
|
|
999
983
|
//#region package.json
|
|
1000
984
|
var name = "@univerjs/sheets-formula-ui";
|
|
1001
|
-
var version = "1.0
|
|
985
|
+
var version = "1.2.0";
|
|
1002
986
|
|
|
1003
987
|
//#endregion
|
|
1004
988
|
//#region src/config/config.ts
|
|
@@ -1027,63 +1011,120 @@ const ErrorTypeToMessageMap = {
|
|
|
1027
1011
|
[ErrorType.NULL]: "null"
|
|
1028
1012
|
};
|
|
1029
1013
|
let FormulaAlertRenderController = class FormulaAlertRenderController extends Disposable {
|
|
1030
|
-
constructor(_context,
|
|
1014
|
+
constructor(_context, _selectionsService, _cellAlertManagerService, _localeService, _formulaDataModel, _sheetSkeletonService, _sheetSkeletonManagerService, _commandService, _instanceService, _editorBridgeService) {
|
|
1031
1015
|
super();
|
|
1032
1016
|
this._context = _context;
|
|
1033
|
-
this.
|
|
1017
|
+
this._selectionsService = _selectionsService;
|
|
1034
1018
|
this._cellAlertManagerService = _cellAlertManagerService;
|
|
1035
1019
|
this._localeService = _localeService;
|
|
1036
1020
|
this._formulaDataModel = _formulaDataModel;
|
|
1037
|
-
this.
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
this.
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
this.disposeWithMe(this.
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
if (
|
|
1060
|
-
|
|
1061
|
-
return;
|
|
1062
|
-
}
|
|
1063
|
-
this._cellAlertManagerService.showAlert({
|
|
1064
|
-
type: CellAlertType.ERROR,
|
|
1065
|
-
title: this._localeService.t("sheets-formula-ui.error.title"),
|
|
1066
|
-
message: this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[errorType]}`),
|
|
1067
|
-
location: cellPos.location,
|
|
1068
|
-
width: 200,
|
|
1069
|
-
height: 74,
|
|
1070
|
-
key: ALERT_KEY
|
|
1071
|
-
});
|
|
1072
|
-
return;
|
|
1021
|
+
this._sheetSkeletonService = _sheetSkeletonService;
|
|
1022
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1023
|
+
this._commandService = _commandService;
|
|
1024
|
+
this._instanceService = _instanceService;
|
|
1025
|
+
this._editorBridgeService = _editorBridgeService;
|
|
1026
|
+
_defineProperty(this, "_circularLocations", /* @__PURE__ */ new Set());
|
|
1027
|
+
this.disposeWithMe(this._selectionsService.selectionChanged$.subscribe(() => this._updateAlert()));
|
|
1028
|
+
this.disposeWithMe(this._context.unit.activeSheet$.subscribe(() => this._updateAlert()));
|
|
1029
|
+
this.disposeWithMe(this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe(() => this._updateAlert()));
|
|
1030
|
+
this.disposeWithMe(this._editorBridgeService.visible$.subscribe(() => this._updateAlert()));
|
|
1031
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1032
|
+
if (command.id === SetFormulaCalculationNotificationMutation.id) {
|
|
1033
|
+
const params = command.params;
|
|
1034
|
+
if (params.circularReferences) {
|
|
1035
|
+
const locations = new Set(params.circularReferences.filter((cell) => cell.unitId === this._context.unit.getUnitId()).map((cell) => JSON.stringify([
|
|
1036
|
+
cell.sheetId,
|
|
1037
|
+
cell.row,
|
|
1038
|
+
cell.column
|
|
1039
|
+
])));
|
|
1040
|
+
const changed = locations.size !== this._circularLocations.size || Array.from(locations).some((location) => !this._circularLocations.has(location));
|
|
1041
|
+
this._circularLocations = locations;
|
|
1042
|
+
this._formulaDataModel.setCircularReferences(params.circularReferences);
|
|
1043
|
+
if (changed) this._refreshMarkers();
|
|
1044
|
+
this._updateAlert();
|
|
1073
1045
|
}
|
|
1046
|
+
} else if (command.id === SetRangeValuesMutation.id || command.id === SetWorkbookCalculationSettingsMutation.id) {
|
|
1047
|
+
if (command.id === SetWorkbookCalculationSettingsMutation.id && command.params.unitId === this._context.unit.getUnitId()) this._refreshMarkers();
|
|
1048
|
+
this._updateAlert();
|
|
1074
1049
|
}
|
|
1075
|
-
this._hideAlert();
|
|
1076
1050
|
}));
|
|
1051
|
+
this.disposeWithMe(() => this._hideAlert());
|
|
1052
|
+
}
|
|
1053
|
+
_updateAlert() {
|
|
1054
|
+
var _selections, _this$_formulaDataMod, _this$_cellAlertManag;
|
|
1055
|
+
const workbook = this._context.unit;
|
|
1056
|
+
const worksheet = workbook.getActiveSheet();
|
|
1057
|
+
const selection = this._selectionsService.currentSelectionParam;
|
|
1058
|
+
const currentWorkbook = this._instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1059
|
+
if (!worksheet || (selection === null || selection === void 0 ? void 0 : selection.unitId) !== workbook.getUnitId() || selection.sheetId !== worksheet.getSheetId() || (currentWorkbook === null || currentWorkbook === void 0 ? void 0 : currentWorkbook.getUnitId()) !== workbook.getUnitId() || this._editorBridgeService.isVisible().visible) {
|
|
1060
|
+
this._hideAlert();
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
const selections = this._selectionsService.getCurrentSelections();
|
|
1064
|
+
const primary = selections === null || selections === void 0 || (_selections = selections[selections.length - 1]) === null || _selections === void 0 ? void 0 : _selections.primary;
|
|
1065
|
+
if (!primary) {
|
|
1066
|
+
this._hideAlert();
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
const row = primary.actualRow;
|
|
1070
|
+
const col = primary.actualColumn;
|
|
1071
|
+
const unitId = workbook.getUnitId();
|
|
1072
|
+
const subUnitId = worksheet.getSheetId();
|
|
1073
|
+
const cell = worksheet.getCell(row, col);
|
|
1074
|
+
const circular = !workbook.getCalculationSettings().iterativeCalculation && Boolean((cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si)) && this._formulaDataModel.isCircularReference(unitId, subUnitId, row, col);
|
|
1075
|
+
const arrayCell = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaCellData()) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[unitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[subUnitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[row]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[col];
|
|
1076
|
+
const error = isICellData(cell) ? extractFormulaError(cell, !!arrayCell) : void 0;
|
|
1077
|
+
if (!circular && !error) {
|
|
1078
|
+
this._hideAlert();
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
const message = circular ? this._localeService.t("sheets-formula-ui.calculation.circular") : this._localeService.t(`sheets-formula-ui.error.${ErrorTypeToMessageMap[error]}`);
|
|
1082
|
+
const previous = (_this$_cellAlertManag = this._cellAlertManagerService.currentAlert.get(this._alertKey)) === null || _this$_cellAlertManag === void 0 ? void 0 : _this$_cellAlertManag.alert;
|
|
1083
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.location.row) === row && previous.location.col === col && previous.location.subUnitId === subUnitId && previous.message === message && Boolean(previous.action) === circular) return;
|
|
1084
|
+
this._cellAlertManagerService.showAlert({
|
|
1085
|
+
type: CellAlertType.ERROR,
|
|
1086
|
+
title: this._localeService.t(circular ? "sheets-formula-ui.calculation.circularTitle" : "sheets-formula-ui.error.title"),
|
|
1087
|
+
message,
|
|
1088
|
+
location: {
|
|
1089
|
+
unitId,
|
|
1090
|
+
subUnitId,
|
|
1091
|
+
row,
|
|
1092
|
+
col
|
|
1093
|
+
},
|
|
1094
|
+
width: 240,
|
|
1095
|
+
height: circular ? 124 : 74,
|
|
1096
|
+
key: this._alertKey,
|
|
1097
|
+
action: circular ? {
|
|
1098
|
+
label: this._localeService.t("sheets-formula-ui.calculation.action"),
|
|
1099
|
+
onSelect: () => {
|
|
1100
|
+
this._commandService.syncExecuteCommand(CalculationOptionsOperation.id, { unitId });
|
|
1101
|
+
}
|
|
1102
|
+
} : void 0
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
get _alertKey() {
|
|
1106
|
+
return `${ALERT_KEY}:${this._context.unit.getUnitId()}`;
|
|
1107
|
+
}
|
|
1108
|
+
_refreshMarkers() {
|
|
1109
|
+
var _this$_context$mainCo;
|
|
1110
|
+
this._sheetSkeletonService.getSkeletonsByUnitId(this._context.unit.getUnitId()).forEach((skeleton) => skeleton.resetCache());
|
|
1111
|
+
this._sheetSkeletonManagerService.reCalculate();
|
|
1112
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
|
|
1077
1113
|
}
|
|
1078
1114
|
_hideAlert() {
|
|
1079
|
-
this._cellAlertManagerService.removeAlert(
|
|
1115
|
+
this._cellAlertManagerService.removeAlert(this._alertKey);
|
|
1080
1116
|
}
|
|
1081
1117
|
};
|
|
1082
1118
|
FormulaAlertRenderController = __decorate([
|
|
1083
|
-
__decorateParam(1, Inject(
|
|
1119
|
+
__decorateParam(1, Inject(SheetsSelectionsService)),
|
|
1084
1120
|
__decorateParam(2, Inject(CellAlertManagerService)),
|
|
1085
1121
|
__decorateParam(3, Inject(LocaleService)),
|
|
1086
|
-
__decorateParam(4, Inject(FormulaDataModel))
|
|
1122
|
+
__decorateParam(4, Inject(FormulaDataModel)),
|
|
1123
|
+
__decorateParam(5, Inject(SheetSkeletonService)),
|
|
1124
|
+
__decorateParam(6, Inject(SheetSkeletonManagerService)),
|
|
1125
|
+
__decorateParam(7, ICommandService),
|
|
1126
|
+
__decorateParam(8, IUniverInstanceService),
|
|
1127
|
+
__decorateParam(9, IEditorBridgeService)
|
|
1087
1128
|
], FormulaAlertRenderController);
|
|
1088
1129
|
|
|
1089
1130
|
//#endregion
|
|
@@ -1715,7 +1756,9 @@ let FormulaRenderManagerController = class FormulaRenderManagerController extend
|
|
|
1715
1756
|
handler: (cell, pos, next) => {
|
|
1716
1757
|
var _this$_formulaDataMod;
|
|
1717
1758
|
const arrayFormulaCellData = (_this$_formulaDataMod = this._formulaDataModel.getArrayFormulaCellData()) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.unitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.subUnitId]) === null || _this$_formulaDataMod === void 0 || (_this$_formulaDataMod = _this$_formulaDataMod[pos.row]) === null || _this$_formulaDataMod === void 0 ? void 0 : _this$_formulaDataMod[pos.col];
|
|
1718
|
-
|
|
1759
|
+
const errorType = extractFormulaError(cell, !!arrayFormulaCellData);
|
|
1760
|
+
const circular = Boolean((cell === null || cell === void 0 ? void 0 : cell.f) || (cell === null || cell === void 0 ? void 0 : cell.si)) && !pos.workbook.getCalculationSettings().iterativeCalculation && this._formulaDataModel.isCircularReference(pos.unitId, pos.subUnitId, pos.row, pos.col);
|
|
1761
|
+
if (!errorType && !circular) return next(cell);
|
|
1719
1762
|
if (!cell) return next(cell);
|
|
1720
1763
|
if (cell === pos.rawData) cell = { ...pos.rawData };
|
|
1721
1764
|
cell.markers = {
|
|
@@ -2332,6 +2375,7 @@ function useFormulaSelecting(opts) {
|
|
|
2332
2375
|
});
|
|
2333
2376
|
const calculateSelectingType = useEvent(() => {
|
|
2334
2377
|
var _editor$getSelectionR, _config$dataStream;
|
|
2378
|
+
if (!isFocus) return;
|
|
2335
2379
|
const currentWorkbook = resolveFormulaSelectionWorkbook(univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET), workbook);
|
|
2336
2380
|
if (!currentWorkbook) return;
|
|
2337
2381
|
const currentSheet = currentWorkbook.getActiveSheet();
|
|
@@ -2607,7 +2651,7 @@ function useDocHight(_leadingCharacter = "") {
|
|
|
2607
2651
|
});
|
|
2608
2652
|
return [];
|
|
2609
2653
|
} else {
|
|
2610
|
-
const { textRuns, refSelections } =
|
|
2654
|
+
const { textRuns, refSelections } = buildFormulaTextRuns(descriptionService, colorMap, sequenceNodes);
|
|
2611
2655
|
if (leadingCharacterLength) textRuns.forEach((e) => {
|
|
2612
2656
|
e.ed = e.ed + leadingCharacterLength;
|
|
2613
2657
|
e.st = e.st + leadingCharacterLength;
|
|
@@ -2652,31 +2696,28 @@ function createHighlightTextRuns(textRuns, leadingCharacterLength) {
|
|
|
2652
2696
|
}
|
|
2653
2697
|
function useColor() {
|
|
2654
2698
|
const themeService = useDependency(ThemeService);
|
|
2655
|
-
const
|
|
2699
|
+
const canvasColorService = useDependency(ICanvasColorService);
|
|
2700
|
+
const theme = useObservable(themeService.currentTheme$, themeService.getCurrentTheme());
|
|
2701
|
+
const darkMode = useObservable(themeService.darkMode$, themeService.darkMode);
|
|
2656
2702
|
return useMemo(() => {
|
|
2657
2703
|
return {
|
|
2658
|
-
formulaRefColors: [
|
|
2659
|
-
themeService.getColorFromTheme(
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
themeService.getColorFromTheme("loop-color.7"),
|
|
2666
|
-
themeService.getColorFromTheme("loop-color.8"),
|
|
2667
|
-
themeService.getColorFromTheme("loop-color.9"),
|
|
2668
|
-
themeService.getColorFromTheme("loop-color.10"),
|
|
2669
|
-
themeService.getColorFromTheme("loop-color.11"),
|
|
2670
|
-
themeService.getColorFromTheme("loop-color.12")
|
|
2671
|
-
].map((color) => themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color),
|
|
2704
|
+
formulaRefColors: Object.values(theme["loop-color"]).map((color) => {
|
|
2705
|
+
const resolvedColor = themeService.isValidThemeColor(color) ? themeService.getColorFromTheme(color) : color;
|
|
2706
|
+
if (!darkMode) return resolvedColor;
|
|
2707
|
+
let referenceColor = new ColorKit(resolvedColor);
|
|
2708
|
+
while (referenceColor.toHsl().l > 0 && ColorKit.getContrastRatio(canvasColorService.getRenderColor(referenceColor.toHexString()), theme.gray[800]) < 4.5) referenceColor = referenceColor.darken(5);
|
|
2709
|
+
return referenceColor.toHexString();
|
|
2710
|
+
}),
|
|
2672
2711
|
numberColor: themeService.getColorFromTheme("blue.700"),
|
|
2673
2712
|
stringColor: themeService.getColorFromTheme("jiqing.800"),
|
|
2674
2713
|
plainTextColor: themeService.getColorFromTheme("gray.1000")
|
|
2675
2714
|
};
|
|
2676
|
-
}, [
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2715
|
+
}, [
|
|
2716
|
+
theme,
|
|
2717
|
+
darkMode,
|
|
2718
|
+
themeService,
|
|
2719
|
+
canvasColorService
|
|
2720
|
+
]);
|
|
2680
2721
|
}
|
|
2681
2722
|
|
|
2682
2723
|
//#endregion
|
|
@@ -3744,12 +3785,11 @@ function MobileFunctionPanel(props) {
|
|
|
3744
3785
|
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3745
3786
|
/* @__PURE__ */ jsx("div", {
|
|
3746
3787
|
className: "univer-px-4 univer-pb-3",
|
|
3747
|
-
children: /* @__PURE__ */ jsx(
|
|
3788
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
3748
3789
|
value: query,
|
|
3749
3790
|
"aria-label": copy.search,
|
|
3750
3791
|
placeholder: copy.search,
|
|
3751
|
-
|
|
3752
|
-
onChange: (event) => setQuery(event.target.value)
|
|
3792
|
+
onChange: setQuery
|
|
3753
3793
|
})
|
|
3754
3794
|
}),
|
|
3755
3795
|
!query && /* @__PURE__ */ jsx("div", {
|
|
@@ -5640,6 +5680,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
|
|
|
5640
5680
|
}
|
|
5641
5681
|
_registerIcons() {
|
|
5642
5682
|
this.disposeWithMe(this._iconManager.register({
|
|
5683
|
+
CalculationOptionsIcon,
|
|
5643
5684
|
DatabaseFunctionIcon,
|
|
5644
5685
|
DateFunctionIcon,
|
|
5645
5686
|
EngineeringFunctionIcon,
|
|
@@ -5740,6 +5781,7 @@ let FormulaUIController = class FormulaUIController extends Disposable {
|
|
|
5740
5781
|
SheetOnlyPasteFormulaCommand,
|
|
5741
5782
|
InsertFunctionOperation,
|
|
5742
5783
|
MoreFunctionsOperation,
|
|
5784
|
+
CalculationOptionsOperation,
|
|
5743
5785
|
SearchFunctionOperation,
|
|
5744
5786
|
HelpFunctionOperation,
|
|
5745
5787
|
ReferenceAbsoluteOperation
|
|
@@ -6146,7 +6188,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
|
|
|
6146
6188
|
[FormulaClipboardController],
|
|
6147
6189
|
[FormulaEditorShowController],
|
|
6148
6190
|
[FormulaRenderManagerController],
|
|
6149
|
-
[FormulaReorderController],
|
|
6150
6191
|
[ImageFormulaRenderController]
|
|
6151
6192
|
]);
|
|
6152
6193
|
this._initUIPart();
|
|
@@ -6168,9 +6209,6 @@ let UniverSheetsFormulaMobileUIPlugin = class UniverSheetsFormulaMobileUIPlugin
|
|
|
6168
6209
|
[ImageFormulaRenderController]
|
|
6169
6210
|
]);
|
|
6170
6211
|
}
|
|
6171
|
-
onSteady() {
|
|
6172
|
-
this._injector.get(FormulaReorderController);
|
|
6173
|
-
}
|
|
6174
6212
|
_initUIPart() {
|
|
6175
6213
|
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(MobileGlobalRangeSelector, this._injector)));
|
|
6176
6214
|
}
|
|
@@ -6187,6 +6225,125 @@ UniverSheetsFormulaMobileUIPlugin = __decorate([
|
|
|
6187
6225
|
__decorateParam(4, IUIPartsService)
|
|
6188
6226
|
], UniverSheetsFormulaMobileUIPlugin);
|
|
6189
6227
|
|
|
6228
|
+
//#endregion
|
|
6229
|
+
//#region src/views/calculation-options/CalculationOptions.tsx
|
|
6230
|
+
function CalculationOptions({ unitId }) {
|
|
6231
|
+
var _permissionService$ge;
|
|
6232
|
+
const instanceService = useDependency(IUniverInstanceService);
|
|
6233
|
+
const commandService = useDependency(ICommandService);
|
|
6234
|
+
const permissionService = useDependency(IPermissionService);
|
|
6235
|
+
const dialogService = useDependency(IDialogService);
|
|
6236
|
+
const localeService = useDependency(LocaleService);
|
|
6237
|
+
const workbook = instanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
6238
|
+
const permissionId = new WorkbookEditablePermission(unitId).id;
|
|
6239
|
+
const permission = useObservable(permissionService.getPermissionPoint$(permissionId), void 0, false);
|
|
6240
|
+
const readOnly = !workbook || ((permission === null || permission === void 0 ? void 0 : permission.value) ?? ((_permissionService$ge = permissionService.getPermissionPoint(permissionId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value)) === false;
|
|
6241
|
+
const [draft, setDraft] = useState(() => {
|
|
6242
|
+
const settings = normalizeWorkbookCalculationSettings(workbook === null || workbook === void 0 ? void 0 : workbook.getCalculationSettings());
|
|
6243
|
+
return {
|
|
6244
|
+
enabled: settings.iterativeCalculation,
|
|
6245
|
+
count: String(settings.maxIterations),
|
|
6246
|
+
change: String(settings.maxChange)
|
|
6247
|
+
};
|
|
6248
|
+
});
|
|
6249
|
+
const [submitted, setSubmitted] = useState(false);
|
|
6250
|
+
const settings = {
|
|
6251
|
+
iterativeCalculation: draft.enabled,
|
|
6252
|
+
maxIterations: draft.count.trim() ? Number(draft.count) : NaN,
|
|
6253
|
+
maxChange: draft.change.trim() ? Number(draft.change) : NaN
|
|
6254
|
+
};
|
|
6255
|
+
const validCount = Number.isInteger(settings.maxIterations) && settings.maxIterations >= 1 && settings.maxIterations <= MAX_ITERATION_COUNT;
|
|
6256
|
+
const validChange = Number.isFinite(settings.maxChange) && settings.maxChange > 0;
|
|
6257
|
+
const showCountError = submitted && draft.enabled && !validCount;
|
|
6258
|
+
const showChangeError = submitted && draft.enabled && !validChange;
|
|
6259
|
+
function close() {
|
|
6260
|
+
dialogService.close(CALCULATION_OPTIONS_DIALOG);
|
|
6261
|
+
}
|
|
6262
|
+
function submit() {
|
|
6263
|
+
if (readOnly) return;
|
|
6264
|
+
setSubmitted(true);
|
|
6265
|
+
if (draft.enabled && (!validCount || !validChange)) return;
|
|
6266
|
+
const nextSettings = draft.enabled ? settings : {
|
|
6267
|
+
...workbook.getCalculationSettings(),
|
|
6268
|
+
iterativeCalculation: false
|
|
6269
|
+
};
|
|
6270
|
+
if (commandService.syncExecuteCommand(SetWorkbookCalculationSettingsCommand.id, {
|
|
6271
|
+
unitId,
|
|
6272
|
+
settings: nextSettings
|
|
6273
|
+
})) close();
|
|
6274
|
+
}
|
|
6275
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6276
|
+
className: "univer-flex univer-flex-col univer-gap-4 univer-p-4",
|
|
6277
|
+
children: [
|
|
6278
|
+
/* @__PURE__ */ jsx("p", {
|
|
6279
|
+
className: "univer-m-0 univer-text-sm",
|
|
6280
|
+
children: localeService.t("sheets-formula-ui.calculation.workbook")
|
|
6281
|
+
}),
|
|
6282
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
6283
|
+
checked: draft.enabled,
|
|
6284
|
+
disabled: readOnly,
|
|
6285
|
+
onChange: (enabled) => setDraft((previous) => ({
|
|
6286
|
+
...previous,
|
|
6287
|
+
enabled: Boolean(enabled)
|
|
6288
|
+
})),
|
|
6289
|
+
children: localeService.t("sheets-formula-ui.calculation.enable")
|
|
6290
|
+
}),
|
|
6291
|
+
/* @__PURE__ */ jsxs("label", {
|
|
6292
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
|
|
6293
|
+
children: [
|
|
6294
|
+
localeService.t("sheets-formula-ui.calculation.iterations", String(MAX_ITERATION_COUNT)),
|
|
6295
|
+
/* @__PURE__ */ jsx(Input, {
|
|
6296
|
+
value: draft.count,
|
|
6297
|
+
inputClass: showCountError ? "univer-border-red-500" : void 0,
|
|
6298
|
+
disabled: readOnly || !draft.enabled,
|
|
6299
|
+
onChange: (count) => setDraft((previous) => ({
|
|
6300
|
+
...previous,
|
|
6301
|
+
count
|
|
6302
|
+
}))
|
|
6303
|
+
}),
|
|
6304
|
+
showCountError && /* @__PURE__ */ jsx("span", {
|
|
6305
|
+
role: "alert",
|
|
6306
|
+
className: "univer-text-red-500",
|
|
6307
|
+
children: localeService.t("sheets-formula-ui.calculation.invalidIterations", String(MAX_ITERATION_COUNT))
|
|
6308
|
+
})
|
|
6309
|
+
]
|
|
6310
|
+
}),
|
|
6311
|
+
/* @__PURE__ */ jsxs("label", {
|
|
6312
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-text-sm",
|
|
6313
|
+
children: [
|
|
6314
|
+
localeService.t("sheets-formula-ui.calculation.change"),
|
|
6315
|
+
/* @__PURE__ */ jsx(Input, {
|
|
6316
|
+
value: draft.change,
|
|
6317
|
+
inputClass: showChangeError ? "univer-border-red-500" : void 0,
|
|
6318
|
+
disabled: readOnly || !draft.enabled,
|
|
6319
|
+
onChange: (change) => setDraft((previous) => ({
|
|
6320
|
+
...previous,
|
|
6321
|
+
change
|
|
6322
|
+
}))
|
|
6323
|
+
}),
|
|
6324
|
+
showChangeError && /* @__PURE__ */ jsx("span", {
|
|
6325
|
+
role: "alert",
|
|
6326
|
+
className: "univer-text-red-500",
|
|
6327
|
+
children: localeService.t("sheets-formula-ui.calculation.invalidChange")
|
|
6328
|
+
})
|
|
6329
|
+
]
|
|
6330
|
+
}),
|
|
6331
|
+
/* @__PURE__ */ jsxs("div", {
|
|
6332
|
+
className: "univer-flex univer-justify-end univer-gap-2",
|
|
6333
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
6334
|
+
onClick: close,
|
|
6335
|
+
children: localeService.t("sheets-formula-ui.calculation.cancel")
|
|
6336
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
6337
|
+
variant: "primary",
|
|
6338
|
+
disabled: readOnly,
|
|
6339
|
+
onClick: submit,
|
|
6340
|
+
children: localeService.t("sheets-formula-ui.calculation.confirm")
|
|
6341
|
+
})]
|
|
6342
|
+
})
|
|
6343
|
+
]
|
|
6344
|
+
});
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6190
6347
|
//#endregion
|
|
6191
6348
|
//#region src/views/formula-editor/hooks/use-formula-describe.ts
|
|
6192
6349
|
const useFormulaDescribe = (isNeed, formulaText, editor) => {
|
|
@@ -6426,10 +6583,6 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6426
6583
|
if (!isEnableMouseEnterOrOut.current) return;
|
|
6427
6584
|
setActive(index);
|
|
6428
6585
|
}
|
|
6429
|
-
function handleLiMouseLeave() {
|
|
6430
|
-
if (!isEnableMouseEnterOrOut.current) return;
|
|
6431
|
-
setActive(-1);
|
|
6432
|
-
}
|
|
6433
6586
|
useEffect(() => {
|
|
6434
6587
|
if (!searchList.length) return;
|
|
6435
6588
|
const operationId = `sheet.formula-embedding-editor.search_function.${editorId}`;
|
|
@@ -6454,7 +6607,7 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6454
6607
|
case KeyCode.TAB:
|
|
6455
6608
|
case KeyCode.ENTER: {
|
|
6456
6609
|
const item = searchList[active];
|
|
6457
|
-
handleFunctionSelect(item.name, item.functionType);
|
|
6610
|
+
if (item) handleFunctionSelect(item.name, item.functionType);
|
|
6458
6611
|
break;
|
|
6459
6612
|
}
|
|
6460
6613
|
case KeyCode.ESC:
|
|
@@ -6536,7 +6689,6 @@ function SearchFunctionFactory(props, ref) {
|
|
|
6536
6689
|
children: searchList.map((item, index) => /* @__PURE__ */ jsxs("li", {
|
|
6537
6690
|
className: clsx("univer-box-border univer-cursor-pointer univer-rounded univer-px-2 univer-py-1 univer-text-gray-900 univer-transition-colors dark:!univer-text-gray-0", { "univer-bg-gray-200 dark:!univer-bg-gray-600": active === index }),
|
|
6538
6691
|
onMouseEnter: () => handleLiMouseEnter(index),
|
|
6539
|
-
onMouseLeave: handleLiMouseLeave,
|
|
6540
6692
|
onMouseMove: debounceResetMouseState,
|
|
6541
6693
|
onClick: () => {
|
|
6542
6694
|
handleFunctionSelect(item.name, item.functionType);
|
|
@@ -6942,6 +7094,7 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
6942
7094
|
}
|
|
6943
7095
|
_registerIcons() {
|
|
6944
7096
|
this.disposeWithMe(this._iconManager.register({
|
|
7097
|
+
CalculationOptionsIcon,
|
|
6945
7098
|
DatabaseFunctionIcon,
|
|
6946
7099
|
DateFunctionIcon,
|
|
6947
7100
|
EngineeringFunctionIcon,
|
|
@@ -6959,6 +7112,7 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
6959
7112
|
this.disposeWithMe(this._componentManager.register(MORE_FUNCTIONS_COMPONENT, MoreFunctions));
|
|
6960
7113
|
this.disposeWithMe(this._componentManager.register(RANGE_SELECTOR_COMPONENT_KEY, RangeSelector));
|
|
6961
7114
|
this.disposeWithMe(this._componentManager.register(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, FormulaEditor));
|
|
7115
|
+
this.disposeWithMe(this._componentManager.register(CALCULATION_OPTIONS_COMPONENT, CalculationOptions));
|
|
6962
7116
|
}
|
|
6963
7117
|
};
|
|
6964
7118
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
@@ -7042,7 +7196,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends Plug
|
|
|
7042
7196
|
[FormulaClipboardController],
|
|
7043
7197
|
[FormulaEditorShowController],
|
|
7044
7198
|
[FormulaRenderManagerController],
|
|
7045
|
-
[FormulaReorderController],
|
|
7046
7199
|
[ImageFormulaRenderController]
|
|
7047
7200
|
]);
|
|
7048
7201
|
this._initUIPart();
|
|
@@ -7064,9 +7217,6 @@ let UniverSheetsFormulaUIPlugin = class UniverSheetsFormulaUIPlugin extends Plug
|
|
|
7064
7217
|
[ImageFormulaRenderController]
|
|
7065
7218
|
]);
|
|
7066
7219
|
}
|
|
7067
|
-
onSteady() {
|
|
7068
|
-
this._injector.get(FormulaReorderController);
|
|
7069
|
-
}
|
|
7070
7220
|
_initUIPart() {
|
|
7071
7221
|
this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(GlobalRangeSelector, this._injector)));
|
|
7072
7222
|
}
|
|
@@ -7084,4 +7234,4 @@ UniverSheetsFormulaUIPlugin = __decorate([
|
|
|
7084
7234
|
], UniverSheetsFormulaUIPlugin);
|
|
7085
7235
|
|
|
7086
7236
|
//#endregion
|
|
7087
|
-
export { FORMULA_PROMPT_ACTIVATED, FormulaEditor,
|
|
7237
|
+
export { FORMULA_PROMPT_ACTIVATED, FormulaEditor, GlobalRangeSelectorService, HelpFunctionOperation, InsertFunctionOperation, MORE_FUNCTIONS_COMPONENT, MobileRangeSelector, MoreFunctionsOperation, RangeSelector, RefSelectionsRenderService, ReferenceAbsoluteOperation, SearchFunctionOperation, SheetCopyFormulaOnlyCommand, SheetOnlyPasteFormulaCommand, menuSchema as SheetsFormulaUIMenuSchema, UniverSheetsFormulaMobileUIPlugin, UniverSheetsFormulaUIPlugin, genFormulaRefSelectionStyle };
|