Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

refactor(sheets)!: separate ui from formula and dv plugin (#3527)

Wenzhao Hu9947c22849c7
diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml
index 326fc22ab6..0b4820e593 100644
--- a/.github/workflows/playwright.yml
+++ b/.github/workflows/playwright.yml
@@ -36,6 +36,13 @@ jobs:
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID_E2E }}
+ - name: Generate Playwright Report
+ uses: daun/playwright-report-summary@v3
+ if: always()
+ with:
+ report-file: playwright-report.json
+ custom-info: 'For more information, [see full report](${{ steps.vercel-e2e-report.outputs.preview-url }})'
+
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
@@ -43,10 +50,3 @@ jobs:
name: playwright-report
path: playwright-report/
retention-days: 30
-
- - name: Generate Playwright Report
- uses: daun/playwright-report-summary@v3
- if: always()
- with:
- report-file: playwright-report.json
- custom-info: 'For more information, [see full report](${{ steps.vercel-e2e-report.outputs.preview-url }})'
diff --git a/examples/package.json b/examples/package.json
index 80c100dcbc..bdb6403fa9 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -38,12 +38,14 @@
"@univerjs/sheets-conditional-formatting-ui": "workspace:*",
"@univerjs/sheets-crosshair-highlight": "workspace:*",
"@univerjs/sheets-data-validation": "workspace:*",
+ "@univerjs/sheets-data-validation-ui": "workspace:*",
"@univerjs/sheets-drawing": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-filter-ui": "workspace:*",
"@univerjs/sheets-find-replace": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-formula-ui": "workspace:*",
"@univerjs/sheets-hyper-link": "workspace:*",
"@univerjs/sheets-hyper-link-ui": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
diff --git a/examples/src/mobile-s/main.ts b/examples/src/mobile-s/main.ts
index 3a0ce227f2..d0d930c141 100644
--- a/examples/src/mobile-s/main.ts
+++ b/examples/src/mobile-s/main.ts
@@ -26,7 +26,7 @@ import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsConditionalFormattingMobileUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';
-import { UniverSheetsDataValidationMobilePlugin } from '@univerjs/sheets-data-validation';
+import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { UniverSheetsFilterMobileUIPlugin } from '@univerjs/sheets-filter-ui';
import { UniverSheetsFormulaMobilePlugin } from '@univerjs/sheets-formula';
@@ -67,7 +67,7 @@ univer.registerPlugin(UniverSheetsFilterMobileUIPlugin);
univer.registerPlugin(UniverSheetsNumfmtPlugin);
univer.registerPlugin(UniverSheetsFormulaMobilePlugin);
univer.registerPlugin(UniverSheetsConditionalFormattingMobileUIPlugin);
-univer.registerPlugin(UniverSheetsDataValidationMobilePlugin);
+univer.registerPlugin(UniverSheetsDataValidationPlugin);
const mockUser = {
userID: 'Owner_qxVnhPbQ',
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index 770b2281d2..7cc34cbe24 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -32,9 +32,11 @@ import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
+import { UniverSheetsDataValidationUIPlugin } from '@univerjs/sheets-data-validation-ui';
import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
+import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';
import { UniverSheetsHyperLinkUIPlugin } from '@univerjs/sheets-hyper-link-ui';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui';
@@ -80,21 +82,19 @@ univer.registerPlugin(UniverSheetsNumfmtPlugin);
univer.registerPlugin(UniverSheetsZenEditorPlugin);
univer.registerPlugin(UniverFormulaEnginePlugin, { notExecuteFormula: true });
univer.registerPlugin(UniverSheetsFormulaPlugin, { notExecuteFormula: true });
+univer.registerPlugin(UniverSheetsFormulaUIPlugin);
+univer.registerPlugin(UniverSheetsDataValidationPlugin);
+univer.registerPlugin(UniverSheetsDataValidationUIPlugin);
+
// filter plugin
univer.registerPlugin(UniverSheetsFilterPlugin);
+
// mock lazy load
setTimeout(() => {
// hyperlink
univer.registerPlugin(UniverSheetsHyperLinkUIPlugin);
}, 500);
-// mock lazy load data validation
-setTimeout(() => {
- univer.registerPlugin(UniverSheetsDataValidationPlugin, {
- // showEditOnDropdown: false,
- });
-}, 500);
-
// sort
univer.registerPlugin(UniverSheetsSortUIPlugin);
// condition formatting
diff --git a/packages-experimental/uni-formula-ui/package.json b/packages-experimental/uni-formula-ui/package.json
index 4a0eaf916e..df768b2664 100644
--- a/packages-experimental/uni-formula-ui/package.json
+++ b/packages-experimental/uni-formula-ui/package.json
@@ -65,6 +65,7 @@
"@univerjs/engine-render": "workspace:*",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-formula-ui": "workspace:*",
"@univerjs/slides-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
"@univerjs/uni-formula": "workspace:*",
@@ -81,6 +82,7 @@
"@univerjs/icons": "^0.1.78",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-formula-ui": "workspace:*",
"@univerjs/slides": "workspace:*",
"@univerjs/slides-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
diff --git a/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts b/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts
index d24cfa5722..e31f612e40 100644
--- a/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts
+++ b/packages-experimental/uni-formula-ui/src/services/formula-popup.service.ts
@@ -16,7 +16,7 @@
import { BuildTextUtils, Disposable, FORMULA_EDITOR_ACTIVATED, ICommandService, IContextService, ILogService, Inject } from '@univerjs/core';
import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
-import { FORMULA_PROMPT_ACTIVATED } from '@univerjs/sheets-formula';
+import { FORMULA_PROMPT_ACTIVATED } from '@univerjs/sheets-formula-ui';
import { IShortcutService, KeyCode } from '@univerjs/ui';
import { IUniFormulaService } from '@univerjs/uni-formula';
import { BehaviorSubject, Subject } from 'rxjs';
diff --git a/packages/core/src/services/resource-manager/type.ts b/packages/core/src/services/resource-manager/type.ts
index 51fc56e846..f03e32c5d0 100644
--- a/packages/core/src/services/resource-manager/type.ts
+++ b/packages/core/src/services/resource-manager/type.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import type { Observable } from 'rxjs';
import type { UniverInstanceType } from '@univerjs/core';
-import type { IDisposable } from '../../common/di';
+import type { Observable } from 'rxjs';
import { createIdentifier } from '../../common/di';
+import type { IDisposable } from '../../common/di';
export type IResources = Array<{ id?: string; name: string; data: string }>;
diff --git a/packages/core/src/sheets/range.ts b/packages/core/src/sheets/range.ts
index 682fa5485c..c1b0831365 100644
--- a/packages/core/src/sheets/range.ts
+++ b/packages/core/src/sheets/range.ts
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-import { ObjectMatrix, Tools } from '../shared';
-import { DEFAULT_STYLES } from '../types/const';
-import { BooleanNumber, FontItalic, FontWeight, WrapStrategy } from '../types/enum';
-import { RANGE_TYPE } from './typedef';
import type { IObjectMatrixPrimitiveType, Nullable } from '../shared';
import type { HorizontalAlign, VerticalAlign } from '../types/enum';
import type {
@@ -32,6 +28,10 @@ import type {
import type { Styles } from './styles';
import type { ICellData, IRange } from './typedef';
import type { Worksheet } from './worksheet';
+import { ObjectMatrix, Tools } from '../shared';
+import { DEFAULT_STYLES } from '../types/const';
+import { BooleanNumber, FontItalic, FontWeight, WrapStrategy } from '../types/enum';
+import { RANGE_TYPE } from './typedef';
/**
* getObjectValues options type
diff --git a/packages/data-validation/src/services/data-validator-registry.service.ts b/packages/data-validation/src/services/data-validator-registry.service.ts
index 376eb8fd3f..32f19ff8b5 100644
--- a/packages/data-validation/src/services/data-validator-registry.service.ts
+++ b/packages/data-validation/src/services/data-validator-registry.service.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
+import type { BaseDataValidator } from '../validators/base-data-validator';
import { toDisposable } from '@univerjs/core';
import { BehaviorSubject } from 'rxjs';
-import type { BaseDataValidator } from '../validators/base-data-validator';
export enum DataValidatorRegistryScope {
SHEET = 'sheet',
diff --git a/packages/data-validation/src/validators/base-data-validator.ts b/packages/data-validation/src/validators/base-data-validator.ts
index f436a47215..4087471685 100644
--- a/packages/data-validation/src/validators/base-data-validator.ts
+++ b/packages/data-validation/src/validators/base-data-validator.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { DataValidationOperator, Inject, Injector, LocaleService, Tools } from '@univerjs/core';
import type { CellValue, IDataValidationRule, IDataValidationRuleBase, IStyleData, Nullable, Workbook, Worksheet } from '@univerjs/core';
import type { CellValueType } from '@univerjs/protocol';
-import { OperatorErrorTitleMap, OperatorTitleMap } from '../types/const/operator-text-map';
import type { IBaseDataValidationWidget } from './base-widget';
+import { DataValidationOperator, Inject, Injector, LocaleService, Tools } from '@univerjs/core';
+import { OperatorErrorTitleMap, OperatorTitleMap } from '../types/const/operator-text-map';
const FORMULA1 = '{FORMULA1}';
const FORMULA2 = '{FORMULA2}';
@@ -59,21 +59,19 @@ export interface IFormulaValidResult {
export abstract class BaseDataValidator<DataType = CellValue> {
abstract id: string;
-
abstract title: string;
-
abstract operators: DataValidationOperator[];
-
abstract scopes: string[] | string;
- abstract formulaInput: string;
+ // #region UI related
+ formulaInput: string | undefined = undefined;
canvasRender: Nullable<IBaseDataValidationWidget> = null;
-
dropdown: string | undefined = undefined;
-
optionsInput: string | undefined = undefined;
+ // #endregion
+
constructor(
@Inject(LocaleService) readonly localeService: LocaleService,
@Inject(Injector) readonly injector: Injector
diff --git a/packages/engine-formula/src/commands/mutations/set-formula-calculation.mutation.ts b/packages/engine-formula/src/commands/mutations/set-formula-calculation.mutation.ts
index bc3b44dbc9..4affefd874 100644
--- a/packages/engine-formula/src/commands/mutations/set-formula-calculation.mutation.ts
+++ b/packages/engine-formula/src/commands/mutations/set-formula-calculation.mutation.ts
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-import type { IExecutionOptions, IMutation, Nullable } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IExecutionOptions, IMutation, Nullable } from '@univerjs/core';
import type {
IRuntimeOtherUnitDataType,
IRuntimeUnitDataPrimitiveType,
} from '../../basics/common';
-import type { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
import type { IFormulaDirtyData } from '../../services/current-data.service';
+import type { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
export interface ISetFormulaCalculationStartMutation extends IFormulaDirtyData {
options: Nullable<IExecutionOptions>;
diff --git a/packages/engine-formula/src/commands/mutations/set-formula-data.mutation.ts b/packages/engine-formula/src/commands/mutations/set-formula-data.mutation.ts
index c4abd93bf8..10fca59b00 100644
--- a/packages/engine-formula/src/commands/mutations/set-formula-data.mutation.ts
+++ b/packages/engine-formula/src/commands/mutations/set-formula-data.mutation.ts
@@ -24,7 +24,10 @@ export interface ISetFormulaDataMutationParams {
}
/**
- * There is no need to process data here, it is used as the main thread to send data to the worker. The main thread has already updated the data in advance, and there is no need to update it again here.
+ * There is no need to process data here, it is used as the main thread to send data to the worker.
+ * The main thread has already updated the data in advance, and there is no need to update it again here.
+ *
+ * @deprecated Do not use command system as rpc calling method.
*/
export const SetFormulaDataMutation: IMutation<ISetFormulaDataMutationParams> = {
id: 'formula.mutation.set-formula-data',
diff --git a/packages/engine-formula/src/controller/calculate.controller.ts b/packages/engine-formula/src/controller/calculate.controller.ts
index 04089a309f..c8815cbc3b 100644
--- a/packages/engine-formula/src/controller/calculate.controller.ts
+++ b/packages/engine-formula/src/controller/calculate.controller.ts
@@ -14,26 +14,26 @@
* limitations under the License.
*/
-import type { ICommandInfo, IUnitRange } from '@univerjs/core';
import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';
+import type { ICommandInfo, IUnitRange } from '@univerjs/core';
-import type { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData } from '../basics/common';
-import type { ISetArrayFormulaDataMutationParams } from '../commands/mutations/set-array-formula-data.mutation';
+import { convertRuntimeToUnitData } from '../basics/runtime';
import { SetArrayFormulaDataMutation } from '../commands/mutations/set-array-formula-data.mutation';
-import type { ISetFormulaCalculationStartMutation } from '../commands/mutations/set-formula-calculation.mutation';
import {
SetFormulaCalculationNotificationMutation,
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
} from '../commands/mutations/set-formula-calculation.mutation';
-import type { ISetFormulaDataMutationParams } from '../commands/mutations/set-formula-data.mutation';
import { SetFormulaDataMutation } from '../commands/mutations/set-formula-data.mutation';
import { FormulaDataModel } from '../models/formula-data.model';
import { CalculateFormulaService } from '../services/calculate-formula.service';
-import type { IAllRuntimeData } from '../services/runtime.service';
import { FormulaExecutedStateType } from '../services/runtime.service';
-import { convertRuntimeToUnitData } from '../basics/runtime';
+import type { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData } from '../basics/common';
+import type { ISetArrayFormulaDataMutationParams } from '../commands/mutations/set-array-formula-data.mutation';
+import type { ISetFormulaCalculationStartMutation } from '../commands/mutations/set-formula-calculation.mutation';
+import type { ISetFormulaDataMutationParams } from '../commands/mutations/set-formula-data.mutation';
+import type { IAllRuntimeData } from '../services/runtime.service';
@OnLifecycle(LifecycleStages.Ready, CalculateController)
export class CalculateController extends Disposable {
@@ -139,7 +139,7 @@ export class CalculateController extends Disposable {
case FormulaExecutedStateType.STOP_EXECUTION:
break;
case FormulaExecutedStateType.SUCCESS:
- this._applyFormula(data);
+ this._applyResult(data);
break;
case FormulaExecutedStateType.INITIAL:
break;
@@ -174,7 +174,7 @@ export class CalculateController extends Disposable {
});
}
- private async _applyFormula(data: IAllRuntimeData) {
+ private async _applyResult(data: IAllRuntimeData) {
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData } = data;
if (!unitData) {
@@ -182,16 +182,11 @@ export class CalculateController extends Disposable {
return;
}
- // const deleteMutationInfo = this._deletePreviousArrayFormulaValue(arrayFormulaRange);
-
if (arrayFormulaRange) {
this._formulaDataModel.clearPreviousArrayFormulaCellData(clearArrayFormulaCellData);
-
this._formulaDataModel.mergeArrayFormulaCellData(arrayFormulaCellData);
-
this._formulaDataModel.mergeArrayFormulaRange(arrayFormulaRange);
- // Synchronous to the main thread
this._commandService.executeCommand(
SetArrayFormulaDataMutation.id,
{
diff --git a/packages/engine-formula/src/functions/compatibility/betadist/index.ts b/packages/engine-formula/src/functions/compatibility/betadist/index.ts
index 04ec0c214e..68d11793ce 100644
--- a/packages/engine-formula/src/functions/compatibility/betadist/index.ts
+++ b/packages/engine-formula/src/functions/compatibility/betadist/index.ts
@@ -18,10 +18,10 @@ import { ErrorType } from '../../../basics/error-type';
import { betaCDF } from '../../../basics/statistical';
import { expandArrayValueObject } from '../../../engine/utils/array-object';
import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
-import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
import { NumberValueObject } from '../../../engine/value-object/primitive-object';
import { BaseFunction } from '../../base-function';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
export class Betadist extends BaseFunction {
override minParams = 3;
diff --git a/packages/engine-formula/src/services/active-dirty-manager.service.ts b/packages/engine-formula/src/services/active-dirty-manager.service.ts
index db3d864b38..8157306d28 100644
--- a/packages/engine-formula/src/services/active-dirty-manager.service.ts
+++ b/packages/engine-formula/src/services/active-dirty-manager.service.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { ICommandInfo, IUnitRange, Nullable } from '@univerjs/core';
import { createIdentifier, Disposable } from '@univerjs/core';
+import type { ICommandInfo, IUnitRange, Nullable } from '@univerjs/core';
import type { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap } from '../basics/common';
export interface IDirtyConversionManagerParams {
diff --git a/packages/engine-render/src/components/docs/layout/doc-skeleton.ts b/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
index c4d4d6600e..932eec7511 100644
--- a/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
+++ b/packages/engine-render/src/components/docs/layout/doc-skeleton.ts
@@ -14,9 +14,19 @@
* limitations under the License.
*/
+import type { ColumnSeparatorType, ISectionColumnProperties, LocaleService, Nullable } from '@univerjs/core';
+import type {
+ IDocumentSkeletonCached,
+ IDocumentSkeletonGlyph,
+ IDocumentSkeletonPage,
+ ISkeletonResourceReference,
+} from '../../../basics/i-document-skeleton-cached';
+import type { IDocsConfig, INodeInfo, INodePosition, INodeSearch } from '../../../basics/interfaces';
+import type { IViewportInfo, Vector2 } from '../../../basics/vector2';
+import type { DocumentViewModel } from '../view-model/document-view-model';
+import type { ILayoutContext } from './tools';
import { PRESET_LIST_TYPE, SectionType } from '@univerjs/core';
import { Subject } from 'rxjs';
-import type { ColumnSeparatorType, ISectionColumnProperties, LocaleService, Nullable } from '@univerjs/core';
import { DocumentSkeletonPageType, GlyphType, LineType, PageLayoutType } from '../../../basics/i-document-skeleton-cached';
import { Skeleton } from '../../skeleton';
import { Liquid } from '../liquid';
@@ -27,16 +37,6 @@ import { LanguageDetector } from './hyphenation/language-detector';
import { createSkeletonPage } from './model/page';
import { createSkeletonSection } from './model/section';
import { getLastPage, getNullSkeleton, getPageFromPath, prepareSectionBreakConfig, resetContext, setPageParent, updateBlockIndex, updateInlineDrawingCoords } from './tools';
-import type {
- IDocumentSkeletonCached,
- IDocumentSkeletonGlyph,
- IDocumentSkeletonPage,
- ISkeletonResourceReference,
-} from '../../../basics/i-document-skeleton-cached';
-import type { IDocsConfig, INodeInfo, INodePosition, INodeSearch } from '../../../basics/interfaces';
-import type { IViewportInfo, Vector2 } from '../../../basics/vector2';
-import type { DocumentViewModel } from '../view-model/document-view-model';
-import type { ILayoutContext } from './tools';
export enum DocumentSkeletonState {
PENDING = 'pending',
diff --git a/packages/facade/package.json b/packages/facade/package.json
index a7cb3c96fe..636670ad54 100644
--- a/packages/facade/package.json
+++ b/packages/facade/package.json
@@ -72,6 +72,7 @@
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-filter-ui": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-formula-ui": "workspace:*",
"@univerjs/sheets-hyper-link-ui": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
"@univerjs/sheets-thread-comment": "workspace:*",
@@ -97,6 +98,7 @@
"@univerjs/sheets-filter": "workspace:*",
"@univerjs/sheets-filter-ui": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-formula-ui": "workspace:*",
"@univerjs/sheets-hyper-link": "workspace:*",
"@univerjs/sheets-hyper-link-ui": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
diff --git a/packages/facade/src/apis/__tests__/create-test-bed.ts b/packages/facade/src/apis/__tests__/create-test-bed.ts
index 84d0bc10d2..7aeb6c8737 100644
--- a/packages/facade/src/apis/__tests__/create-test-bed.ts
+++ b/packages/facade/src/apis/__tests__/create-test-bed.ts
@@ -54,8 +54,8 @@ import {
RegisterFunctionService,
RegisterOtherFormulaService,
} from '@univerjs/sheets-formula';
-import enUS from '@univerjs/sheets-formula/locale/en-US';
-import zhCN from '@univerjs/sheets-formula/locale/zh-CN';
+import enUS from '@univerjs/sheets-formula-ui/locale/en-US';
+import zhCN from '@univerjs/sheets-formula-ui/locale/zh-CN';
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
import { ISheetSelectionRenderService, SheetRenderController, SheetSelectionRenderService, SheetSkeletonManagerService, SheetsRenderService } from '@univerjs/sheets-ui';
import { IThreadCommentDataSourceService, ThreadCommentDataSourceService, ThreadCommentModel } from '@univerjs/thread-comment';
diff --git a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
index 3c2fffef30..ad4f025795 100644
--- a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
+++ b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts
@@ -28,8 +28,8 @@ import {
import { DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService } from '@univerjs/docs';
import { DocIMEInputManagerService, DocsRenderService, DocStateChangeManagerService } from '@univerjs/docs-ui';
import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
-import enUS from '@univerjs/sheets-formula/locale/en-US';
-import zhCN from '@univerjs/sheets-formula/locale/zh-CN';
+import enUS from '@univerjs/sheets-formula-ui/locale/en-US';
+import zhCN from '@univerjs/sheets-formula-ui/locale/zh-CN';
import type { Dependency, DocumentDataModel, IDocumentData } from '@univerjs/core';
import { FUniver } from '../../facade';
diff --git a/packages/facade/src/apis/f-hooks.ts b/packages/facade/src/apis/f-hooks.ts
index 89f6fa80eb..b71bfc0438 100644
--- a/packages/facade/src/apis/f-hooks.ts
+++ b/packages/facade/src/apis/f-hooks.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Inject, Injector, LifecycleService, LifecycleStages, toDisposable } from '@univerjs/core';
import type { IDisposable } from '@univerjs/core';
+import { Inject, Injector, LifecycleService, LifecycleStages, toDisposable } from '@univerjs/core';
import { filter } from 'rxjs';
import { FClipboardHooks } from './hooks/f-clipboard-hooks';
import { FUndoRedoHooks } from './hooks/f-undoredo-hooks';
diff --git a/packages/facade/src/apis/facade.ts b/packages/facade/src/apis/facade.ts
index badd7a8a7f..f39f8a72b1 100644
--- a/packages/facade/src/apis/facade.ts
+++ b/packages/facade/src/apis/facade.ts
@@ -14,29 +14,6 @@
* limitations under the License.
*/
-import {
- BorderStyleTypes,
- debounce,
- ICommandService,
- Inject,
- Injector,
- IUniverInstanceService,
- Quantity,
- RedoCommand,
- toDisposable,
- UndoCommand,
- Univer,
- UniverInstanceType,
- WrapStrategy,
-} from '@univerjs/core';
-import { SetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { ISocketService, WebSocketService } from '@univerjs/network';
-import { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, SetCrosshairHighlightColorOperation } from '@univerjs/sheets-crosshair-highlight';
-import { IRegisterFunctionService, RegisterFunctionService } from '@univerjs/sheets-formula';
-
-import { SHEET_VIEW_KEY } from '@univerjs/sheets-ui';
-import { CopyCommand, PasteCommand } from '@univerjs/ui';
import type {
CommandListener,
Dependency,
@@ -59,6 +36,29 @@ import type {
import type { ISocket } from '@univerjs/network';
import type { ISetCrosshairHighlightColorOperationParams } from '@univerjs/sheets-crosshair-highlight';
import type { IRegisterFunctionParams } from '@univerjs/sheets-formula';
+import {
+ BorderStyleTypes,
+ debounce,
+ ICommandService,
+ Inject,
+ Injector,
+ IUniverInstanceService,
+ Quantity,
+ RedoCommand,
+ toDisposable,
+ UndoCommand,
+ Univer,
+ UniverInstanceType,
+ WrapStrategy,
+} from '@univerjs/core';
+
+import { SetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
+import { IRenderManagerService } from '@univerjs/engine-render';
+import { ISocketService, WebSocketService } from '@univerjs/network';
+import { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, SetCrosshairHighlightColorOperation } from '@univerjs/sheets-crosshair-highlight';
+import { IRegisterFunctionService, RegisterFunctionService } from '@univerjs/sheets-formula';
+import { SHEET_VIEW_KEY } from '@univerjs/sheets-ui';
+import { CopyCommand, PasteCommand } from '@univerjs/ui';
import { FDocument } from './docs/f-document';
import { FHooks } from './f-hooks';
import { FDataValidationBuilder } from './sheets/f-data-validation-builder';
diff --git a/packages/facade/src/apis/sheets/__tests__/create-formula-test-bed.ts b/packages/facade/src/apis/sheets/__tests__/create-formula-test-bed.ts
index b3b00f3696..e0fa87295a 100644
--- a/packages/facade/src/apis/sheets/__tests__/create-formula-test-bed.ts
+++ b/packages/facade/src/apis/sheets/__tests__/create-formula-test-bed.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { Dependency, IWorkbookData, Workbook } from '@univerjs/core';
import {
ILogService,
Inject,
@@ -28,6 +27,7 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { ActiveDirtyManagerService, AstRootNodeFactory, AstTreeBuilder, CalculateController, CalculateFormulaService, DefinedNamesService, DependencyManagerService, FeatureCalculationManagerService, FormulaCurrentConfigService, FormulaDataModel, FormulaDependencyGenerator, FormulaRuntimeService, FunctionNodeFactory, FunctionService, IActiveDirtyManagerService, IDefinedNamesService, IDependencyManagerService, IFeatureCalculationManagerService, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, Interpreter, IOtherFormulaManagerService, ISuperTableService, LambdaNodeFactory, LambdaParameterNodeFactory, Lexer, LexerTreeBuilder, OperatorNodeFactory, OtherFormulaManagerService, PrefixNodeFactory, ReferenceNodeFactory, SuffixNodeFactory, SuperTableService, UnionNodeFactory, ValueNodeFactory } from '@univerjs/engine-formula';
+import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
import { ISocketService, WebSocketService } from '@univerjs/network';
import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
import {
@@ -36,10 +36,10 @@ import {
IRegisterFunctionService,
RegisterFunctionService,
} from '@univerjs/sheets-formula';
-import enUS from '@univerjs/sheets-formula/locale/en-US';
-import zhCN from '@univerjs/sheets-formula/locale/zh-CN';
+import enUS from '@univerjs/sheets-formula-ui/locale/en-US';
+import zhCN from '@univerjs/sheets-formula-ui/locale/zh-CN';
-import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
+import type { Dependency, IWorkbookData, Workbook } from '@univerjs/core';
import { FUniver } from '../../facade';
function getTestWorkbookDataDemo(): IWorkbookData {
diff --git a/packages/facade/src/apis/sheets/__tests__/create-worksheet-test-bed.ts b/packages/facade/src/apis/sheets/__tests__/create-worksheet-test-bed.ts
index 1253973b60..ef7bc2e921 100644
--- a/packages/facade/src/apis/sheets/__tests__/create-worksheet-test-bed.ts
+++ b/packages/facade/src/apis/sheets/__tests__/create-worksheet-test-bed.ts
@@ -54,8 +54,8 @@ import {
RegisterFunctionService,
RegisterOtherFormulaService,
} from '@univerjs/sheets-formula';
-import enUS from '@univerjs/sheets-formula/locale/en-US';
-import zhCN from '@univerjs/sheets-formula/locale/zh-CN';
+import enUS from '@univerjs/sheets-formula-ui/locale/en-US';
+import zhCN from '@univerjs/sheets-formula-ui/locale/zh-CN';
import { ISheetSelectionRenderService, SheetRenderController, SheetSelectionRenderService, SheetSkeletonManagerService, SheetsRenderService } from '@univerjs/sheets-ui';
import { IPlatformService, IShortcutService, PlatformService, ShortcutService } from '@univerjs/ui';
import type { Dependency, IWorkbookData, UnitModel } from '@univerjs/core';
diff --git a/packages/facade/src/apis/sheets/f-data-validation-builder.ts b/packages/facade/src/apis/sheets/f-data-validation-builder.ts
index 10baea594d..8753469c19 100644
--- a/packages/facade/src/apis/sheets/f-data-validation-builder.ts
+++ b/packages/facade/src/apis/sheets/f-data-validation-builder.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
+import type { IDataValidationRule } from '@univerjs/core';
+import type { FRange } from './f-range';
import { DataValidationErrorStyle, DataValidationOperator, DataValidationType, generateRandomId } from '@univerjs/core';
import { serializeRangeToRefString } from '@univerjs/engine-formula';
-import type { IDataValidationRule } from '@univerjs/core';
import { FDataValidation } from './f-data-validation';
-import type { FRange } from './f-range';
/**
* Builder for data validation rules.
diff --git a/packages/facade/src/apis/sheets/f-data-validation.ts b/packages/facade/src/apis/sheets/f-data-validation.ts
index e95baa8496..2c7ced8b64 100644
--- a/packages/facade/src/apis/sheets/f-data-validation.ts
+++ b/packages/facade/src/apis/sheets/f-data-validation.ts
@@ -15,13 +15,12 @@
*/
import type { DataValidationOperator, DataValidationType, IDataValidationRule, IDataValidationRuleOptions, IRange } from '@univerjs/core';
+import type { IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams } from '@univerjs/sheets-data-validation';
+import type { FWorksheet } from './f-worksheet';
import { DataValidationErrorStyle, ICommandService } from '@univerjs/core';
-
import { DataValidationModel, getRuleOptions } from '@univerjs/data-validation';
-import type { IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams } from '@univerjs/sheets-data-validation';
import { RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from '@univerjs/sheets-data-validation';
import { FDataValidationBuilder } from './f-data-validation-builder';
-import type { FWorksheet } from './f-worksheet';
import { FRange } from './f-range';
export class FDataValidation {
diff --git a/packages/facade/src/apis/sheets/f-filter.ts b/packages/facade/src/apis/sheets/f-filter.ts
index b8c6a4cba5..f962665e22 100644
--- a/packages/facade/src/apis/sheets/f-filter.ts
+++ b/packages/facade/src/apis/sheets/f-filter.ts
@@ -15,11 +15,11 @@
*/
import type { Nullable, Workbook, Worksheet } from '@univerjs/core';
-import { ICommandService, Inject, Injector } from '@univerjs/core';
+import type { ISheetCommandSharedParams } from '@univerjs/sheets';
import type { FilterModel, IFilterColumn } from '@univerjs/sheets-filter';
import type { ISetSheetsFilterCriteriaCommandParams } from '@univerjs/sheets-filter-ui';
+import { ICommandService, Inject, Injector } from '@univerjs/core';
import { ClearSheetsFilterCriteriaCommand, RemoveSheetFilterCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter-ui';
-import type { ISheetCommandSharedParams } from '@univerjs/sheets';
import { FRange } from './f-range';
/**
diff --git a/packages/facade/src/apis/sheets/f-formula.ts b/packages/facade/src/apis/sheets/f-formula.ts
index ea4b4d6ea3..b93ad22aa8 100644
--- a/packages/facade/src/apis/sheets/f-formula.ts
+++ b/packages/facade/src/apis/sheets/f-formula.ts
@@ -15,8 +15,8 @@
*/
import type { ICommandInfo, IDisposable } from '@univerjs/core';
-import { ICommandService } from '@univerjs/core';
import type { FormulaExecutedStateType, IExecutionInProgressParams, ISetFormulaCalculationNotificationMutation, ISetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
+import { ICommandService } from '@univerjs/core';
import { SetFormulaCalculationNotificationMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
/**
diff --git a/packages/facade/src/apis/sheets/f-permission.ts b/packages/facade/src/apis/sheets/f-permission.ts
index 2544019f6c..762041851b 100644
--- a/packages/facade/src/apis/sheets/f-permission.ts
+++ b/packages/facade/src/apis/sheets/f-permission.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
+import type { IRange, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor } from '@univerjs/core';
import { generateRandomId, IAuthzIoService, ICommandService, Inject, Injector, IPermissionService, Rectangle } from '@univerjs/core';
import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, RangeProtectionRuleModel, SetRangeProtectionMutation, SetWorksheetPermissionPointsMutation, UnitObject, WorkbookEditablePermission, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
-import type { IRange, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor } from '@univerjs/core';
export class FPermission {
constructor(
diff --git a/packages/facade/src/apis/sheets/f-range.ts b/packages/facade/src/apis/sheets/f-range.ts
index 0223292d48..1477dd91d6 100644
--- a/packages/facade/src/apis/sheets/f-range.ts
+++ b/packages/facade/src/apis/sheets/f-range.ts
@@ -14,28 +14,6 @@
* limitations under the License.
*/
-import { BooleanNumber, CustomRangeType, Dimension, generateRandomId, ICommandService, Inject, Injector, Tools, UserManagerService, WrapStrategy } from '@univerjs/core';
-import { FormulaDataModel } from '@univerjs/engine-formula';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import {
- addMergeCellsUtil,
- getAddMergeMutationRangeByType,
- RemoveWorksheetMergeCommand,
- SetHorizontalTextAlignCommand,
- SetRangeValuesCommand,
- SetStyleCommand,
- SetTextWrapCommand,
- SetVerticalTextAlignCommand,
-} from '@univerjs/sheets';
-import { AddSheetDataValidationCommand, ClearRangeDataValidationCommand, SheetsDataValidationValidatorService } from '@univerjs/sheets-data-validation';
-import { SheetsFilterService } from '@univerjs/sheets-filter';
-import { SetSheetFilterRangeCommand } from '@univerjs/sheets-filter-ui';
-import { AddHyperLinkCommand, CancelHyperLinkCommand, UpdateHyperLinkCommand } from '@univerjs/sheets-hyper-link-ui';
-import { SetNumfmtCommand } from '@univerjs/sheets-numfmt';
-import { AddCommentCommand, DeleteCommentTreeCommand, SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
-import { CellAlertManagerService, ISheetClipboardService, SheetCanvasPopManagerService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
-import { getDT } from '@univerjs/thread-comment-ui';
-import { ComponentManager } from '@univerjs/ui';
import type {
CellValue,
DataValidationStatus,
@@ -66,6 +44,29 @@ import type { ISetSheetFilterRangeCommandParams } from '@univerjs/sheets-filter-
import type { IAddHyperLinkCommandParams, ICancelHyperLinkCommandParams, IUpdateHyperLinkCommandParams } from '@univerjs/sheets-hyper-link-ui';
import type { ISetNumfmtCommandParams } from '@univerjs/sheets-numfmt';
import type { ICanvasPopup, ICellAlert } from '@univerjs/sheets-ui';
+import type { FHorizontalAlignment, FVerticalAlignment, IFComponentKey } from './utils';
+import { BooleanNumber, CustomRangeType, Dimension, generateRandomId, ICommandService, Inject, Injector, Tools, UserManagerService, WrapStrategy } from '@univerjs/core';
+import { FormulaDataModel } from '@univerjs/engine-formula';
+import { IRenderManagerService } from '@univerjs/engine-render';
+import {
+ addMergeCellsUtil,
+ getAddMergeMutationRangeByType,
+ RemoveWorksheetMergeCommand,
+ SetHorizontalTextAlignCommand,
+ SetRangeValuesCommand,
+ SetStyleCommand,
+ SetTextWrapCommand,
+ SetVerticalTextAlignCommand,
+} from '@univerjs/sheets';
+import { AddSheetDataValidationCommand, ClearRangeDataValidationCommand, SheetsDataValidationValidatorService } from '@univerjs/sheets-data-validation';
+import { SheetsFilterService } from '@univerjs/sheets-filter';
+import { SetSheetFilterRangeCommand } from '@univerjs/sheets-filter-ui';
+import { AddHyperLinkCommand, CancelHyperLinkCommand, UpdateHyperLinkCommand } from '@univerjs/sheets-hyper-link-ui';
+import { SetNumfmtCommand } from '@univerjs/sheets-numfmt';
+import { AddCommentCommand, DeleteCommentTreeCommand, SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
+import { CellAlertManagerService, ISheetClipboardService, SheetCanvasPopManagerService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
+import { getDT } from '@univerjs/thread-comment-ui';
+import { ComponentManager } from '@univerjs/ui';
import { FDataValidation } from './f-data-validation';
import { FFilter } from './f-filter';
import { FThreadComment } from './f-thread-comment';
@@ -79,7 +80,6 @@ import {
transformFacadeHorizontalAlignment,
transformFacadeVerticalAlignment,
} from './utils';
-import type { FHorizontalAlignment, FVerticalAlignment, IFComponentKey } from './utils';
export type FontLine = 'none' | 'underline' | 'line-through';
export type FontStyle = 'normal' | 'italic';
diff --git a/packages/facade/src/apis/sheets/f-sheet-hooks.ts b/packages/facade/src/apis/sheets/f-sheet-hooks.ts
index 0d8f127fce..d7a75f842d 100644
--- a/packages/facade/src/apis/sheets/f-sheet-hooks.ts
+++ b/packages/facade/src/apis/sheets/f-sheet-hooks.ts
@@ -15,9 +15,9 @@
*/
import type { IDisposable, Nullable } from '@univerjs/core';
-import { ICommandService, Inject, Injector, toDisposable } from '@univerjs/core';
-
import type { IDragCellPosition, IHoverCellPosition } from '@univerjs/sheets-ui';
+
+import { ICommandService, Inject, Injector, toDisposable } from '@univerjs/core';
import { DragManagerService, HoverManagerService } from '@univerjs/sheets-ui';
export class FSheetHooks {
diff --git a/packages/facade/src/apis/sheets/f-thread-comment.ts b/packages/facade/src/apis/sheets/f-thread-comment.ts
index 5eb687044c..e80efbac9d 100644
--- a/packages/facade/src/apis/sheets/f-thread-comment.ts
+++ b/packages/facade/src/apis/sheets/f-thread-comment.ts
@@ -15,12 +15,12 @@
*/
import type { IDocumentBody, IRange, Workbook } from '@univerjs/core';
-import { ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import type { IBaseComment, IDeleteCommentCommandParams, IResolveCommentCommandParams, IThreadComment, IUpdateCommentCommandParams } from '@univerjs/thread-comment';
-import { DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand } from '@univerjs/thread-comment';
-import { getDT } from '@univerjs/thread-comment-ui';
+import { ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { deserializeRangeWithSheet } from '@univerjs/engine-formula';
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
+import { DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand } from '@univerjs/thread-comment';
+import { getDT } from '@univerjs/thread-comment-ui';
import { FRange } from './f-range';
export class FThreadComment {
diff --git a/packages/facade/src/apis/sheets/f-workbook.ts b/packages/facade/src/apis/sheets/f-workbook.ts
index 1a15e07539..7e1a2b7089 100644
--- a/packages/facade/src/apis/sheets/f-workbook.ts
+++ b/packages/facade/src/apis/sheets/f-workbook.ts
@@ -14,6 +14,19 @@
* limitations under the License.
*/
+import type { CommandListener, ICommandInfo, IDisposable, IExecutionOptions, IRange, IWorkbookData, Nullable, ObjectMatrix, Workbook } from '@univerjs/core';
+import type { IRuleChange, IValidStatusChange } from '@univerjs/data-validation';
+import type { IUpdateCommandParams } from '@univerjs/docs-ui';
+import type {
+ ISetSelectionsOperationParams,
+ ISheetCommandSharedParams,
+} from '@univerjs/sheets';
+import type { IAddSheetDataValidationCommandParams, IDataValidationResCache, IRemoveSheetAllDataValidationCommandParams, IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams } from '@univerjs/sheets-data-validation';
+import type { ICanvasFloatDom } from '@univerjs/sheets-drawing-ui';
+import type { ISheetHyperLinkInfo } from '@univerjs/sheets-hyper-link-ui';
+import type { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams } from '@univerjs/thread-comment';
+import type { IDialogPartMethodOptions, ISidebarMethodOptions } from '@univerjs/ui';
+import type { IFComponentKey } from './utils';
import {
ICommandService,
ILogService,
@@ -34,21 +47,8 @@ import { SheetsHyperLinkResolverService } from '@univerjs/sheets-hyper-link-ui';
import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ThreadCommentModel, UpdateCommentCommand } from '@univerjs/thread-comment';
import { IDialogService, ISidebarService } from '@univerjs/ui';
import { filter } from 'rxjs';
-import type { CommandListener, ICommandInfo, IDisposable, IExecutionOptions, IRange, IWorkbookData, Nullable, ObjectMatrix, Workbook } from '@univerjs/core';
-import type { IRuleChange, IValidStatusChange } from '@univerjs/data-validation';
-import type { IUpdateCommandParams } from '@univerjs/docs-ui';
-import type {
- ISetSelectionsOperationParams,
- ISheetCommandSharedParams,
-} from '@univerjs/sheets';
-import type { IAddSheetDataValidationCommandParams, IDataValidationResCache, IRemoveSheetAllDataValidationCommandParams, IRemoveSheetDataValidationCommandParams, IUpdateSheetDataValidationOptionsCommandParams, IUpdateSheetDataValidationRangeCommandParams, IUpdateSheetDataValidationSettingCommandParams } from '@univerjs/sheets-data-validation';
-import type { ICanvasFloatDom } from '@univerjs/sheets-drawing-ui';
-import type { ISheetHyperLinkInfo } from '@univerjs/sheets-hyper-link-ui';
-import type { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams } from '@univerjs/thread-comment';
-import type { IDialogPartMethodOptions, ISidebarMethodOptions } from '@univerjs/ui';
import { FRange } from './f-range';
import { FWorksheet } from './f-worksheet';
-import type { IFComponentKey } from './utils';
export interface IFICanvasFloatDom extends Omit<ICanvasFloatDom, 'componentKey' | 'unitId' | 'subUnitId'>, IFComponentKey {
diff --git a/packages/facade/src/apis/sheets/f-worksheet.ts b/packages/facade/src/apis/sheets/f-worksheet.ts
index f3cd571847..d8d8a30a35 100644
--- a/packages/facade/src/apis/sheets/f-worksheet.ts
+++ b/packages/facade/src/apis/sheets/f-worksheet.ts
@@ -14,26 +14,26 @@
* limitations under the License.
*/
+import type { IFreeze, IRange, Nullable, ObjectMatrix, Workbook, Worksheet } from '@univerjs/core';
+import type { IDataValidationResCache } from '@univerjs/sheets-data-validation';
+import type { FilterModel } from '@univerjs/sheets-filter';
+
+import type { FWorkbook, IFICanvasFloatDom } from './f-workbook';
import { Direction, ICommandService, Inject, Injector, RANGE_TYPE } from '@univerjs/core';
import { deserializeRangeWithSheet } from '@univerjs/engine-formula';
import { copyRangeStyles, InsertColCommand, InsertRowCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, SetColHiddenCommand, SetColWidthCommand, SetFrozenCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetRowIsAutoHeightCommand, SheetsSelectionsService } from '@univerjs/sheets';
-
import { DataValidationModel, SheetsDataValidationValidatorService } from '@univerjs/sheets-data-validation';
import { SheetCanvasFloatDomManagerService } from '@univerjs/sheets-drawing-ui';
import { SheetsFilterService } from '@univerjs/sheets-filter';
import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
import { CancelFrozenCommand } from '@univerjs/sheets-ui';
import { ComponentManager } from '@univerjs/ui';
-import type { IFreeze, IRange, Nullable, ObjectMatrix, Workbook, Worksheet } from '@univerjs/core';
-import type { IDataValidationResCache } from '@univerjs/sheets-data-validation';
-import type { FilterModel } from '@univerjs/sheets-filter';
import { FDataValidation } from './f-data-validation';
import { FFilter } from './f-filter';
import { FRange } from './f-range';
import { FSelection } from './f-selection';
import { FThreadComment } from './f-thread-comment';
import { covertToColRange, covertToRowRange, transformComponentKey } from './utils';
-import type { FWorkbook, IFICanvasFloatDom } from './f-workbook';
export class FWorksheet {
constructor(
diff --git a/packages/facade/src/apis/sheets/utils.ts b/packages/facade/src/apis/sheets/utils.ts
index f4b9eacbdc..fccb8987e5 100644
--- a/packages/facade/src/apis/sheets/utils.ts
+++ b/packages/facade/src/apis/sheets/utils.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import type { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IRangeWithCoord, Nullable, Worksheet } from '@univerjs/core';
+import type { ComponentManager, ComponentType } from '@univerjs/ui';
import {
DisposableCollection,
generateRandomId,
@@ -26,8 +28,6 @@ import {
Tools,
VerticalAlign,
} from '@univerjs/core';
-import type { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IRangeWithCoord, Nullable, Worksheet } from '@univerjs/core';
-import type { ComponentManager, ComponentType } from '@univerjs/ui';
export type FHorizontalAlignment = 'left' | 'center' | 'normal';
export type FVerticalAlignment = 'top' | 'middle' | 'bottom';
diff --git a/packages/sheets-data-validation-ui/README.md b/packages/sheets-data-validation-ui/README.md
new file mode 100644
index 0000000000..10bafaf311
--- /dev/null
+++ b/packages/sheets-data-validation-ui/README.md
@@ -0,0 +1,38 @@
+# @univerjs/sheets-data-validation-ui
+
+## Package Overview
+
+| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
+| --- | --- | --- | --- | --- | :---: | :---: |
+| `@univerjs/sheets-data-validation-ui` | `UniverSheetsDataValidationUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
+
+## Introduction
+
+> `@univerjs/sheets-data-validation-ui` provides UI Univer Sheet data validation.
+
+## Usage
+
+### Installation
+
+```shell
+# Using npm
+npm i @univerjs/sheets-data-validation-ui
+
+# Using pnpm
+pnpm add
+```
+
+### Register the plugin
+
+```typescript
+import { UniverSheetsDataValidationUiPlugin } from '@univerjs/sheets-data-validation-ui';
+
+univer.registerPlugin(UniverDataValidationPlugin);
+univer.registerPlugin(UniverSheetsDataValidationUiPlugin);
+```
+
+<!-- Links -->
+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-data-validation-ui?style=flat-square
+[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-data-validation-ui
+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-data-validation-ui?style=flat-square
+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-data-validation-ui?style=flat-square
diff --git a/packages/sheets-data-validation-ui/package.json b/packages/sheets-data-validation-ui/package.json
new file mode 100644
index 0000000000..436a57b025
--- /dev/null
+++ b/packages/sheets-data-validation-ui/package.json
@@ -0,0 +1,126 @@
+{
+ "name": "@univerjs/sheets-data-validation-ui",
+ "version": "0.3.0",
+ "private": false,
+ "description": "Data validation UI for Univer Sheets",
+ "author": "DreamNum <[email protected]>",
+ "license": "Apache-2.0",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/univer"
+ },
+ "homepage": "https://univer.ai",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dream-num/univer"
+ },
+ "bugs": {
+ "url": "https://github.com/dream-num/univer/issues"
+ },
+ "keywords": [
+ "univer"
+ ],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "dev": "vite",
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "build": "tsc && vite build",
+ "lint:types": "tsc --noEmit"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/data-validation": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-data-validation": "workspace:*",
+ "@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-numfmt": "workspace:*",
+ "@univerjs/sheets-ui": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "clsx": ">=2.0.0",
+ "dayjs": ">=1.11.0",
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
+ "rxjs": ">=7.0.0"
+ },
+ "dependencies": {
+ "@flatten-js/interval-tree": "^1.1.3",
+ "@univerjs/core": "workspace:*",
+ "@univerjs/data-validation": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/icons": "^0.1.78",
+ "@univerjs/protocol": "0.1.39-alpha.15",
+ "@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-data-validation": "workspace:*",
+ "@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-numfmt": "workspace:*",
+ "@univerjs/sheets-ui": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "clsx": "^2.1.1",
+ "dayjs": "^1.11.13"
+ },
+ "devDependencies": {
+ "@univerjs-infra/shared": "workspace:*",
+ "less": "^4.2.0",
+ "react": "18.3.1",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.6.2",
+ "vite": "^5.4.8",
+ "vitest": "^2.1.1"
+ },
+ "univerSpace": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+}
diff --git a/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts b/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts
new file mode 100644
index 0000000000..a50cedfeb4
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICommand } from '@univerjs/core';
+import type { IAddSheetDataValidationCommandParams } from '@univerjs/sheets-data-validation';
+import { CommandType, ICommandService, IUniverInstanceService } from '@univerjs/core';
+import { getSheetCommandTarget } from '@univerjs/sheets';
+import { AddSheetDataValidationCommand, createDefaultNewRule } from '@univerjs/sheets-data-validation';
+import { OpenValidationPanelOperation } from '../operations/data-validation.operation';
+
+export const AddSheetDataValidationAndOpenCommand: ICommand = {
+ type: CommandType.COMMAND,
+ id: 'data-validation.command.addRuleAndOpen',
+ async handler(accessor) {
+ const univerInstanceService = accessor.get(IUniverInstanceService);
+ const target = getSheetCommandTarget(univerInstanceService);
+ if (!target) return false;
+
+ const { workbook, worksheet } = target;
+ const rule = createDefaultNewRule(accessor);
+ const commandService = accessor.get(ICommandService);
+ const unitId = workbook.getUnitId();
+ const subUnitId = worksheet.getSheetId();
+
+ const addParams: IAddSheetDataValidationCommandParams = {
+ rule,
+ unitId,
+ subUnitId,
+ };
+
+ const res = await commandService.executeCommand(AddSheetDataValidationCommand.id, addParams);
+
+ if (res) {
+ commandService.executeCommand(OpenValidationPanelOperation.id, {
+ ruleId: rule.uid,
+ isAdd: true,
+ });
+
+ return true;
+ }
+ return false;
+ },
+};
diff --git a/packages/sheets-data-validation/src/commands/operations/data-validation.operation.ts b/packages/sheets-data-validation-ui/src/commands/operations/data-validation.operation.ts
similarity index 100%
rename from packages/sheets-data-validation/src/commands/operations/data-validation.operation.ts
rename to packages/sheets-data-validation-ui/src/commands/operations/data-validation.operation.ts
index 1a2e6be648..0a61e4e135 100644
--- a/packages/sheets-data-validation/src/commands/operations/data-validation.operation.ts
+++ b/packages/sheets-data-validation-ui/src/commands/operations/data-validation.operation.ts
@@ -15,11 +15,11 @@
*/
import { CommandType, type ICommand, ICommandService, IUniverInstanceService } from '@univerjs/core';
-import { ISidebarService } from '@univerjs/ui';
import { DataValidationModel } from '@univerjs/data-validation';
import { getSheetCommandTarget } from '@univerjs/sheets';
-import { DataValidationDropdownManagerService } from '../../services/dropdown-manager.service';
+import { ISidebarService } from '@univerjs/ui';
import { DataValidationPanelService } from '../../services/data-validation-panel.service';
+import { DataValidationDropdownManagerService } from '../../services/dropdown-manager.service';
export const DATA_VALIDATION_PANEL = 'DataValidationPanel';
diff --git a/packages/sheets-data-validation-ui/src/const.ts b/packages/sheets-data-validation-ui/src/const.ts
new file mode 100644
index 0000000000..1f7151c943
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/const.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const DROP_DOWN_DEFAULT_COLOR = '#ECECEC';
diff --git a/packages/sheets-data-validation/src/controllers/config.schema.ts b/packages/sheets-data-validation-ui/src/controllers/config.schema.ts
similarity index 100%
rename from packages/sheets-data-validation/src/controllers/config.schema.ts
rename to packages/sheets-data-validation-ui/src/controllers/config.schema.ts
diff --git a/packages/sheets-data-validation/src/controllers/dv-alert.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts
similarity index 100%
rename from packages/sheets-data-validation/src/controllers/dv-alert.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts
index 9852606331..ab8a51bd7b 100644
--- a/packages/sheets-data-validation/src/controllers/dv-alert.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { Workbook } from '@univerjs/core';
+import type { BaseDataValidator } from '@univerjs/data-validation';
import { DataValidationStatus, Disposable, Inject, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import { CellAlertManagerService, CellAlertType, HoverManagerService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
import { debounceTime } from 'rxjs';
-import type { Workbook } from '@univerjs/core';
-import type { BaseDataValidator } from '@univerjs/data-validation';
const ALERT_KEY = 'SHEET_DATA_VALIDATION_ALERT';
diff --git a/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts
similarity index 96%
rename from packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts
index 3645c4f3d8..e8bd108197 100644
--- a/packages/sheets-data-validation/src/controllers/dv-auto-fill.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { IAutoFillLocation, ISheetAutoFillHook } from '@univerjs/sheets-ui';
import { DataValidationType, Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, queryObjectMatrix, Range, Rectangle } from '@univerjs/core';
+import { DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';
-import type { IAutoFillLocation, ISheetAutoFillHook } from '@univerjs/sheets-ui';
-import { getDataValidationDiffMutations } from '../commands/commands/data-validation.command';
-import { DATA_VALIDATION_PLUGIN_NAME } from '../common/const';
-import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
+
+// TODO: adjust imports
@OnLifecycle(LifecycleStages.Ready, DataValidationAutoFillController)
export class DataValidationAutoFillController extends Disposable {
diff --git a/packages/sheets-data-validation/src/controllers/dv-copy-paste.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts
similarity index 97%
rename from packages/sheets-data-validation/src/controllers/dv-copy-paste.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts
index cc5291ab6e..cedf33ca2b 100644
--- a/packages/sheets-data-validation/src/controllers/dv-copy-paste.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-import { Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, queryObjectMatrix, Rectangle } from '@univerjs/core';
-import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';
import type { IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';
import type { IDiscreteRange } from '@univerjs/sheets-ui';
-import { getDataValidationDiffMutations } from '../commands/commands/data-validation.command';
-import { DATA_VALIDATION_PLUGIN_NAME } from '../common/const';
-import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
+import { Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, queryObjectMatrix, Rectangle } from '@univerjs/core';
+import { DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
+import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';
@OnLifecycle(LifecycleStages.Ready, DataValidationCopyPasteController)
export class DataValidationCopyPasteController extends Disposable {
diff --git a/packages/sheets-data-validation/src/controllers/dv-permission.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts
similarity index 96%
rename from packages/sheets-data-validation/src/controllers/dv-permission.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts
index 5f58bfa088..20d33a3022 100644
--- a/packages/sheets-data-validation/src/controllers/dv-permission.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { ICommandInfo } from '@univerjs/core';
+import type { IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';
import { Disposable, ICommandService, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';
+import { AddSheetDataValidationCommand, UpdateSheetDataValidationRangeCommand } from '@univerjs/sheets-data-validation';
import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
-import type { ICommandInfo } from '@univerjs/core';
-import { AddSheetDataValidationCommand, UpdateSheetDataValidationRangeCommand } from '../commands/commands/data-validation.command';
-import type { IUpdateSheetDataValidationRangeCommandParams } from '../commands/commands/data-validation.command';
@OnLifecycle(LifecycleStages.Ready, DataValidationPermissionController)
export class DataValidationPermissionController extends Disposable {
diff --git a/packages/sheets-data-validation/src/controllers/dv-reject-input.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
similarity index 97%
rename from packages/sheets-data-validation/src/controllers/dv-reject-input.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
index 048b78b7cc..93f97d7051 100644
--- a/packages/sheets-data-validation/src/controllers/dv-reject-input.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts
@@ -17,11 +17,10 @@
import { DataValidationErrorStyle, Disposable, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';
import { DataValidatorRegistryService } from '@univerjs/data-validation';
import { Button } from '@univerjs/design';
+import { getCellValueOrigin, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
import { IEditorBridgeService } from '@univerjs/sheets-ui';
import { IDialogService } from '@univerjs/ui';
import React from 'react';
-import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
-import { getCellValueOrigin } from '../utils/get-cell-data-origin';
@OnLifecycle(LifecycleStages.Ready, DataValidationRejectInputController)
export class DataValidationRejectInputController extends Disposable {
diff --git a/packages/sheets-data-validation/src/controllers/dv-render.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts
similarity index 98%
rename from packages/sheets-data-validation/src/controllers/dv-render.controller.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts
index 25c9f3d95c..2c988d3a03 100644
--- a/packages/sheets-data-validation/src/controllers/dv-render.controller.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts
@@ -19,12 +19,11 @@ import { DataValidationStatus, DataValidationType, ICommandService, Inject, Inte
import { DataValidatorRegistryService } from '@univerjs/data-validation';
import { IRenderManagerService } from '@univerjs/engine-render';
import { InterceptCellContentPriority, INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';
+import { getCellValueOrigin, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
import { AutoHeightController, IEditorBridgeService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { IMenuManagerService } from '@univerjs/ui';
import { bufferTime, filter } from 'rxjs';
-import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
import { DataValidationDropdownManagerService } from '../services/dropdown-manager.service';
-import { getCellValueOrigin } from '../utils/get-cell-data-origin';
import { menuSchema } from './menu.schema';
const INVALID_MARK = {
@@ -264,7 +263,6 @@ export class SheetsDataValidationMobileRenderController extends RxDisposable {
constructor(
@ICommandService private readonly _commandService: ICommandService,
@IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
@Inject(AutoHeightController) private readonly _autoHeightController: AutoHeightController,
@Inject(DataValidatorRegistryService) private readonly _dataValidatorRegistryService: DataValidatorRegistryService,
@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,
diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts
new file mode 100644
index 0000000000..f6960a4756
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Ctor } from '@univerjs/core';
+import type { BaseSheetDataValidatorView } from '../views/validator-views/sheet-validator-view';
+import { Inject, Injector, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';
+import { DataValidatorRegistryService } from '@univerjs/data-validation';
+import { DataValidationSingle } from '@univerjs/icons';
+import { ComponentManager } from '@univerjs/ui';
+import { DATA_VALIDATION_PANEL } from '../commands/operations/data-validation.operation';
+import { DataValidationPanel, DATE_DROPDOWN_KEY, DateDropdown, LIST_DROPDOWN_KEY, ListDropDown } from '../views/components';
+import { CellDropdown, DROP_DOWN_KEY } from '../views/components/drop-down';
+import { FORMULA_INPUTS } from '../views/components/formula-input';
+import { ListRenderModeInput } from '../views/components/render-mode';
+import { DateShowTimeOption } from '../views/components/show-time';
+import { CheckboxValidatorView } from '../views/validator-views/checkbox-validator-view';
+import { CustomFormulaValidatorView } from '../views/validator-views/custom-validator-view';
+import { DateValidatorView } from '../views/validator-views/date-validator-view';
+import { DecimalValidatorView } from '../views/validator-views/decimal-validator-view';
+import { ListMultipleValidatorView } from '../views/validator-views/list-multiple-view';
+import { ListValidatorView } from '../views/validator-views/list-validator-view';
+import { TextLengthValidatorView } from '../views/validator-views/text-length-validator.view';
+import { WholeValidatorView } from '../views/validator-views/whole-validator-view';
+import { DataValidationIcon } from './dv.menu';
+
+@OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationUIController)
+export class SheetsDataValidationUIController extends RxDisposable {
+ constructor(
+ @Inject(Injector) private readonly _injector: Injector,
+ @Inject(ComponentManager) private readonly _componentManger: ComponentManager,
+ @Inject(DataValidatorRegistryService) private readonly _dataValidatorRegistryService: DataValidatorRegistryService
+ ) {
+ super();
+
+ this._initComponents();
+ this._registerValidatorViews();
+ }
+
+ private _initComponents() {
+ ([
+ [DataValidationIcon, DataValidationSingle],
+ [DATA_VALIDATION_PANEL, DataValidationPanel],
+ [DROP_DOWN_KEY, CellDropdown],
+ [LIST_DROPDOWN_KEY, ListDropDown],
+ [DATE_DROPDOWN_KEY, DateDropdown],
+ [ListRenderModeInput.componentKey, ListRenderModeInput],
+ [DateShowTimeOption.componentKey, DateShowTimeOption],
+ ...FORMULA_INPUTS,
+ ] as const).forEach(([key, component]) => {
+ this.disposeWithMe(this._componentManger.register(
+ key,
+ component
+ ));
+ });
+ }
+
+ private _registerValidatorViews(): void {
+ ([
+ DecimalValidatorView,
+ WholeValidatorView,
+ TextLengthValidatorView,
+ DateValidatorView,
+ CheckboxValidatorView,
+ ListValidatorView,
+ ListMultipleValidatorView,
+ CustomFormulaValidatorView,
+ ] as Ctor<BaseSheetDataValidatorView>[]).forEach((v) => {
+ const view = this._injector.createInstance(v);
+ const validator = this._dataValidatorRegistryService.getValidatorItem(view.id);
+ if (validator) {
+ validator.formulaInput = view.formulaInput;
+ validator.canvasRender = view.canvasRender;
+ validator.dropdown = view.dropdown;
+ validator.optionsInput = view.optionsInput;
+ }
+ });
+ }
+}
diff --git a/packages/sheets-data-validation/src/controllers/dv.menu.ts b/packages/sheets-data-validation-ui/src/controllers/dv.menu.ts
similarity index 98%
rename from packages/sheets-data-validation/src/controllers/dv.menu.ts
rename to packages/sheets-data-validation-ui/src/controllers/dv.menu.ts
index 7e1e668d01..194fc47ba6 100644
--- a/packages/sheets-data-validation/src/controllers/dv.menu.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/dv.menu.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
import type { IAccessor } from '@univerjs/core';
import { UniverInstanceType } from '@univerjs/core';
-import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';
-import { AddSheetDataValidationAndOpenCommand } from '../commands/commands/data-validation.command';
+import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
+import { getMenuHiddenObservable, type IMenuItem, MenuItemType } from '@univerjs/ui';
+import { AddSheetDataValidationAndOpenCommand } from '../commands/commands/data-validation-ui.command';
import { OpenValidationPanelOperation } from '../commands/operations/data-validation.operation';
export const DataValidationIcon = 'data-validation-single';
diff --git a/packages/sheets-data-validation/src/controllers/menu.schema.ts b/packages/sheets-data-validation-ui/src/controllers/menu.schema.ts
similarity index 97%
rename from packages/sheets-data-validation/src/controllers/menu.schema.ts
rename to packages/sheets-data-validation-ui/src/controllers/menu.schema.ts
index cd49f0c96c..e122adf928 100644
--- a/packages/sheets-data-validation/src/controllers/menu.schema.ts
+++ b/packages/sheets-data-validation-ui/src/controllers/menu.schema.ts
@@ -16,8 +16,8 @@
import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
+import { AddSheetDataValidationAndOpenCommand } from '../commands/commands/data-validation-ui.command';
import { OpenValidationPanelOperation } from '../commands/operations/data-validation.operation';
-import { AddSheetDataValidationAndOpenCommand } from '../commands/commands/data-validation.command';
import {
addDataValidationMenuFactory,
DATA_VALIDATION_MENU_ID,
diff --git a/packages/sheets-data-validation-ui/src/index.ts b/packages/sheets-data-validation-ui/src/index.ts
new file mode 100644
index 0000000000..43c875ed23
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/index.ts
@@ -0,0 +1,18 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { DATE_DROPDOWN_KEY, LIST_DROPDOWN_KEY } from './views/components';
+export { UniverSheetsDataValidationUIPlugin } from './plugin';
diff --git a/packages/sheets-data-validation/src/locale/en-US.ts b/packages/sheets-data-validation-ui/src/locale/en-US.ts
similarity index 100%
rename from packages/sheets-data-validation/src/locale/en-US.ts
rename to packages/sheets-data-validation-ui/src/locale/en-US.ts
diff --git a/packages/sheets-data-validation/src/locale/ru-RU.ts b/packages/sheets-data-validation-ui/src/locale/ru-RU.ts
similarity index 100%
rename from packages/sheets-data-validation/src/locale/ru-RU.ts
rename to packages/sheets-data-validation-ui/src/locale/ru-RU.ts
diff --git a/packages/sheets-data-validation/src/locale/vi-VN.ts b/packages/sheets-data-validation-ui/src/locale/vi-VN.ts
similarity index 100%
rename from packages/sheets-data-validation/src/locale/vi-VN.ts
rename to packages/sheets-data-validation-ui/src/locale/vi-VN.ts
diff --git a/packages/sheets-data-validation/src/locale/zh-CN.ts b/packages/sheets-data-validation-ui/src/locale/zh-CN.ts
similarity index 100%
rename from packages/sheets-data-validation/src/locale/zh-CN.ts
rename to packages/sheets-data-validation-ui/src/locale/zh-CN.ts
diff --git a/packages/sheets-data-validation/src/locale/zh-TW.ts b/packages/sheets-data-validation-ui/src/locale/zh-TW.ts
similarity index 100%
rename from packages/sheets-data-validation/src/locale/zh-TW.ts
rename to packages/sheets-data-validation-ui/src/locale/zh-TW.ts
diff --git a/packages/sheets-data-validation-ui/src/plugin.ts b/packages/sheets-data-validation-ui/src/plugin.ts
new file mode 100644
index 0000000000..3cbe665044
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/plugin.ts
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Dependency } from '@univerjs/core';
+import type { IUniverSheetsDataValidationConfig } from './controllers/config.schema';
+import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
+import { AddSheetDataValidationAndOpenCommand } from './commands/commands/data-validation-ui.command';
+import {
+ CloseValidationPanelOperation,
+ HideDataValidationDropdown,
+ OpenValidationPanelOperation,
+ ShowDataValidationDropdown,
+ ToggleValidationPanelOperation,
+} from './commands/operations/data-validation.operation';
+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
+import { DataValidationAlertController } from './controllers/dv-alert.controller';
+import { DataValidationAutoFillController } from './controllers/dv-auto-fill.controller';
+import { DataValidationCopyPasteController } from './controllers/dv-copy-paste.controller';
+import { DataValidationPermissionController } from './controllers/dv-permission.controller';
+import { DataValidationRejectInputController } from './controllers/dv-reject-input.controller';
+import { SheetsDataValidationRenderController } from './controllers/dv-render.controller';
+import { SheetsDataValidationUIController } from './controllers/dv-ui.controller';
+import { DataValidationPanelService } from './services/data-validation-panel.service';
+import { DataValidationDropdownManagerService } from './services/dropdown-manager.service';
+
+const PLUGIN_NAME = 'SHEET_DATA_VALIDATION_UI_PLUGIN';
+
+export class UniverSheetsDataValidationUIPlugin extends Plugin {
+ static override pluginName: string = PLUGIN_NAME;
+ static override type = UniverInstanceType.UNIVER_SHEET;
+
+ constructor(
+ private readonly _config: Partial<IUniverSheetsDataValidationConfig> = defaultPluginConfig,
+ @Inject(Injector) protected readonly _injector: Injector,
+ @ICommandService private readonly _commandService: ICommandService,
+ @IConfigService private readonly _configService: IConfigService
+ ) {
+ super();
+
+ // Manage the plugin configuration..
+ const { menu, ...rest } = this._config;
+ if (menu) {
+ this._configService.setConfig('menu', menu, { merge: true });
+ }
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
+ }
+
+ override onStarting(): void {
+ ([
+ [DataValidationPanelService],
+ [DataValidationDropdownManagerService],
+ [DataValidationAlertController],
+ [DataValidationAutoFillController],
+ [SheetsDataValidationRenderController],
+ [DataValidationPermissionController],
+ [DataValidationCopyPasteController],
+ [DataValidationRejectInputController],
+ [SheetsDataValidationUIController],
+ ] as Dependency[]).forEach((dep) => {
+ this._injector.add(dep);
+ });
+
+ [
+ AddSheetDataValidationAndOpenCommand,
+ ShowDataValidationDropdown,
+ HideDataValidationDropdown,
+ CloseValidationPanelOperation,
+ OpenValidationPanelOperation,
+ ToggleValidationPanelOperation,
+ ].forEach((command) => {
+ this._commandService.registerCommand(command);
+ });
+ }
+}
diff --git a/packages/sheets-data-validation/src/services/data-validation-panel.service.ts b/packages/sheets-data-validation-ui/src/services/data-validation-panel.service.ts
similarity index 100%
rename from packages/sheets-data-validation/src/services/data-validation-panel.service.ts
rename to packages/sheets-data-validation-ui/src/services/data-validation-panel.service.ts
diff --git a/packages/sheets-data-validation/src/services/dropdown-manager.service.ts b/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts
similarity index 98%
rename from packages/sheets-data-validation/src/services/dropdown-manager.service.ts
rename to packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts
index 91f2eb8ef9..dcb67d6537 100644
--- a/packages/sheets-data-validation/src/services/dropdown-manager.service.ts
+++ b/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts
@@ -14,16 +14,16 @@
* limitations under the License.
*/
+import type { IDisposable, Nullable, Workbook } from '@univerjs/core';
import { Disposable, DisposableCollection, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DataValidatorRegistryService } from '@univerjs/data-validation';
import { IRenderManagerService } from '@univerjs/engine-render';
import { type ISheetLocation, SheetsSelectionsService } from '@univerjs/sheets';
+import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
import { Subject } from 'rxjs';
-import type { IDisposable, Nullable, Workbook } from '@univerjs/core';
-import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
-import { DROP_DOWN_KEY } from '../views/drop-down';
+import { DROP_DOWN_KEY } from '../views/components/drop-down';
export interface IDropdownParam {
location: ISheetLocation;
diff --git a/packages/sheets-data-validation/src/views/date-dropdown/index.module.less b/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/date-dropdown/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.module.less
diff --git a/packages/sheets-data-validation/src/views/date-dropdown/index.tsx b/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
similarity index 94%
rename from packages/sheets-data-validation/src/views/date-dropdown/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
index f2d3862989..52d908b34f 100644
--- a/packages/sheets-data-validation/src/views/date-dropdown/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/date-dropdown/index.tsx
@@ -14,19 +14,19 @@
* limitations under the License.
*/
+import type { CellValue, Nullable } from '@univerjs/core';
+import type { DateValidator } from '@univerjs/sheets-data-validation';
+import type { IDropdownComponentProps } from '../../../services/dropdown-manager.service';
import { CellValueType, DataValidationErrorStyle, ICommandService, LocaleService, numfmt, useDependency } from '@univerjs/core';
import { Button, DatePanel } from '@univerjs/design';
import { SetRangeValuesCommand } from '@univerjs/sheets';
+import { getCellValueOrigin } from '@univerjs/sheets-data-validation';
import { getPatternType } from '@univerjs/sheets-numfmt';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import React, { useState } from 'react';
-import type { CellValue, Nullable } from '@univerjs/core';
-import { DataValidationRejectInputController } from '../../controllers/dv-reject-input.controller';
-import { getCellValueOrigin } from '../../utils/get-cell-data-origin';
+import { DataValidationRejectInputController } from '../../../controllers/dv-reject-input.controller';
import styles from './index.module.less';
-import type { IDropdownComponentProps } from '../../services/dropdown-manager.service';
-import type { DateValidator } from '../../validators';
dayjs.extend(utc);
diff --git a/packages/sheets-data-validation/src/views/detail/index.module.less b/packages/sheets-data-validation-ui/src/views/components/detail/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/detail/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/detail/index.module.less
diff --git a/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
new file mode 100644
index 0000000000..7d7adf263f
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/components/detail/index.tsx
@@ -0,0 +1,301 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { DataValidationOperator, DataValidationType, IDataValidationRuleBase, IDataValidationRuleOptions, IExecutionOptions, ISheetDataValidationRule, IUnitRange } from '@univerjs/core';
+import type { IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';
+import { createInternalEditorID, debounce, ICommandService, isUnitRangesEqual, isValidRange, LocaleService, RedoCommand, shallowEqual, UndoCommand, useDependency } from '@univerjs/core';
+import { DataValidationModel, DataValidatorRegistryScope, DataValidatorRegistryService, getRuleOptions, getRuleSetting, TWO_FORMULA_OPERATOR_COUNT } from '@univerjs/data-validation';
+import { Button, FormLayout, Select } from '@univerjs/design';
+import { RangeSelector } from '@univerjs/docs-ui';
+import { serializeRange } from '@univerjs/engine-formula';
+import { RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from '@univerjs/sheets-data-validation';
+import { ComponentManager, useEvent, useObservable } from '@univerjs/ui';
+import React, { useEffect, useMemo, useState } from 'react';
+import { DataValidationPanelService } from '../../../services/data-validation-panel.service';
+import { DataValidationOptions } from '../options';
+import styles from './index.module.less';
+
+// debounce execute commands, for better redo-undo experience
+const debounceExecuteFactory = (commandService: ICommandService) => debounce(
+ async (id: string, params?: any, options?: IExecutionOptions | undefined,
+ callback?: (success: boolean) => void
+ ) => {
+ const res = await commandService.executeCommand(id, params, options);
+ callback?.(res);
+ },
+ 1000
+);
+
+export function DataValidationDetail() {
+ const [key, setKey] = useState(0);
+ const dataValidationPanelService = useDependency(DataValidationPanelService);
+ const activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule)!;
+ const { unitId, subUnitId, rule } = activeRuleInfo || {};
+ const ruleId = rule.uid;
+ const validatorService = useDependency(DataValidatorRegistryService);
+ const componentManager = useDependency(ComponentManager);
+ const commandService = useDependency(ICommandService);
+ const dataValidationModel = useDependency(DataValidationModel);
+ const localeService = useDependency(LocaleService);
+ const [localRule, setLocalRule] = useState<ISheetDataValidationRule>(rule);
+ const validator = validatorService.getValidatorItem(localRule.type);
+ const [showError, setShowError] = useState(false);
+ const validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET);
+ const [localRanges, setLocalRanges] = useState<IUnitRange[]>(() => localRule.ranges.map((i) => ({ unitId: '', sheetId: '', range: i })));
+ const debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]);
+
+ useEffect(() => {
+ commandService.onCommandExecuted((commandInfo) => {
+ if (commandInfo.id === UndoCommand.id || commandInfo.id === RedoCommand.id) {
+ setTimeout(() => {
+ const activeRule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId) as ISheetDataValidationRule;
+ setKey((k) => k + 1);
+ if (activeRule) {
+ setLocalRule(activeRule);
+ setLocalRanges(activeRule.ranges.map((i) => ({ unitId: '', sheetId: '', range: i })));
+ }
+ }, 20);
+ }
+ });
+ }, [commandService, dataValidationModel, ruleId, subUnitId, unitId]);
+
+ if (!validator) {
+ return null;
+ }
+
+ const operators = validator.operators;
+ const operatorNames = validator.operatorNames;
+ const isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT.includes(localRule.operator) : false;
+
+ const handleOk = () => {
+ if (!localRule.ranges.length) {
+ return;
+ }
+ if (validator.validatorFormula(localRule, unitId, subUnitId).success) {
+ dataValidationPanelService.setActiveRule(null);
+ } else {
+ setShowError(true);
+ }
+ };
+
+ const handleUpdateRuleRanges = useEvent((unitRanges: IUnitRange[]) => {
+ if (isUnitRangesEqual(unitRanges, localRanges)) {
+ return;
+ }
+ setLocalRanges(unitRanges);
+ const ranges = unitRanges.filter((i) => (!i.unitId || i.unitId === unitId) && (!i.sheetId || i.sheetId === subUnitId)).map((i) => i.range);
+ setLocalRule({
+ ...localRule,
+ ranges,
+ });
+
+ if (ranges.length === 0) {
+ return;
+ }
+
+ const params: IUpdateSheetDataValidationRangeCommandParams = {
+ unitId,
+ subUnitId,
+ ruleId,
+ ranges,
+ };
+
+ debounceExecute(UpdateSheetDataValidationRangeCommand.id, params);
+ });
+
+ const handleUpdateRuleSetting = (setting: IDataValidationRuleBase) => {
+ if (shallowEqual(setting, getRuleSetting(localRule))) {
+ return;
+ }
+
+ setLocalRule({
+ ...localRule,
+ ...setting,
+ });
+ const params = {
+ unitId,
+ subUnitId,
+ ruleId,
+ setting,
+ };
+
+ debounceExecute(
+ UpdateSheetDataValidationSettingCommand.id,
+ params,
+ undefined
+ );
+ };
+
+ const handleDelete = async () => {
+ await commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
+ ruleId,
+ unitId,
+ subUnitId,
+ });
+ dataValidationPanelService.setActiveRule(null);
+ };
+
+ const baseRule = {
+ type: localRule.type,
+ operator: localRule.operator,
+ formula1: localRule.formula1,
+ formula2: localRule.formula2,
+ allowBlank: localRule.allowBlank,
+ };
+
+ const handleChangeType = (newType: string) => {
+ const validator = validatorService.getValidatorItem(newType);
+ if (!validator) {
+ return;
+ }
+
+ const operators = validator.operators;
+ const rule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
+ const newRule = (newType === rule?.type || (newType.includes('list') && rule?.type.includes('list')))
+ ? {
+ ...rule,
+ type: newType as DataValidationType,
+ }
+ : {
+ ...localRule,
+ type: newType as DataValidationType,
+ operator: operators[0],
+ formula1: undefined,
+ formula2: undefined,
+ };
+ setLocalRule(newRule);
+
+ commandService.executeCommand(UpdateSheetDataValidationSettingCommand.id, {
+ unitId,
+ subUnitId,
+ ruleId: localRule.uid,
+ setting: getRuleSetting(newRule),
+ });
+ };
+
+ const FormulaInput = componentManager.get(validator.formulaInput!);
+ const rangeStr = useMemo(() => localRanges.map((i) => serializeRange(i.range)).join(','), []);
+
+ const options: IDataValidationRuleOptions = getRuleOptions(localRule);
+
+ const handleUpdateRuleOptions = (newOptions: IDataValidationRuleOptions) => {
+ if (shallowEqual(newOptions, getRuleOptions(localRule))) {
+ return;
+ }
+ setLocalRule({
+ ...localRule,
+ ...newOptions,
+ });
+
+ debounceExecute(
+ UpdateSheetDataValidationOptionsCommand.id,
+ {
+ unitId,
+ subUnitId,
+ ruleId,
+ options: newOptions,
+ }
+ );
+ };
+ return (
+ <div className={styles.dataValidationDetail}>
+ <FormLayout
+ label={localeService.t('dataValidation.panel.range')}
+ error={!localRule.ranges.length ? localeService.t('dataValidation.panel.rangeError') : ''}
+ >
+ <RangeSelector
+ key={key}
+ className={styles.dataValidationDetailFormItem}
+ value={rangeStr}
+ id={createInternalEditorID('data-validation-detail')}
+ openForSheetUnitId={unitId}
+ openForSheetSubUnitId={subUnitId}
+ onChange={(newRange) => {
+ if (newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow)) {
+ return;
+ }
+
+ handleUpdateRuleRanges(newRange);
+ }}
+
+ />
+ </FormLayout>
+ <FormLayout label={localeService.t('dataValidation.panel.type')}>
+ <Select
+ options={validators?.map((validator) => ({
+ label: localeService.t(validator.title),
+ value: validator.id,
+ }))}
+ value={localRule.type}
+ onChange={handleChangeType}
+ className={styles.dataValidationDetailFormItem}
+ />
+ </FormLayout>
+ {operators?.length
+ ? (
+ <FormLayout label={localeService.t('dataValidation.panel.operator')}>
+ <Select
+ options={operators.map((op, i) => ({
+ value: `${op}`,
+ label: operatorNames[i],
+ }))}
+ value={`${localRule.operator}`}
+ onChange={(operator) => {
+ handleUpdateRuleSetting({
+ ...baseRule,
+ operator: operator as DataValidationOperator,
+ });
+ }}
+ className={styles.dataValidationDetailFormItem}
+ />
+ </FormLayout>
+ )
+ : null}
+ {FormulaInput
+ ? (
+ <FormulaInput
+ key={key + localRule.type}
+ isTwoFormula={isTwoFormula}
+ value={{
+ formula1: localRule.formula1,
+ formula2: localRule.formula2,
+ }}
+ onChange={(value: any) => {
+ handleUpdateRuleSetting({
+ ...baseRule,
+ ...value,
+ });
+ }}
+ showError={showError}
+ validResult={validator.validatorFormula(localRule, unitId, subUnitId)}
+ unitId={unitId}
+ subUnitId={subUnitId}
+ ruleId={ruleId}
+ />
+ )
+ : null}
+ <DataValidationOptions value={options} onChange={handleUpdateRuleOptions} extraComponent={validator.optionsInput} />
+ <div className={styles.dataValidationDetailButtons}>
+ <Button className={styles.dataValidationDetailButton} onClick={handleDelete}>
+ {localeService.t('dataValidation.panel.removeRule')}
+ </Button>
+ <Button className={styles.dataValidationDetailButton} type="primary" onClick={handleOk}>
+ {localeService.t('dataValidation.panel.done')}
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/sheets-data-validation/src/views/drop-down/CellDropdown.tsx b/packages/sheets-data-validation-ui/src/views/components/drop-down/CellDropdown.tsx
similarity index 94%
rename from packages/sheets-data-validation/src/views/drop-down/CellDropdown.tsx
rename to packages/sheets-data-validation-ui/src/views/components/drop-down/CellDropdown.tsx
index 89e28cb0e6..099b9ae486 100644
--- a/packages/sheets-data-validation/src/views/drop-down/CellDropdown.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/drop-down/CellDropdown.tsx
@@ -17,7 +17,7 @@
import { useDependency } from '@univerjs/core';
import { ComponentManager, useObservable } from '@univerjs/ui';
import React from 'react';
-import { DataValidationDropdownManagerService } from '../../services/dropdown-manager.service';
+import { DataValidationDropdownManagerService } from '../../../services/dropdown-manager.service';
export function CellDropdown() {
const dropdownManagerService = useDependency(DataValidationDropdownManagerService);
diff --git a/packages/sheets-data-validation/src/views/drop-down/index.ts b/packages/sheets-data-validation-ui/src/views/components/drop-down/index.ts
similarity index 100%
rename from packages/sheets-data-validation/src/views/drop-down/index.ts
rename to packages/sheets-data-validation-ui/src/views/components/drop-down/index.ts
diff --git a/packages/sheets-data-validation/src/views/formula-input/base-formula-input.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/base-formula-input.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/formula-input/base-formula-input.tsx
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/base-formula-input.tsx
index 1fe6ea65cb..84cdcd69cd 100644
--- a/packages/sheets-data-validation/src/views/formula-input/base-formula-input.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/base-formula-input.tsx
@@ -15,9 +15,9 @@
*/
import type { IFormulaInputProps } from '@univerjs/data-validation';
+import { LocaleService, useDependency } from '@univerjs/core';
import { FormLayout, Input } from '@univerjs/design';
import React from 'react';
-import { LocaleService, useDependency } from '@univerjs/core';
import styles from './index.module.less';
export const BaseFormulaInput = (props: IFormulaInputProps) => {
diff --git a/packages/sheets-data-validation/src/views/formula-input/checkbox-formula-input.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/checkbox-formula-input.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/formula-input/checkbox-formula-input.tsx
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/checkbox-formula-input.tsx
index 8c0c37d4be..a0820000e0 100644
--- a/packages/sheets-data-validation/src/views/formula-input/checkbox-formula-input.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/checkbox-formula-input.tsx
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { LocaleService, useDependency } from '@univerjs/core';
import type { IFormulaInputProps } from '@univerjs/data-validation';
+import { LocaleService, useDependency } from '@univerjs/core';
import { Checkbox, FormLayout, Input } from '@univerjs/design';
import React, { useState } from 'react';
import styles from './index.module.less';
diff --git a/packages/sheets-data-validation/src/views/formula-input/custom-formula-input.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/custom-formula-input.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/formula-input/custom-formula-input.tsx
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/custom-formula-input.tsx
index 570e8c921e..0a64295a9f 100644
--- a/packages/sheets-data-validation/src/views/formula-input/custom-formula-input.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/custom-formula-input.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+import type { IFormulaInputProps } from '@univerjs/data-validation';
import { createInternalEditorID } from '@univerjs/core';
-import { FormLayout } from '@univerjs/design';
+import { FormLayout } from '@univerjs/design';
import { TextEditor } from '@univerjs/docs-ui';
import React from 'react';
-import type { IFormulaInputProps } from '@univerjs/data-validation';
export function CustomFormulaInput(props: IFormulaInputProps) {
const { unitId, subUnitId, value, onChange, showError, validResult } = props;
diff --git a/packages/sheets-data-validation/src/views/formula-input/formula-input.ts b/packages/sheets-data-validation-ui/src/views/components/formula-input/formula-input.ts
similarity index 100%
rename from packages/sheets-data-validation/src/views/formula-input/formula-input.ts
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/formula-input.ts
diff --git a/packages/sheets-data-validation/src/views/formula-input/index.module.less b/packages/sheets-data-validation-ui/src/views/components/formula-input/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/formula-input/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/index.module.less
diff --git a/packages/sheets-data-validation/src/views/formula-input/index.ts b/packages/sheets-data-validation-ui/src/views/components/formula-input/index.ts
similarity index 77%
rename from packages/sheets-data-validation/src/views/formula-input/index.ts
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/index.ts
index dcd63e964e..a30f1cdd2c 100644
--- a/packages/sheets-data-validation/src/views/formula-input/index.ts
+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/index.ts
@@ -15,30 +15,31 @@
*/
import type { FormulaInputType } from '@univerjs/data-validation';
-import { CustomFormulaInput } from './custom-formula-input';
import { BaseFormulaInput } from './base-formula-input';
-import { ListFormulaInput } from './list-formula-input';
import { CheckboxFormulaInput } from './checkbox-formula-input';
+import { CustomFormulaInput } from './custom-formula-input';
+import { ListFormulaInput } from './list-formula-input';
export const CUSTOM_FORMULA_INPUT_NAME = 'data-validation.custom-formula-input';
export const BASE_FORMULA_INPUT_NAME = 'data-validation.formula-input';
export const LIST_FORMULA_INPUT_NAME = 'data-validation.list-formula-input';
export const CHECKBOX_FORMULA_INPUT_NAME = 'data-validation.checkbox-formula-input';
-export const FORMULA_INPUTS: [string, FormulaInputType][] = [[
- CUSTOM_FORMULA_INPUT_NAME,
- CustomFormulaInput,
-],
-[
- BASE_FORMULA_INPUT_NAME,
- BaseFormulaInput,
-],
-[
- LIST_FORMULA_INPUT_NAME,
- ListFormulaInput,
-],
-[
- CHECKBOX_FORMULA_INPUT_NAME,
- CheckboxFormulaInput,
-],
+export const FORMULA_INPUTS: [string, FormulaInputType][] = [
+ [
+ CUSTOM_FORMULA_INPUT_NAME,
+ CustomFormulaInput,
+ ],
+ [
+ BASE_FORMULA_INPUT_NAME,
+ BaseFormulaInput,
+ ],
+ [
+ LIST_FORMULA_INPUT_NAME,
+ ListFormulaInput,
+ ],
+ [
+ CHECKBOX_FORMULA_INPUT_NAME,
+ CheckboxFormulaInput,
+ ],
];
diff --git a/packages/sheets-data-validation/src/views/formula-input/list-formula-input.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/list-formula-input.tsx
similarity index 98%
rename from packages/sheets-data-validation/src/views/formula-input/list-formula-input.tsx
rename to packages/sheets-data-validation-ui/src/views/components/formula-input/list-formula-input.tsx
index 6e34bb3757..ca0cd7f356 100644
--- a/packages/sheets-data-validation/src/views/formula-input/list-formula-input.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/list-formula-input.tsx
@@ -14,20 +14,19 @@
* limitations under the License.
*/
+import type { ListValidator } from '@univerjs/sheets-data-validation';
import { createInternalEditorID, DataValidationType, isFormulaString, LocaleService, Tools, useDependency } from '@univerjs/core';
import { DataValidationModel, DataValidatorRegistryService, type IFormulaInputProps } from '@univerjs/data-validation';
import { DraggableList, FormLayout, Input, Radio, RadioGroup, Select } from '@univerjs/design';
import { TextEditor } from '@univerjs/docs-ui';
import { DeleteSingle, IncreaseSingle, SequenceSingle } from '@univerjs/icons';
+import { DataValidationFormulaController, deserializeListOptions, serializeListOptions } from '@univerjs/sheets-data-validation';
import { useEvent, useObservable } from '@univerjs/ui';
import cs from 'clsx';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { debounceTime } from 'rxjs';
-import { DROP_DOWN_DEFAULT_COLOR } from '../../common/const';
-import { DataValidationFormulaController } from '../../controllers/dv-formula.controller';
-import { deserializeListOptions, serializeListOptions } from '../../validators/util';
+import { DROP_DOWN_DEFAULT_COLOR } from '../../../const';
import styles from './index.module.less';
-import type { ListValidator } from '../../validators';
const DEFAULT_COLOR_PRESET = [
'#FFFFFF',
diff --git a/packages/sheets-data-validation/src/views/index.ts b/packages/sheets-data-validation-ui/src/views/components/index.ts
similarity index 100%
rename from packages/sheets-data-validation/src/views/index.ts
rename to packages/sheets-data-validation-ui/src/views/components/index.ts
diff --git a/packages/sheets-data-validation/src/views/item/index.module.less b/packages/sheets-data-validation-ui/src/views/components/item/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/item/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/item/index.module.less
diff --git a/packages/sheets-data-validation/src/views/item/index.tsx b/packages/sheets-data-validation-ui/src/views/components/item/index.tsx
similarity index 97%
rename from packages/sheets-data-validation/src/views/item/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/item/index.tsx
index 5ac83ec6c8..6f44746552 100644
--- a/packages/sheets-data-validation/src/views/item/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/item/index.tsx
@@ -19,9 +19,9 @@ import { useDependency } from '@univerjs/core';
import { DataValidatorRegistryService } from '@univerjs/data-validation';
import { serializeRange } from '@univerjs/engine-formula';
import { DeleteSingle } from '@univerjs/icons';
+import { RemoveSheetDataValidationCommand } from '@univerjs/sheets-data-validation';
import { IMarkSelectionService } from '@univerjs/sheets-ui';
import React, { useEffect, useRef, useState } from 'react';
-import { RemoveSheetDataValidationCommand } from '../../commands/commands/data-validation.command';
import styles from './index.module.less';
export interface IDataValidationDetailProps {
diff --git a/packages/sheets-data-validation/src/views/list-dropdown/index.module.less b/packages/sheets-data-validation-ui/src/views/components/list-dropdown/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/list-dropdown/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/list-dropdown/index.module.less
diff --git a/packages/sheets-data-validation/src/views/list-dropdown/index.tsx b/packages/sheets-data-validation-ui/src/views/components/list-dropdown/index.tsx
similarity index 95%
rename from packages/sheets-data-validation/src/views/list-dropdown/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/list-dropdown/index.tsx
index 4c34a5dfa0..d2f2e523bf 100644
--- a/packages/sheets-data-validation/src/views/list-dropdown/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/list-dropdown/index.tsx
@@ -14,6 +14,12 @@
* limitations under the License.
*/
+import type { DocumentDataModel } from '@univerjs/core';
+import type { IRichTextEditingMutationParams } from '@univerjs/docs';
+import type { ISetRangeValuesCommandParams, ISheetLocation } from '@univerjs/sheets';
+import type { ListMultipleValidator } from '@univerjs/sheets-data-validation';
+import type { IUniverSheetsDataValidationConfig } from '../../../controllers/config.schema';
+import type { IDropdownComponentProps } from '../../../services/dropdown-manager.service';
import { BuildTextUtils, DataValidationRenderMode, DataValidationType, ICommandService, IConfigService, IUniverInstanceService, LocaleService, UniverInstanceType, useDependency } from '@univerjs/core';
import { DataValidationModel } from '@univerjs/data-validation';
import { RectPopup, Scrollbar } from '@univerjs/design';
@@ -21,21 +27,15 @@ import { RichTextEditingMutation } from '@univerjs/docs';
import { DeviceInputEventType } from '@univerjs/engine-render';
import { CheckMarkSingle } from '@univerjs/icons';
import { RangeProtectionPermissionEditPoint, SetRangeValuesCommand, WorkbookEditablePermission, WorksheetEditPermission } from '@univerjs/sheets';
+import { deserializeListOptions, getDataValidationCellValue, serializeListOptions } from '@univerjs/sheets-data-validation';
import { IEditorBridgeService, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';
import { KeyCode, useObservable } from '@univerjs/ui';
import React, { useEffect, useMemo, useState } from 'react';
import { debounceTime } from 'rxjs';
-import type { DocumentDataModel } from '@univerjs/core';
-import type { IRichTextEditingMutationParams } from '@univerjs/docs';
-import type { ISetRangeValuesCommandParams, ISheetLocation } from '@univerjs/sheets';
-import { OpenValidationPanelOperation } from '../../commands/operations/data-validation.operation';
-import { DROP_DOWN_DEFAULT_COLOR } from '../../common/const';
-import { PLUGIN_CONFIG_KEY } from '../../controllers/config.schema';
-import { deserializeListOptions, getDataValidationCellValue, serializeListOptions } from '../../validators/util';
+import { OpenValidationPanelOperation } from '../../../commands/operations/data-validation.operation';
+import { DROP_DOWN_DEFAULT_COLOR } from '../../../const';
+import { PLUGIN_CONFIG_KEY } from '../../../controllers/config.schema';
import styles from './index.module.less';
-import type { IUniverSheetsDataValidationConfig } from '../../controllers/config.schema';
-import type { IDropdownComponentProps } from '../../services/dropdown-manager.service';
-import type { ListMultipleValidator } from '../../validators/list-multiple-validator';
interface ISelectListProps {
value: string[];
diff --git a/packages/sheets-data-validation/src/views/list/index.module.less b/packages/sheets-data-validation-ui/src/views/components/list/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/list/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/list/index.module.less
diff --git a/packages/sheets-data-validation/src/views/list/index.tsx b/packages/sheets-data-validation-ui/src/views/components/list/index.tsx
similarity index 92%
rename from packages/sheets-data-validation/src/views/list/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/list/index.tsx
index 371fbab78d..e5a0f2cfde 100644
--- a/packages/sheets-data-validation/src/views/list/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/list/index.tsx
@@ -15,16 +15,14 @@
*/
import type { ISheetDataValidationRule, Workbook } from '@univerjs/core';
-import type { IAddSheetDataValidationCommandParams } from '../../commands/commands/data-validation.command';
+import type { IAddSheetDataValidationCommandParams } from '@univerjs/sheets-data-validation';
import { ICommandService, Injector, IUniverInstanceService, LocaleService, UniverInstanceType, useDependency } from '@univerjs/core';
import { Button } from '@univerjs/design';
import { checkRangesEditablePermission } from '@univerjs/sheets';
+import { AddSheetDataValidationCommand, createDefaultNewRule, RemoveSheetAllDataValidationCommand, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
import { useObservable } from '@univerjs/ui';
import React, { useEffect, useState } from 'react';
-import { AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand } from '../../commands/commands/data-validation.command';
-import { SheetDataValidationModel } from '../../models/sheet-data-validation-model';
-import { DataValidationPanelService } from '../../services/data-validation-panel.service';
-import { createDefaultNewRule } from '../../utils/create';
+import { DataValidationPanelService } from '../../../services/data-validation-panel.service';
import { DataValidationItem } from '../item';
import styles from './index.module.less';
diff --git a/packages/sheets-data-validation/src/views/options/index.module.less b/packages/sheets-data-validation-ui/src/views/components/options/index.module.less
similarity index 100%
rename from packages/sheets-data-validation/src/views/options/index.module.less
rename to packages/sheets-data-validation-ui/src/views/components/options/index.module.less
diff --git a/packages/sheets-data-validation/src/views/options/index.tsx b/packages/sheets-data-validation-ui/src/views/components/options/index.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/options/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/options/index.tsx
index d6d42558bb..7b5f98afc7 100644
--- a/packages/sheets-data-validation/src/views/options/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/options/index.tsx
@@ -15,11 +15,11 @@
*/
import { DataValidationErrorStyle, type IDataValidationRuleOptions, LocaleService } from '@univerjs/core';
-import { Checkbox, FormLayout, Input, Radio, RadioGroup } from '@univerjs/design';
-import React, { useState } from 'react';
import { useDependency } from '@univerjs/core';
+import { Checkbox, FormLayout, Input, Radio, RadioGroup } from '@univerjs/design';
import { MoreDownSingle, MoreUpSingle } from '@univerjs/icons';
import { ComponentManager } from '@univerjs/ui';
+import React, { useState } from 'react';
import styles from './index.module.less';
export interface IDataValidationOptionsParams {
diff --git a/packages/sheets-data-validation/src/views/panel/index.tsx b/packages/sheets-data-validation-ui/src/views/components/panel/index.tsx
similarity index 92%
rename from packages/sheets-data-validation/src/views/panel/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/panel/index.tsx
index fe7ce536ce..dc43309b9b 100644
--- a/packages/sheets-data-validation/src/views/panel/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/panel/index.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import React from 'react';
import { useDependency } from '@univerjs/core';
import { useObservable } from '@univerjs/ui';
+import React from 'react';
+import { DataValidationPanelService } from '../../../services/data-validation-panel.service';
import { DataValidationDetail } from '../detail';
import { DataValidationList } from '../list';
-import { DataValidationPanelService } from '../../services/data-validation-panel.service';
export const DataValidationPanel = () => {
const dataValidationPanelService = useDependency(DataValidationPanelService);
diff --git a/packages/sheets-data-validation/src/views/render-mode/index.tsx b/packages/sheets-data-validation-ui/src/views/components/render-mode/index.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/render-mode/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/render-mode/index.tsx
diff --git a/packages/sheets-data-validation/src/views/show-time/index.tsx b/packages/sheets-data-validation-ui/src/views/components/show-time/index.tsx
similarity index 100%
rename from packages/sheets-data-validation/src/views/show-time/index.tsx
rename to packages/sheets-data-validation-ui/src/views/components/show-time/index.tsx
index f11384e203..70207c2c3b 100644
--- a/packages/sheets-data-validation/src/views/show-time/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/components/show-time/index.tsx
@@ -15,8 +15,8 @@
*/
import { type IDataValidationRuleOptions, LocaleService } from '@univerjs/core';
-import { Checkbox, FormLayout } from '@univerjs/design';
import { useDependency } from '@univerjs/core';
+import { Checkbox, FormLayout } from '@univerjs/design';
import React from 'react';
export interface IDateShowTimeOptionProps {
diff --git a/packages/sheets-data-validation/src/views/detail/index.tsx b/packages/sheets-data-validation-ui/src/views/detail/index.tsx
similarity index 98%
rename from packages/sheets-data-validation/src/views/detail/index.tsx
rename to packages/sheets-data-validation-ui/src/views/detail/index.tsx
index ea27875e7b..9ba1f5c862 100644
--- a/packages/sheets-data-validation/src/views/detail/index.tsx
+++ b/packages/sheets-data-validation-ui/src/views/detail/index.tsx
@@ -15,17 +15,17 @@
*/
import type { DataValidationOperator, DataValidationType, IDataValidationRuleBase, IDataValidationRuleOptions, IExecutionOptions, ISheetDataValidationRule, IUnitRange } from '@univerjs/core';
-import type { IUpdateSheetDataValidationRangeCommandParams } from '../../commands/commands/data-validation.command';
+import type { IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';
import { createInternalEditorID, debounce, ICommandService, isUnitRangesEqual, isValidRange, LocaleService, RedoCommand, shallowEqual, UndoCommand, useDependency } from '@univerjs/core';
import { DataValidationModel, DataValidatorRegistryScope, DataValidatorRegistryService, getRuleOptions, getRuleSetting, TWO_FORMULA_OPERATOR_COUNT } from '@univerjs/data-validation';
import { Button, FormLayout, Select } from '@univerjs/design';
import { RangeSelector } from '@univerjs/docs-ui';
import { serializeRange } from '@univerjs/engine-formula';
+import { RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from '@univerjs/sheets-data-validation';
import { ComponentManager, useEvent, useObservable } from '@univerjs/ui';
import React, { useEffect, useMemo, useState } from 'react';
-import { RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from '../../commands/commands/data-validation.command';
import { DataValidationPanelService } from '../../services/data-validation-panel.service';
-import { DataValidationOptions } from '../options';
+import { DataValidationOptions } from '../components/options';
import styles from './index.module.less';
// debounce execute commands, for better redo-undo experience
@@ -186,7 +186,7 @@ export function DataValidationDetail() {
});
};
- const FormulaInput = componentManager.get(validator.formulaInput);
+ const FormulaInput = componentManager.get(validator.formulaInput!);
const rangeStr = useMemo(() => localRanges.map((i) => serializeRange(i.range)).join(','), []);
const options: IDataValidationRuleOptions = getRuleOptions(localRule);
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/checkbox-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/checkbox-validator-view.ts
new file mode 100644
index 0000000000..0337c08804
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/checkbox-validator-view.ts
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { CHECKBOX_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { CheckboxRender } from '../widgets/checkbox-widget';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class CheckboxValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.CHECKBOX;
+ override canvasRender = this.injector.createInstance(CheckboxRender);
+ override formulaInput: string = CHECKBOX_FORMULA_INPUT_NAME;
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/custom-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/custom-validator-view.ts
new file mode 100644
index 0000000000..d55ebe3e7a
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/custom-validator-view.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { CUSTOM_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class CustomFormulaValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.CUSTOM;
+ override formulaInput: string = CUSTOM_FORMULA_INPUT_NAME;
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/date-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/date-validator-view.ts
new file mode 100644
index 0000000000..1654965bd6
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/date-validator-view.ts
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { DATE_DROPDOWN_KEY } from '../components';
+import { BASE_FORMULA_INPUT_NAME } from '../components/formula-input/formula-input';
+import { DateShowTimeOption } from '../components/show-time';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class DateValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.DATE;
+ override formulaInput: string = BASE_FORMULA_INPUT_NAME;
+ override optionsInput = DateShowTimeOption.componentKey;
+ override dropdown = DATE_DROPDOWN_KEY;
+}
+
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/decimal-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/decimal-validator-view.ts
new file mode 100644
index 0000000000..6e973516cc
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/decimal-validator-view.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { BASE_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class DecimalValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.DECIMAL;
+ override formulaInput: string = BASE_FORMULA_INPUT_NAME;
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/list-multiple-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/list-multiple-view.ts
new file mode 100644
index 0000000000..29381deaad
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/list-multiple-view.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { DropdownMultipleWidget } from '../widgets/dropdown-multiple-widget';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class ListMultipleValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.LIST_MULTIPLE;
+ override canvasRender = this.injector.createInstance(DropdownMultipleWidget);
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/list-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/list-validator-view.ts
new file mode 100644
index 0000000000..61eaa37712
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/list-validator-view.ts
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IBaseDataValidationWidget } from '@univerjs/data-validation';
+import { DataValidationType, type Nullable } from '@univerjs/core';
+import { LIST_DROPDOWN_KEY } from '../components';
+import { LIST_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { ListRenderModeInput } from '../components/render-mode';
+import { DropdownWidget } from '../widgets/dropdown-widget';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class ListValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.LIST;
+ override canvasRender: Nullable<IBaseDataValidationWidget> = this.injector.createInstance(DropdownWidget);
+ override dropdown: string | undefined = LIST_DROPDOWN_KEY;
+ override optionsInput: string | undefined = ListRenderModeInput.componentKey;
+ override formulaInput: string = LIST_FORMULA_INPUT_NAME;
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/sheet-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/sheet-validator-view.ts
new file mode 100644
index 0000000000..c47d605bcc
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/sheet-validator-view.ts
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IBaseDataValidationWidget } from '@univerjs/data-validation';
+import { Inject, Injector, type Nullable } from '@univerjs/core';
+import { LIST_FORMULA_INPUT_NAME } from '../components/formula-input';
+
+/**
+ * This is the base class for all sheet data validator views. It is used to extend {@link BaseDataValidator}.
+ */
+export abstract class BaseSheetDataValidatorView {
+ canvasRender: Nullable<IBaseDataValidationWidget> = null;
+ dropdown: string | undefined = undefined;
+ optionsInput: string | undefined = undefined;
+
+ abstract id: string;
+ formulaInput: string = LIST_FORMULA_INPUT_NAME;
+
+ constructor(
+ @Inject(Injector) protected readonly injector: Injector
+ ) {
+ // empty
+ }
+}
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/text-length-validator.view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/text-length-validator.view.ts
new file mode 100644
index 0000000000..30d37e24db
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/text-length-validator.view.ts
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { BASE_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class TextLengthValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.TEXT_LENGTH;
+ override formulaInput: string = BASE_FORMULA_INPUT_NAME;
+}
+
diff --git a/packages/sheets-data-validation-ui/src/views/validator-views/whole-validator-view.ts b/packages/sheets-data-validation-ui/src/views/validator-views/whole-validator-view.ts
new file mode 100644
index 0000000000..ddd8c56f7d
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/views/validator-views/whole-validator-view.ts
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DataValidationType } from '@univerjs/core';
+import { BASE_FORMULA_INPUT_NAME } from '../components/formula-input';
+import { BaseSheetDataValidatorView } from './sheet-validator-view';
+
+export class WholeValidatorView extends BaseSheetDataValidatorView {
+ override id = DataValidationType.WHOLE;
+ override formulaInput: string = BASE_FORMULA_INPUT_NAME;
+}
+
diff --git a/packages/sheets-data-validation/src/widgets/checkbox-widget.ts b/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts
similarity index 95%
rename from packages/sheets-data-validation/src/widgets/checkbox-widget.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts
index 2646265c41..554d0b111e 100644
--- a/packages/sheets-data-validation/src/widgets/checkbox-widget.ts
+++ b/packages/sheets-data-validation-ui/src/views/widgets/checkbox-widget.ts
@@ -14,18 +14,15 @@
* limitations under the License.
*/
-import { HorizontalAlign, ICommandService, Inject, isFormulaString, ThemeService, VerticalAlign } from '@univerjs/core';
-import { Checkbox, fixLineWidthByScale, Transform } from '@univerjs/engine-render';
-import { SetRangeValuesCommand } from '@univerjs/sheets';
import type { ICellRenderContext, IDataValidationRule, IStyleData, Nullable } from '@univerjs/core';
import type { BaseDataValidator, IBaseDataValidationWidget, IFormulaResult } from '@univerjs/data-validation';
import type { IMouseEvent, IPointerEvent, UniverRenderingContext, UniverRenderingContext2D } from '@univerjs/engine-render';
import type { ISetRangeValuesCommandParams } from '@univerjs/sheets';
-import { DataValidationFormulaService } from '../services/dv-formula.service';
-import { getFormulaResult } from '../utils/formula';
-import { getCellValueOrigin } from '../utils/get-cell-data-origin';
-import { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, transformCheckboxValue } from '../validators/checkbox-validator';
-import type { CheckboxValidator } from '../validators/checkbox-validator';
+import type { CheckboxValidator } from '@univerjs/sheets-data-validation';
+import { HorizontalAlign, ICommandService, Inject, isFormulaString, ThemeService, VerticalAlign } from '@univerjs/core';
+import { Checkbox, fixLineWidthByScale, Transform } from '@univerjs/engine-render';
+import { SetRangeValuesCommand } from '@univerjs/sheets';
+import { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, DataValidationFormulaService, getCellValueOrigin, getFormulaResult, transformCheckboxValue } from '@univerjs/sheets-data-validation';
const MARGIN_H = 6;
diff --git a/packages/sheets-data-validation/src/widgets/dropdown-multiple-widget.ts b/packages/sheets-data-validation-ui/src/views/widgets/dropdown-multiple-widget.ts
similarity index 96%
rename from packages/sheets-data-validation/src/widgets/dropdown-multiple-widget.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/dropdown-multiple-widget.ts
index bad810a2a3..ccb97675ec 100644
--- a/packages/sheets-data-validation/src/widgets/dropdown-multiple-widget.ts
+++ b/packages/sheets-data-validation-ui/src/views/widgets/dropdown-multiple-widget.ts
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-import { HorizontalAlign, ICommandService, VerticalAlign } from '@univerjs/core';
import type { ICellRenderContext } from '@univerjs/core';
-import { getFontStyleString } from '@univerjs/engine-render';
-import type { IMouseEvent, IPointerEvent, Spreadsheet, SpreadsheetSkeleton, UniverRenderingContext, UniverRenderingContext2D } from '@univerjs/engine-render';
import type { IBaseDataValidationWidget } from '@univerjs/data-validation';
-import type { ListMultipleValidator } from '../validators/list-multiple-validator';
-import { getCellValueOrigin } from '../utils/get-cell-data-origin';
-import type { IShowDataValidationDropdownParams } from '../commands/operations/data-validation.operation';
-import { ShowDataValidationDropdown } from '../commands/operations/data-validation.operation';
+import type { IMouseEvent, IPointerEvent, Spreadsheet, SpreadsheetSkeleton, UniverRenderingContext, UniverRenderingContext2D } from '@univerjs/engine-render';
+import type { ListMultipleValidator } from '@univerjs/sheets-data-validation';
+import type { IShowDataValidationDropdownParams } from '../../commands/operations/data-validation.operation';
import type { IDropdownInfo } from './dropdown-widget';
+import { HorizontalAlign, ICommandService, VerticalAlign } from '@univerjs/core';
+import { getFontStyleString } from '@univerjs/engine-render';
+import { getCellValueOrigin } from '@univerjs/sheets-data-validation';
+import { ShowDataValidationDropdown } from '../../commands/operations/data-validation.operation';
import { CELL_PADDING_H, CELL_PADDING_V, Dropdown, ICON_PLACE, layoutDropdowns, MARGIN_V } from './shape';
const downPath = new Path2D('M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z');
diff --git a/packages/sheets-data-validation/src/widgets/dropdown-widget.ts b/packages/sheets-data-validation-ui/src/views/widgets/dropdown-widget.ts
similarity index 97%
rename from packages/sheets-data-validation/src/widgets/dropdown-widget.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/dropdown-widget.ts
index 1abe027921..707247b45d 100644
--- a/packages/sheets-data-validation/src/widgets/dropdown-widget.ts
+++ b/packages/sheets-data-validation-ui/src/views/widgets/dropdown-widget.ts
@@ -17,12 +17,13 @@
import type { ICellRenderContext, IDocumentData, IPaddingData, IStyleData, Nullable } from '@univerjs/core';
import type { IBaseDataValidationWidget } from '@univerjs/data-validation';
import type { IMouseEvent, IPointerEvent, SpreadsheetSkeleton, UniverRenderingContext, UniverRenderingContext2D } from '@univerjs/engine-render';
-import type { ListValidator } from '../validators';
+import type { ListValidator } from '@univerjs/sheets-data-validation';
+import type { IShowDataValidationDropdownParams } from '../../commands/operations/data-validation.operation';
import { BooleanNumber, DataValidationRenderMode, DataValidationType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DocumentDataModel, HorizontalAlign, ICommandService, Inject, LocaleService, Tools, VerticalAlign, WrapStrategy } from '@univerjs/core';
import { Documents, DocumentSkeleton, DocumentViewModel, getDocsSkeletonPageSize, Rect } from '@univerjs/engine-render';
-import { type IShowDataValidationDropdownParams, ShowDataValidationDropdown } from '../commands/operations/data-validation.operation';
-import { DROP_DOWN_DEFAULT_COLOR } from '../common/const';
-import { getCellValueOrigin } from '../utils/get-cell-data-origin';
+import { getCellValueOrigin } from '@univerjs/sheets-data-validation';
+import { ShowDataValidationDropdown } from '../../commands/operations/data-validation.operation';
+import { DROP_DOWN_DEFAULT_COLOR } from '../../const';
const PADDING_H = 4;
const ICON_SIZE = 4;
diff --git a/packages/sheets-data-validation/src/widgets/shape/dropdown.ts b/packages/sheets-data-validation-ui/src/views/widgets/shape/dropdown.ts
similarity index 91%
rename from packages/sheets-data-validation/src/widgets/shape/dropdown.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/shape/dropdown.ts
index 255c223db6..de5944d5ea 100644
--- a/packages/sheets-data-validation/src/widgets/shape/dropdown.ts
+++ b/packages/sheets-data-validation-ui/src/views/widgets/shape/dropdown.ts
@@ -15,9 +15,9 @@
*/
import type { IShapeProps, UniverRenderingContext } from '@univerjs/engine-render';
-import { Rect, Shape } from '@univerjs/engine-render';
-import { DROP_DOWN_DEFAULT_COLOR } from '../../common/const';
import type { IDropdownLayoutInfo } from './layout';
+import { Rect, Shape } from '@univerjs/engine-render';
+import { DROP_DOWN_DEFAULT_COLOR } from '../../../const';
import { PADDING_H } from './layout';
const RADIUS = 8;
@@ -32,7 +32,7 @@ export interface IDropdownProps extends IShapeProps {
export class Dropdown extends Shape<IDropdownProps> {
static override drawWith(ctx: UniverRenderingContext, props: IDropdownProps) {
- const { fontFamily, fontString, fontSize, info, fill, color } = props;
+ const { fontString, info, fill, color } = props;
const { layout, text } = info;
ctx.save();
Rect.drawWith(ctx, {
diff --git a/packages/sheets-data-validation/src/widgets/shape/index.ts b/packages/sheets-data-validation-ui/src/views/widgets/shape/index.ts
similarity index 100%
rename from packages/sheets-data-validation/src/widgets/shape/index.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/shape/index.ts
diff --git a/packages/sheets-data-validation/src/widgets/shape/layout.ts b/packages/sheets-data-validation-ui/src/views/widgets/shape/layout.ts
similarity index 100%
rename from packages/sheets-data-validation/src/widgets/shape/layout.ts
rename to packages/sheets-data-validation-ui/src/views/widgets/shape/layout.ts
diff --git a/packages/sheets-data-validation-ui/src/vite-env.d.ts b/packages/sheets-data-validation-ui/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/sheets-data-validation-ui/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/sheets-data-validation-ui/tsconfig.json b/packages/sheets-data-validation-ui/tsconfig.json
new file mode 100644
index 0000000000..c62210cbad
--- /dev/null
+++ b/packages/sheets-data-validation-ui/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/sheets-data-validation-ui/tsconfig.node.json b/packages/sheets-data-validation-ui/tsconfig.node.json
new file mode 100644
index 0000000000..50ef1e6862
--- /dev/null
+++ b/packages/sheets-data-validation-ui/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/sheets-data-validation-ui/vite.config.ts b/packages/sheets-data-validation-ui/vite.config.ts
new file mode 100644
index 0000000000..ff0e0966ce
--- /dev/null
+++ b/packages/sheets-data-validation-ui/vite.config.ts
@@ -0,0 +1,12 @@
+import createViteConfig from '@univerjs-infra/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({}, {
+ mode,
+ pkg,
+ features: {
+ react: true,
+ css: true,
+ dom: true,
+ },
+});
diff --git a/packages/sheets-data-validation/README.md b/packages/sheets-data-validation/README.md
index 3ec844a258..4a0d2cf4ae 100644
--- a/packages/sheets-data-validation/README.md
+++ b/packages/sheets-data-validation/README.md
@@ -4,11 +4,11 @@
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
| --- | --- | --- | --- | --- | :---: | :---: |
-| `@univerjs/sheets-data-validation` | `UniverSheetsDataValidation` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
+| `@univerjs/sheets-data-validation` | `UniverSheetsDataValidation` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ️❌ | ❌️ |
## Introduction
-> `@univerjs/sheets-data-validation` provides full capabilities for Univer Sheet data validation, including panel capabilities.
+> `@univerjs/sheets-data-validation` provides full capabilities for Univer Sheet data validation.
## Usage
diff --git a/packages/sheets-data-validation/package.json b/packages/sheets-data-validation/package.json
index 71454d007d..25674fbfea 100644
--- a/packages/sheets-data-validation/package.json
+++ b/packages/sheets-data-validation/package.json
@@ -22,8 +22,7 @@
],
"exports": {
".": "./src/index.ts",
- "./*": "./src/*",
- "./locale/*": "./src/locale/*.ts"
+ "./*": "./src/*"
},
"main": "./lib/cjs/index.js",
"module": "./lib/es/index.js",
@@ -43,8 +42,7 @@
"require": "./lib/cjs/*",
"types": "./lib/types/index.d.ts"
},
- "./lib/*": "./lib/*",
- "./locale/*": "./lib/locale/*.json"
+ "./lib/*": "./lib/*"
}
},
"directories": {
@@ -58,21 +56,19 @@
"test": "vitest run",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
- "build": "tsc && vite build"
+ "build": "tsc && vite build",
+ "lint:types": "tsc --noEmit"
},
"peerDependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/data-validation": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
- "@univerjs/sheets-ui": "workspace:*",
- "@univerjs/ui": "workspace:*",
"clsx": ">=2.0.0",
"dayjs": ">=1.11.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
@@ -84,7 +80,6 @@
"@univerjs/data-validation": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/icons": "^0.1.78",
@@ -92,8 +87,6 @@
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-formula": "workspace:*",
"@univerjs/sheets-numfmt": "workspace:*",
- "@univerjs/sheets-ui": "workspace:*",
- "@univerjs/ui": "workspace:*",
"clsx": "^2.1.1",
"dayjs": "^1.11.13"
},
@@ -117,7 +110,6 @@
"require": "./lib/cjs/*",
"types": "./lib/types/index.d.ts"
},
- "./lib/*": "./lib/*",
- "./locale/*": "./lib/locale/*.json"
+ "./lib/*": "./lib/*"
}
}
diff --git a/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts b/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
index bdbf977b77..066d0e06f9 100644
--- a/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
+++ b/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
@@ -14,18 +14,16 @@
* limitations under the License.
*/
-import { CommandType, DataValidationType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Range, sequenceExecute, sequenceExecuteAsync, Tools } from '@univerjs/core';
-import { AddDataValidationMutation, DataValidatorRegistryService, getRuleOptions, getRuleSetting, RemoveDataValidationMutation, UpdateDataValidationMutation, UpdateRuleType } from '@univerjs/data-validation';
-import { getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
import type { CellValue, IAccessor, ICellData, ICommand, IDataValidationRuleBase, IDataValidationRuleOptions, IMutationInfo, Injector, IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';
import type { DataValidationChangeSource, IAddDataValidationMutationParams, IRemoveDataValidationMutationParams, IUpdateDataValidationMutationParams } from '@univerjs/data-validation';
import type { ISetRangeValuesMutationParams, ISheetCommandSharedParams } from '@univerjs/sheets';
+import type { RangeMutation } from '../../models/rule-matrix';
+import { CommandType, DataValidationType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Range, sequenceExecute, sequenceExecuteAsync, Tools } from '@univerjs/core';
+import { AddDataValidationMutation, DataValidatorRegistryService, getRuleOptions, getRuleSetting, RemoveDataValidationMutation, UpdateDataValidationMutation, UpdateRuleType } from '@univerjs/data-validation';
+import { getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
import { SheetDataValidationModel } from '../../models/sheet-data-validation-model';
-import { createDefaultNewRule } from '../../utils/create';
import { getStringCellValue } from '../../utils/get-cell-data-origin';
import { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, type CheckboxValidator } from '../../validators';
-import { OpenValidationPanelOperation } from '../operations/data-validation.operation';
-import type { RangeMutation } from '../../models/rule-matrix';
export interface IUpdateSheetDataValidationRangeCommandParams {
unitId: string;
@@ -287,40 +285,6 @@ export const AddSheetDataValidationCommand: ICommand<IAddSheetDataValidationComm
},
};
-export const AddSheetDataValidationAndOpenCommand: ICommand = {
- type: CommandType.COMMAND,
- id: 'data-validation.command.addRuleAndOpen',
- async handler(accessor) {
- const univerInstanceService = accessor.get(IUniverInstanceService);
- const target = getSheetCommandTarget(univerInstanceService);
- if (!target) return false;
-
- const { workbook, worksheet } = target;
- const rule = createDefaultNewRule(accessor);
- const commandService = accessor.get(ICommandService);
- const unitId = workbook.getUnitId();
- const subUnitId = worksheet.getSheetId();
-
- const addParams: IAddSheetDataValidationCommandParams = {
- rule,
- unitId,
- subUnitId,
- };
-
- const res = await commandService.executeCommand(AddSheetDataValidationCommand.id, addParams);
-
- if (res) {
- commandService.executeCommand(OpenValidationPanelOperation.id, {
- ruleId: rule.uid,
- isAdd: true,
- });
-
- return true;
- }
- return false;
- },
-};
-
export interface IUpdateSheetDataValidationSettingCommandParams extends ISheetCommandSharedParams {
ruleId: string;
setting: IDataValidationRuleBase;
diff --git a/packages/sheets-data-validation/src/common/const.ts b/packages/sheets-data-validation/src/common/const.ts
index e1a1eea9dd..6bcea61bb4 100644
--- a/packages/sheets-data-validation/src/common/const.ts
+++ b/packages/sheets-data-validation/src/common/const.ts
@@ -16,6 +16,4 @@
export const DATA_VALIDATION_PLUGIN_NAME = 'SHEET_DATA_VALIDATION_PLUGIN';
-export const DROP_DOWN_DEFAULT_COLOR = '#ECECEC';
-
export const DROP_DOWN_COLORS = [];
diff --git a/packages/sheets-data-validation/src/controllers/dv.controller.ts b/packages/sheets-data-validation/src/controllers/dv.controller.ts
index b493a99019..a9331f562a 100644
--- a/packages/sheets-data-validation/src/controllers/dv.controller.ts
+++ b/packages/sheets-data-validation/src/controllers/dv.controller.ts
@@ -14,25 +14,16 @@
* limitations under the License.
*/
-import { Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, UniverInstanceType } from '@univerjs/core';
+import type { Workbook } from '@univerjs/core';
+import { Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';
import { DataValidatorRegistryService } from '@univerjs/data-validation';
-import { DataValidationSingle } from '@univerjs/icons';
import { ClearSelectionAllCommand, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
-import { ComponentManager } from '@univerjs/ui';
-import type { Workbook } from '@univerjs/core';
import { getDataValidationDiffMutations } from '../commands/commands/data-validation.command';
-import { DATA_VALIDATION_PANEL } from '../commands/operations/data-validation.operation';
import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
import { CheckboxValidator, DateValidator, DecimalValidator, ListValidator, TextLengthValidator } from '../validators';
import { CustomFormulaValidator } from '../validators/custom-validator';
import { ListMultipleValidator } from '../validators/list-multiple-validator';
import { WholeValidator } from '../validators/whole-validator';
-import { DataValidationPanel, DATE_DROPDOWN_KEY, DateDropdown, LIST_DROPDOWN_KEY, ListDropDown } from '../views';
-import { CellDropdown, DROP_DOWN_KEY } from '../views/drop-down';
-import { FORMULA_INPUTS } from '../views/formula-input';
-import { ListRenderModeInput } from '../views/render-mode';
-import { DateShowTimeOption } from '../views/show-time';
-import { DataValidationIcon } from './dv.menu';
@OnLifecycle(LifecycleStages.Rendered, DataValidationController)
export class DataValidationController extends RxDisposable {
@@ -40,7 +31,6 @@ export class DataValidationController extends RxDisposable {
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
@Inject(DataValidatorRegistryService) private readonly _dataValidatorRegistryService: DataValidatorRegistryService,
@Inject(Injector) private readonly _injector: Injector,
- @Inject(ComponentManager) private readonly _componentManger: ComponentManager,
@Inject(SheetsSelectionsService) private _selectionManagerService: SheetsSelectionsService,
@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,
@Inject(SheetDataValidationModel) private readonly _sheetDataValidationModel: SheetDataValidationModel
@@ -52,10 +42,9 @@ export class DataValidationController extends RxDisposable {
private _init() {
this._registerValidators();
this._initCommandInterceptor();
- this._initComponents();
}
- private _registerValidators() {
+ private _registerValidators(): void {
([
DecimalValidator,
WholeValidator,
@@ -67,14 +56,8 @@ export class DataValidationController extends RxDisposable {
CustomFormulaValidator,
]).forEach((Validator) => {
const validator = this._injector.createInstance(Validator as typeof ListValidator);
- this.disposeWithMe(
- this._dataValidatorRegistryService.register(validator)
- );
- this.disposeWithMe({
- dispose: () => {
- this._injector.delete(Validator as typeof ListValidator);
- },
- });
+ this.disposeWithMe(this._dataValidatorRegistryService.register(validator));
+ this.disposeWithMe(toDisposable(() => this._injector.delete(Validator as typeof ListValidator)));
});
}
@@ -113,22 +96,4 @@ export class DataValidationController extends RxDisposable {
},
});
}
-
- private _initComponents() {
- ([
- [DataValidationIcon, DataValidationSingle],
- [DATA_VALIDATION_PANEL, DataValidationPanel],
- [DROP_DOWN_KEY, CellDropdown],
- [LIST_DROPDOWN_KEY, ListDropDown],
- [DATE_DROPDOWN_KEY, DateDropdown],
- [ListRenderModeInput.componentKey, ListRenderModeInput],
- [DateShowTimeOption.componentKey, DateShowTimeOption],
- ...FORMULA_INPUTS,
- ] as const).forEach(([key, component]) => {
- this.disposeWithMe(this._componentManger.register(
- key,
- component
- ));
- });
- }
}
diff --git a/packages/sheets-data-validation/src/index.ts b/packages/sheets-data-validation/src/index.ts
index 25b81133a5..bbb80325c4 100644
--- a/packages/sheets-data-validation/src/index.ts
+++ b/packages/sheets-data-validation/src/index.ts
@@ -15,7 +15,6 @@
*/
export { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
-export { UniverSheetsDataValidationMobilePlugin } from './mobile-plugin';
export { SheetDataValidationModel } from './models/sheet-data-validation-model';
export { UniverSheetsDataValidationPlugin } from './plugin';
export { DataValidationCacheService } from './services/dv-cache.service';
@@ -23,17 +22,25 @@ export type { IDataValidationResCache } from './services/dv-cache.service';
export { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
export { DataValidationFormulaService } from './services/dv-formula.service';
export { SheetsDataValidationValidatorService } from './services/dv-validator-service';
-
-export { DATE_DROPDOWN_KEY, LIST_DROPDOWN_KEY } from './views';
+export { createDefaultNewRule } from './utils/create';
+export { DataValidationFormulaController } from './controllers/dv-formula.controller';
+export { getFormulaCellData, getFormulaResult } from './utils/formula';
+export { getCellValueOrigin } from './utils/get-cell-data-origin';
+export { ListValidator } from './validators/list-validator';
+export { DateValidator } from './validators/date-validator';
+export { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CheckboxValidator, transformCheckboxValue } from './validators/checkbox-validator';
+export { ListMultipleValidator } from './validators/list-multiple-validator';
+export { deserializeListOptions, getDataValidationCellValue, serializeListOptions } from './validators/util';
// TODO: @jikkai: I think this is a mistake, it should be exported from here. @weird94
export { DataValidationModel } from '@univerjs/data-validation';
// #region - all commands
+
export {
- AddSheetDataValidationAndOpenCommand,
AddSheetDataValidationCommand,
ClearRangeDataValidationCommand,
+ getDataValidationDiffMutations,
type IAddSheetDataValidationCommandParams,
type IClearRangeDataValidationCommandParams,
type IRemoveSheetAllDataValidationCommandParams,
@@ -47,12 +54,5 @@ export {
UpdateSheetDataValidationRangeCommand,
UpdateSheetDataValidationSettingCommand,
} from './commands/commands/data-validation.command';
-export {
- CloseValidationPanelOperation,
- HideDataValidationDropdown,
- OpenValidationPanelOperation,
- ShowDataValidationDropdown,
- ToggleValidationPanelOperation,
-} from './commands/operations/data-validation.operation';
// #endregion
diff --git a/packages/sheets-data-validation/src/mobile-plugin.ts b/packages/sheets-data-validation/src/mobile-plugin.ts
deleted file mode 100644
index ddd9b09d5e..0000000000
--- a/packages/sheets-data-validation/src/mobile-plugin.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {
- DependentOn,
- ICommandService,
- IConfigService,
- Plugin,
- UniverInstanceType,
-} from '@univerjs/core';
-import { type Dependency, Inject, Injector } from '@univerjs/core';
-import { UniverDataValidationPlugin } from '@univerjs/data-validation';
-import { UniverSheetsPlugin } from '@univerjs/sheets';
-import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
-import { AddSheetDataValidationAndOpenCommand, AddSheetDataValidationCommand, ClearRangeDataValidationCommand, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from './commands/commands/data-validation.command';
-import { CloseValidationPanelOperation, HideDataValidationDropdown, OpenValidationPanelOperation, ShowDataValidationDropdown, ToggleValidationPanelOperation } from './commands/operations/data-validation.operation';
-import { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
-import {
- defaultPluginConfig,
- type IUniverSheetsDataValidationConfig,
- PLUGIN_CONFIG_KEY,
-} from './controllers/config.schema';
-import { DataValidationController } from './controllers/dv.controller';
-import { DataValidationAlertController } from './controllers/dv-alert.controller';
-import { DataValidationCopyPasteController } from './controllers/dv-copy-paste.controller';
-import { DataValidationFormulaController } from './controllers/dv-formula.controller';
-import { DataValidationPermissionController } from './controllers/dv-permission.controller';
-import { DataValidationRefRangeController } from './controllers/dv-ref-range.controller';
-import { SheetsDataValidationMobileRenderController } from './controllers/dv-render.controller';
-import { SheetDataValidationModel } from './models/sheet-data-validation-model';
-import { DataValidationPanelService } from './services/data-validation-panel.service';
-import { DataValidationDropdownManagerService } from './services/dropdown-manager.service';
-import { DataValidationCacheService } from './services/dv-cache.service';
-import { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
-import { DataValidationFormulaService } from './services/dv-formula.service';
-import { SheetsDataValidationValidatorService } from './services/dv-validator-service';
-
-@DependentOn(UniverDataValidationPlugin, UniverSheetsPlugin, UniverSheetsUIPlugin)
-export class UniverSheetsDataValidationMobilePlugin extends Plugin {
- static override pluginName = DATA_VALIDATION_PLUGIN_NAME;
- static override type = UniverInstanceType.UNIVER_SHEET;
-
- constructor(
- private readonly _config: Partial<IUniverSheetsDataValidationConfig> = defaultPluginConfig,
- @Inject(Injector) protected _injector: Injector,
- @ICommandService private readonly _commandService: ICommandService,
- @IConfigService private readonly _configService: IConfigService
- ) {
- super();
-
- // Manage the plugin configuration.
- const { menu, ...rest } = this._config;
- if (menu) {
- this._configService.setConfig('menu', menu, { merge: true });
- }
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
- }
-
- override onStarting() {
- ([
- [DataValidationPanelService],
- [DataValidationCacheService],
- [DataValidationFormulaService],
- [DataValidationCustomFormulaService],
- [DataValidationDropdownManagerService],
- [SheetsDataValidationValidatorService],
- [SheetDataValidationModel],
- // controller
- [DataValidationController],
- [SheetsDataValidationMobileRenderController],
- [DataValidationAlertController],
- [DataValidationRefRangeController],
- [DataValidationPermissionController],
- [DataValidationCopyPasteController],
- [DataValidationFormulaController],
- ] as Dependency[]).forEach((dep) => {
- this._injector.add(dep);
- });
-
- [
- AddSheetDataValidationCommand,
- AddSheetDataValidationAndOpenCommand,
- UpdateSheetDataValidationRangeCommand,
- UpdateSheetDataValidationSettingCommand,
- UpdateSheetDataValidationOptionsCommand,
- RemoveSheetDataValidationCommand,
- RemoveSheetAllDataValidationCommand,
- ClearRangeDataValidationCommand,
-
- // operation
- ShowDataValidationDropdown,
- HideDataValidationDropdown,
- CloseValidationPanelOperation,
- OpenValidationPanelOperation,
- ToggleValidationPanelOperation,
- ].forEach((command) => {
- this._commandService.registerCommand(command);
- });
- }
-}
diff --git a/packages/sheets-data-validation/src/models/rule-matrix.ts b/packages/sheets-data-validation/src/models/rule-matrix.ts
index 70c59005aa..1a90af654f 100644
--- a/packages/sheets-data-validation/src/models/rule-matrix.ts
+++ b/packages/sheets-data-validation/src/models/rule-matrix.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
+import type { IRange, ISheetDataValidationRule, IUniverInstanceService, Workbook } from '@univerjs/core';
import IntervalTree from '@flatten-js/interval-tree';
import { debounce, Range, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';
-import type { IRange, ISheetDataValidationRule, IUniverInstanceService, Workbook } from '@univerjs/core';
interface IRuleItem {
ruleId: string;
diff --git a/packages/sheets-data-validation/src/plugin.ts b/packages/sheets-data-validation/src/plugin.ts
index 0712ecd3f1..ee572b71fb 100644
--- a/packages/sheets-data-validation/src/plugin.ts
+++ b/packages/sheets-data-validation/src/plugin.ts
@@ -17,77 +17,55 @@
import {
DependentOn,
ICommandService,
- IConfigService,
Plugin,
UniverInstanceType,
} from '@univerjs/core';
import { type Dependency, Inject, Injector } from '@univerjs/core';
import { UniverDataValidationPlugin } from '@univerjs/data-validation';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
-import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';
-import { AddSheetDataValidationAndOpenCommand, AddSheetDataValidationCommand, ClearRangeDataValidationCommand, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand } from './commands/commands/data-validation.command';
-import { CloseValidationPanelOperation, HideDataValidationDropdown, OpenValidationPanelOperation, ShowDataValidationDropdown, ToggleValidationPanelOperation } from './commands/operations/data-validation.operation';
+import {
+ AddSheetDataValidationCommand,
+ ClearRangeDataValidationCommand,
+ RemoveSheetAllDataValidationCommand,
+ RemoveSheetDataValidationCommand,
+ UpdateSheetDataValidationOptionsCommand,
+ UpdateSheetDataValidationRangeCommand,
+ UpdateSheetDataValidationSettingCommand,
+} from './commands/commands/data-validation.command';
import { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
import { DataValidationController } from './controllers/dv.controller';
-import { DataValidationAlertController } from './controllers/dv-alert.controller';
-import { DataValidationAutoFillController } from './controllers/dv-auto-fill.controller';
-import { DataValidationCopyPasteController } from './controllers/dv-copy-paste.controller';
import { DataValidationFormulaController } from './controllers/dv-formula.controller';
-import { DataValidationPermissionController } from './controllers/dv-permission.controller';
import { DataValidationRefRangeController } from './controllers/dv-ref-range.controller';
-import { DataValidationRejectInputController } from './controllers/dv-reject-input.controller';
-import { SheetsDataValidationRenderController } from './controllers/dv-render.controller';
import { SheetDataValidationSheetController } from './controllers/dv-sheet.controller';
import { SheetDataValidationModel } from './models/sheet-data-validation-model';
-import { DataValidationPanelService } from './services/data-validation-panel.service';
-import { DataValidationDropdownManagerService } from './services/dropdown-manager.service';
import { DataValidationCacheService } from './services/dv-cache.service';
import { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
import { DataValidationFormulaService } from './services/dv-formula.service';
import { SheetsDataValidationValidatorService } from './services/dv-validator-service';
-import type { IUniverSheetsDataValidationConfig } from './controllers/config.schema';
-@DependentOn(UniverSheetsNumfmtPlugin, UniverDataValidationPlugin, UniverSheetsUIPlugin)
+@DependentOn(UniverSheetsNumfmtPlugin, UniverDataValidationPlugin)
export class UniverSheetsDataValidationPlugin extends Plugin {
static override pluginName = DATA_VALIDATION_PLUGIN_NAME;
static override type = UniverInstanceType.UNIVER_SHEET;
constructor(
- private readonly _config: Partial<IUniverSheetsDataValidationConfig> = defaultPluginConfig,
+ _config = undefined,
@Inject(Injector) protected _injector: Injector,
- @ICommandService private readonly _commandService: ICommandService,
- @IConfigService private readonly _configService: IConfigService
+ @ICommandService private readonly _commandService: ICommandService
) {
super();
-
- // Manage the plugin configuration..
- const { menu, ...rest } = this._config;
- if (menu) {
- this._configService.setConfig('menu', menu, { merge: true });
- }
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
}
override onStarting() {
([
- [DataValidationPanelService],
[DataValidationCacheService],
[DataValidationFormulaService],
[DataValidationCustomFormulaService],
- [DataValidationDropdownManagerService],
[SheetsDataValidationValidatorService],
[SheetDataValidationModel],
- // controller
[DataValidationController],
- [SheetsDataValidationRenderController],
- [DataValidationAlertController],
[DataValidationRefRangeController],
- [DataValidationPermissionController],
- [DataValidationAutoFillController],
- [DataValidationCopyPasteController],
[DataValidationFormulaController],
- [DataValidationRejectInputController],
[SheetDataValidationSheetController],
] as Dependency[]).forEach((dep) => {
this._injector.add(dep);
@@ -95,20 +73,12 @@ export class UniverSheetsDataValidationPlugin extends Plugin {
[
AddSheetDataValidationCommand,
- AddSheetDataValidationAndOpenCommand,
UpdateSheetDataValidationRangeCommand,
UpdateSheetDataValidationSettingCommand,
UpdateSheetDataValidationOptionsCommand,
RemoveSheetDataValidationCommand,
RemoveSheetAllDataValidationCommand,
ClearRangeDataValidationCommand,
-
- // operation
- ShowDataValidationDropdown,
- HideDataValidationDropdown,
- CloseValidationPanelOperation,
- OpenValidationPanelOperation,
- ToggleValidationPanelOperation,
].forEach((command) => {
this._commandService.registerCommand(command);
});
diff --git a/packages/sheets-data-validation/src/utils/create.ts b/packages/sheets-data-validation/src/utils/create.ts
index d7af36f48b..9784c22c29 100644
--- a/packages/sheets-data-validation/src/utils/create.ts
+++ b/packages/sheets-data-validation/src/utils/create.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
+import type { IAccessor } from '@univerjs/core';
import { DataValidationOperator, DataValidationType, Tools } from '@univerjs/core';
import { SheetsSelectionsService } from '@univerjs/sheets';
-import type { IAccessor } from '@univerjs/core';
export function createDefaultNewRule(accessor: IAccessor) {
const selectionManagerService = accessor.get(SheetsSelectionsService);
diff --git a/packages/sheets-data-validation/src/validators/checkbox-validator.ts b/packages/sheets-data-validation/src/validators/checkbox-validator.ts
index dfcfbcc738..ab89c7498a 100644
--- a/packages/sheets-data-validation/src/validators/checkbox-validator.ts
+++ b/packages/sheets-data-validation/src/validators/checkbox-validator.ts
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-import { DataValidationType, isFormulaString, Tools, WrapStrategy } from '@univerjs/core';
-import { BaseDataValidator } from '@univerjs/data-validation';
import type { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, LocaleService, Nullable } from '@univerjs/core';
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
+import { DataValidationType, isFormulaString, Tools, WrapStrategy } from '@univerjs/core';
+import { BaseDataValidator } from '@univerjs/data-validation';
import { DataValidationFormulaService } from '../services/dv-formula.service';
import { getFormulaResult } from '../utils/formula';
-import { CHECKBOX_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { CheckboxRender } from '../widgets/checkbox-widget';
export const CHECKBOX_FORMULA_1 = 1;
export const CHECKBOX_FORMULA_2 = 0;
@@ -55,9 +53,6 @@ export class CheckboxValidator extends BaseDataValidator {
override title: string = 'dataValidation.checkbox.title';
override operators: DataValidationOperator[] = [];
override scopes: string | string[] = ['sheet'];
- override formulaInput: string = CHECKBOX_FORMULA_INPUT_NAME;
-
- override canvasRender = this.injector.createInstance(CheckboxRender);
private _formulaService = this.injector.get(DataValidationFormulaService);
diff --git a/packages/sheets-data-validation/src/validators/custom-validator.ts b/packages/sheets-data-validation/src/validators/custom-validator.ts
index 280e29a4d0..4660078bdf 100644
--- a/packages/sheets-data-validation/src/validators/custom-validator.ts
+++ b/packages/sheets-data-validation/src/validators/custom-validator.ts
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-import { CellValueType, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import type { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
+import { CellValueType, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import { BaseDataValidator } from '@univerjs/data-validation';
import { ERROR_TYPE_SET } from '@univerjs/engine-formula';
-import { CUSTOM_FORMULA_INPUT_NAME } from '../views/formula-input';
import { DataValidationCustomFormulaService } from '../services/dv-custom-formula.service';
import { getFormulaCellData } from '../utils/formula';
@@ -32,7 +31,6 @@ export class CustomFormulaValidator extends BaseDataValidator {
override title: string = 'dataValidation.custom.title';
override operators: DataValidationOperator[] = [];
override scopes: string | string[] = ['sheet'];
- override formulaInput: string = CUSTOM_FORMULA_INPUT_NAME;
private _customFormulaService = this.injector.get(DataValidationCustomFormulaService);
diff --git a/packages/sheets-data-validation/src/validators/date-validator.ts b/packages/sheets-data-validation/src/validators/date-validator.ts
index 2dc5c8f93f..2287eb5587 100644
--- a/packages/sheets-data-validation/src/validators/date-validator.ts
+++ b/packages/sheets-data-validation/src/validators/date-validator.ts
@@ -14,18 +14,15 @@
* limitations under the License.
*/
+import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
+import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
import { DataValidationOperator, DataValidationType, isFormulaString, numfmt, Tools } from '@univerjs/core';
import { BaseDataValidator } from '@univerjs/data-validation';
import dayjs from 'dayjs';
-import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
-import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
import { DateOperatorErrorTitleMap, DateOperatorNameMap, DateOperatorTitleMap } from '../common/date-text-map';
import { DataValidationFormulaService } from '../services/dv-formula.service';
import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
import { getFormulaResult } from '../utils/formula';
-import { DATE_DROPDOWN_KEY } from '../views';
-import { BASE_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { DateShowTimeOption } from '../views/show-time';
const FORMULA1 = '{FORMULA1}';
const FORMULA2 = '{FORMULA2}';
@@ -64,10 +61,6 @@ export class DateValidator extends BaseDataValidator<number> {
];
scopes: string | string[] = ['sheet'];
- formulaInput: string = BASE_FORMULA_INPUT_NAME;
- override optionsInput = DateShowTimeOption.componentKey;
- override dropdown = DATE_DROPDOWN_KEY;
-
private _formulaService = this.injector.get(DataValidationFormulaService);
override async parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<number | undefined>> {
diff --git a/packages/sheets-data-validation/src/validators/decimal-validator.ts b/packages/sheets-data-validation/src/validators/decimal-validator.ts
index c0bf79499a..16b2fa08f1 100644
--- a/packages/sheets-data-validation/src/validators/decimal-validator.ts
+++ b/packages/sheets-data-validation/src/validators/decimal-validator.ts
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import type { CellValue, IDataValidationRule, Nullable } from '@univerjs/core';
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
+import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import { BaseDataValidator } from '@univerjs/data-validation';
-import { BASE_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
import { DataValidationFormulaService } from '../services/dv-formula.service';
+import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
export function getCellValueNumber(cellValue: CellValue) {
let str = cellValue;
@@ -53,8 +52,6 @@ export class DecimalValidator extends BaseDataValidator<number> {
];
scopes: string | string[] = ['sheet'];
- formulaInput: string = BASE_FORMULA_INPUT_NAME;
- dropDownInput?: string;
private _isFormulaOrNumber(formula: string) {
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
diff --git a/packages/sheets-data-validation/src/validators/list-multiple-validator.ts b/packages/sheets-data-validation/src/validators/list-multiple-validator.ts
index db4914fcf5..f61e1883d6 100644
--- a/packages/sheets-data-validation/src/validators/list-multiple-validator.ts
+++ b/packages/sheets-data-validation/src/validators/list-multiple-validator.ts
@@ -15,13 +15,11 @@
*/
import { DataValidationType } from '@univerjs/core';
-import { DropdownMultipleWidget } from '../widgets/dropdown-multiple-widget';
import { ListValidator } from './list-validator';
export class ListMultipleValidator extends ListValidator {
override id: string = DataValidationType.LIST_MULTIPLE;
override title: string = 'dataValidation.listMultiple.title';
- override canvasRender = this.injector.createInstance(DropdownMultipleWidget);
override skipDefaultFontRender = () => {
return true;
diff --git a/packages/sheets-data-validation/src/validators/list-validator.ts b/packages/sheets-data-validation/src/validators/list-validator.ts
index 64b2e7420a..6138c9c551 100644
--- a/packages/sheets-data-validation/src/validators/list-validator.ts
+++ b/packages/sheets-data-validation/src/validators/list-validator.ts
@@ -14,17 +14,13 @@
* limitations under the License.
*/
+import type { CellValue, DataValidationOperator, ICellData, IDataValidationRule, IRange, ISheetDataValidationRule, IStyleData, Nullable, Workbook } from '@univerjs/core';
+import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
import { DataValidationRenderMode, DataValidationType, isFormulaString, IUniverInstanceService, numfmt, Rectangle, Tools, UniverInstanceType, WrapStrategy } from '@univerjs/core';
import { BaseDataValidator } from '@univerjs/data-validation';
import { deserializeRangeWithSheet, isReferenceString, LexerTreeBuilder, sequenceNodeType } from '@univerjs/engine-formula';
-import type { CellValue, DataValidationOperator, ICellData, IDataValidationRule, IRange, ISheetDataValidationRule, IStyleData, Nullable, Workbook } from '@univerjs/core';
-import type { IBaseDataValidationWidget, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
import { DataValidationFormulaService } from '../services/dv-formula.service';
import { getCellValueOrigin } from '../utils/get-cell-data-origin';
-import { LIST_DROPDOWN_KEY } from '../views';
-import { LIST_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { ListRenderModeInput } from '../views/render-mode';
-import { DropdownWidget } from '../widgets/dropdown-widget';
import { deserializeListOptions } from './util';
export function getRuleFormulaResultSet(result: Nullable<Nullable<ICellData>[][]>) {
@@ -97,13 +93,6 @@ export class ListValidator extends BaseDataValidator {
title: string = 'dataValidation.list.title';
operators: DataValidationOperator[] = [];
scopes: string | string[] = ['sheet'];
- formulaInput: string = LIST_FORMULA_INPUT_NAME;
-
- override canvasRender: Nullable<IBaseDataValidationWidget> = this.injector.createInstance(DropdownWidget);
-
- override dropdown: string | undefined = LIST_DROPDOWN_KEY;
-
- override optionsInput: string | undefined = ListRenderModeInput.componentKey;
override skipDefaultFontRender = (rule: ISheetDataValidationRule) => {
return rule.renderMode !== DataValidationRenderMode.TEXT;
diff --git a/packages/sheets-data-validation/src/validators/text-length-validator.ts b/packages/sheets-data-validation/src/validators/text-length-validator.ts
index 1b45f1d48d..b56a9c898a 100644
--- a/packages/sheets-data-validation/src/validators/text-length-validator.ts
+++ b/packages/sheets-data-validation/src/validators/text-length-validator.ts
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
+import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import { BaseDataValidator, TextLengthErrorTitleMap } from '@univerjs/data-validation';
-import { BASE_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
import { DataValidationFormulaService } from '../services/dv-formula.service';
+import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
const FORMULA1 = '{FORMULA1}';
const FORMULA2 = '{FORMULA2}';
@@ -41,7 +40,6 @@ export class TextLengthValidator extends BaseDataValidator<number> {
];
scopes: string | string[] = ['sheet'];
- formulaInput: string = BASE_FORMULA_INPUT_NAME;
private _formulaService = this.injector.get(DataValidationFormulaService);
diff --git a/packages/sheets-data-validation/src/validators/util.ts b/packages/sheets-data-validation/src/validators/util.ts
index 081629c492..93e1b151a5 100644
--- a/packages/sheets-data-validation/src/validators/util.ts
+++ b/packages/sheets-data-validation/src/validators/util.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Range, UniverInstanceType } from '@univerjs/core';
import type { ICellData, IUnitRangeName, IUniverInstanceService, Nullable, Workbook } from '@univerjs/core';
+import { Range, UniverInstanceType } from '@univerjs/core';
import { getCellValueOrigin } from '../utils/get-cell-data-origin';
export function getSheetRangeValueSet(grid: IUnitRangeName, univerInstanceService: IUniverInstanceService, currUnitId: string, currSubUnitId: string) {
diff --git a/packages/sheets-data-validation/src/validators/whole-validator.ts b/packages/sheets-data-validation/src/validators/whole-validator.ts
index 48c2cc554f..138c55101d 100644
--- a/packages/sheets-data-validation/src/validators/whole-validator.ts
+++ b/packages/sheets-data-validation/src/validators/whole-validator.ts
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
+import { DataValidationOperator, DataValidationType, isFormulaString, Tools } from '@univerjs/core';
import { BaseDataValidator } from '@univerjs/data-validation';
-import { BASE_FORMULA_INPUT_NAME } from '../views/formula-input';
-import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
import { DataValidationFormulaService } from '../services/dv-formula.service';
+import { TWO_FORMULA_OPERATOR_COUNT } from '../types/const/two-formula-operators';
import { getCellValueNumber } from './decimal-validator';
export class WholeValidator extends BaseDataValidator<number> {
@@ -41,8 +40,6 @@ export class WholeValidator extends BaseDataValidator<number> {
];
scopes: string | string[] = ['sheet'];
- formulaInput: string = BASE_FORMULA_INPUT_NAME;
- dropDownInput?: string;
private _isFormulaOrInt(formula: string) {
return !Tools.isBlank(formula) && (isFormulaString(formula) || (!Number.isNaN(+formula) && Number.isInteger(+formula)));
diff --git a/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
index 4c6bf920f8..b04122573f 100644
--- a/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
+++ b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts
@@ -15,11 +15,11 @@
*/
import { Disposable, ICommandService, IResourceManagerService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import type { IDrawingSubunitMap } from '@univerjs/drawing';
import { IDrawingManagerService } from '@univerjs/drawing';
-import type { ISheetDrawing } from '../services/sheet-drawing.service';
-import { ISheetDrawingService } from '../services/sheet-drawing.service';
+import type { IDrawingSubunitMap } from '@univerjs/drawing';
import { SetDrawingApplyMutation } from '../commands/mutations/set-drawing-apply.mutation';
+import { ISheetDrawingService } from '../services/sheet-drawing.service';
+import type { ISheetDrawing } from '../services/sheet-drawing.service';
export const SHEET_DRAWING_PLUGIN = 'SHEET_DRAWING_PLUGIN';
diff --git a/packages/sheets-drawing/src/index.ts b/packages/sheets-drawing/src/index.ts
index b862e01344..5c4e458433 100644
--- a/packages/sheets-drawing/src/index.ts
+++ b/packages/sheets-drawing/src/index.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-/* eslint-disable perfectionist/sort-exports */
export { UniverSheetsDrawingPlugin } from './plugin';
export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
export { SHEET_DRAWING_PLUGIN } from './controllers/sheet-drawing.controller';
diff --git a/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts b/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts
index b34598e9df..6842f3ecd9 100644
--- a/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts
+++ b/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import type { Dependency } from '@univerjs/core';
+import type { IUniverSheetsFilterUIConfig } from './controllers/config.schema';
import {
DependentOn,
IConfigService,
@@ -23,15 +25,13 @@ import {
Plugin,
UniverInstanceType,
} from '@univerjs/core';
-import type { Dependency } from '@univerjs/core';
-import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { IRPCChannelService, toModule } from '@univerjs/rpc';
+import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
+import { SheetsFilterPermissionController } from './controllers/sheets-filter-permission.controller';
import { SheetsFilterUIDesktopController } from './controllers/sheets-filter-ui-desktop.controller';
import { SheetsFilterPanelService } from './services/sheets-filter-panel.service';
-import { SheetsFilterPermissionController } from './controllers/sheets-filter-permission.controller';
import { ISheetsGenerateFilterValuesService, SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME } from './worker/generate-filter-values.service';
-import type { IUniverSheetsFilterUIConfig } from './controllers/config.schema';
-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
const NAME = 'SHEET_FILTER_UI_PLUGIN';
diff --git a/packages/sheets-formula-ui/README.md b/packages/sheets-formula-ui/README.md
new file mode 100644
index 0000000000..6d746f30f6
--- /dev/null
+++ b/packages/sheets-formula-ui/README.md
@@ -0,0 +1,39 @@
+# @univerjs/sheets-formula-ui
+
+## Package Overview
+
+| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
+| --- | --- | --- | --- | --- | :---: | :---: |
+| `@univerjs/sheets-formula-ui` | `UniverSheetsFormulaUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
+
+## Introduction
+
+`@univerjs/sheets-formula` provides the ability to edit formulas in spreadsheets, including features such as auto-completion, formula suggestions, drop-down filling for formulas, and copy-paste functionality.
+
+> [!NOTE]
+> Formula calculation is one of the core functionalities of spreadsheets, and formula calculation scheduling is done in `@univerjs/sheets`.
+
+## Usage
+
+### Installation
+
+```shell
+# Using npm
+npm install @univerjs/sheets-formula-ui
+
+# Using pnpm
+pnpm add @univerjs/sheets-formula-ui
+```
+
+### How To Customize Formulas
+
+If the officially provided formula does not meet your needs, you can expand the formula yourself. Depending on different needs, we provide multiple ways to support registering one or more custom formulas.
+
+- [Register formula using Facade API](https://univer.ai/guides/sheet/facade/general/#register-formula)
+- [Custom Formula](https://univer.ai/guides/sheet/customization/formula/)
+
+<!-- Links -->
+[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-formula?style=flat-square
+[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-formula
+[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-formula?style=flat-square
+[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-formula?style=flat-square
diff --git a/packages/sheets-formula-ui/package.json b/packages/sheets-formula-ui/package.json
new file mode 100644
index 0000000000..e9f127903a
--- /dev/null
+++ b/packages/sheets-formula-ui/package.json
@@ -0,0 +1,122 @@
+{
+ "name": "@univerjs/sheets-formula-ui",
+ "version": "0.2.14",
+ "private": false,
+ "author": "DreamNum <[email protected]>",
+ "license": "Apache-2.0",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/univer"
+ },
+ "homepage": "https://univer.ai",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dream-num/univer"
+ },
+ "bugs": {
+ "url": "https://github.com/dream-num/univer/issues"
+ },
+ "keywords": [
+ "univer"
+ ],
+ "sideEffects": [
+ "**/*.css"
+ ],
+ "exports": {
+ ".": "./src/index.ts",
+ "./*": "./src/*",
+ "./locale/*": "./src/locale/*.ts"
+ },
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "types": "./lib/types/index.d.ts",
+ "publishConfig": {
+ "access": "public",
+ "main": "./lib/cjs/index.js",
+ "module": "./lib/es/index.js",
+ "exports": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+ },
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "lib"
+ ],
+ "scripts": {
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "coverage": "vitest run --coverage",
+ "lint:types": "tsc --noEmit",
+ "build": "tsc && vite build",
+ "sync:cnpm": "cnpm sync"
+ },
+ "peerDependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/rpc": "workspace:*",
+ "@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-filter": "workspace:*",
+ "@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-ui": "workspace:*",
+ "@univerjs/ui": "workspace:*",
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
+ "rxjs": ">=7.0.0"
+ },
+ "dependencies": {
+ "@univerjs/core": "workspace:*",
+ "@univerjs/design": "workspace:*",
+ "@univerjs/docs": "workspace:*",
+ "@univerjs/docs-ui": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
+ "@univerjs/engine-render": "workspace:*",
+ "@univerjs/icons": "^0.1.78",
+ "@univerjs/rpc": "workspace:*",
+ "@univerjs/sheets": "workspace:*",
+ "@univerjs/sheets-formula": "workspace:*",
+ "@univerjs/sheets-numfmt": "workspace:*",
+ "@univerjs/sheets-ui": "workspace:*",
+ "@univerjs/ui": "workspace:*"
+ },
+ "devDependencies": {
+ "@types/react": "^18.3.5",
+ "@univerjs-infra/shared": "workspace:*",
+ "@vitejs/plugin-react": "^4.3.1",
+ "less": "^4.2.0",
+ "react": "18.3.1",
+ "rxjs": "^7.8.1",
+ "typescript": "^5.6.2",
+ "vite": "^5.4.4",
+ "vitest": "^2.0.5"
+ },
+ "univerSpace": {
+ ".": {
+ "import": "./lib/es/index.js",
+ "require": "./lib/cjs/index.js",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./*": {
+ "import": "./lib/es/*",
+ "require": "./lib/cjs/*",
+ "types": "./lib/types/index.d.ts"
+ },
+ "./lib/*": "./lib/*",
+ "./locale/*": "./lib/locale/*.json"
+ }
+}
diff --git a/packages/sheets-formula/src/commands/commands/formula-clipboard.command.ts b/packages/sheets-formula-ui/src/commands/commands/formula-clipboard.command.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/commands/formula-clipboard.command.ts
rename to packages/sheets-formula-ui/src/commands/commands/formula-clipboard.command.ts
index 881da3494a..349d0dfb9d 100644
--- a/packages/sheets-formula/src/commands/commands/formula-clipboard.command.ts
+++ b/packages/sheets-formula-ui/src/commands/commands/formula-clipboard.command.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import type { ICommand } from '@univerjs/core';
import { CommandType, ICommandService } from '@univerjs/core';
import { PREDEFINED_HOOK_NAME, SheetPasteCommand } from '@univerjs/sheets-ui';
+import type { ICommand } from '@univerjs/core';
export const SheetOnlyPasteFormulaCommand: ICommand = {
id: 'sheet.command.paste-formula',
diff --git a/packages/sheets-formula/src/commands/operations/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/__tests__/create-command-test-bed.ts
rename to packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts
diff --git a/packages/sheets-formula/src/commands/operations/__tests__/insert-function.operation.spec.ts b/packages/sheets-formula-ui/src/commands/operations/__tests__/insert-function.operation.spec.ts
similarity index 99%
rename from packages/sheets-formula/src/commands/operations/__tests__/insert-function.operation.spec.ts
rename to packages/sheets-formula-ui/src/commands/operations/__tests__/insert-function.operation.spec.ts
index 8721876eb0..226c8222d5 100644
--- a/packages/sheets-formula/src/commands/operations/__tests__/insert-function.operation.spec.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/__tests__/insert-function.operation.spec.ts
@@ -21,10 +21,10 @@ import {
SetSelectionsOperation,
SheetsSelectionsService,
} from '@univerjs/sheets';
+import { InsertFunctionCommand } from '@univerjs/sheets-formula';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import type { Injector, Univer } from '@univerjs/core';
-import { InsertFunctionCommand } from '../../commands/insert-function.command';
+import type { Injector, Univer } from '@univerjs/core';
import {
InsertFunctionOperation,
isMultiRowsColumnsRange,
diff --git a/packages/sheets-formula/src/commands/operations/editor-formula.operation.ts b/packages/sheets-formula-ui/src/commands/operations/editor-formula.operation.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/editor-formula.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/editor-formula.operation.ts
index ef693daf0b..34f3ffe5bf 100644
--- a/packages/sheets-formula/src/commands/operations/editor-formula.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/editor-formula.operation.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IOperation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IOperation } from '@univerjs/core';
import type { DeviceInputEventType } from '@univerjs/engine-render';
import type { KeyCode, MetaKeys } from '@univerjs/ui';
diff --git a/packages/sheets-formula/src/commands/operations/help-function.operation.ts b/packages/sheets-formula-ui/src/commands/operations/help-function.operation.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/help-function.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/help-function.operation.ts
index 83a902f8b7..8de0e6e801 100644
--- a/packages/sheets-formula/src/commands/operations/help-function.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/help-function.operation.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import type { IAccessor, ICommand } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IAccessor, ICommand } from '@univerjs/core';
-import type { IHelpFunctionOperationParams } from '../../services/prompt.service';
import { IFormulaPromptService } from '../../services/prompt.service';
+import type { IHelpFunctionOperationParams } from '../../services/prompt.service';
export const HelpFunctionOperation: ICommand = {
id: 'formula-ui.operation.help-function',
diff --git a/packages/sheets-formula/src/commands/operations/insert-function.operation.ts b/packages/sheets-formula-ui/src/commands/operations/insert-function.operation.ts
similarity index 98%
rename from packages/sheets-formula/src/commands/operations/insert-function.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/insert-function.operation.ts
index aac7762928..5d0a5517c5 100644
--- a/packages/sheets-formula/src/commands/operations/insert-function.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/insert-function.operation.ts
@@ -33,9 +33,8 @@ import {
SheetsSelectionsService,
} from '@univerjs/sheets';
+import { type IInsertFunction, InsertFunctionCommand } from '@univerjs/sheets-formula';
import type { IAccessor, ICellData, ICommand, IRange, Nullable, ObjectMatrix } from '@univerjs/core';
-import { InsertFunctionCommand } from '../commands/insert-function.command';
-import type { IInsertFunction } from '../commands/insert-function.command';
export interface IInsertFunctionOperationParams {
/**
diff --git a/packages/sheets-formula/src/commands/operations/more-functions.operation.ts b/packages/sheets-formula-ui/src/commands/operations/more-functions.operation.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/more-functions.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/more-functions.operation.ts
index 83e93f8872..5ae32842e0 100644
--- a/packages/sheets-formula/src/commands/operations/more-functions.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/more-functions.operation.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import type { IAccessor, ICommand } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
import { ISidebarService } from '@univerjs/ui';
+import type { IAccessor, ICommand } from '@univerjs/core';
import { MORE_FUNCTIONS_COMPONENT } from '../../views/more-functions/interface';
diff --git a/packages/sheets-formula/src/commands/operations/reference-absolute.operation.ts b/packages/sheets-formula-ui/src/commands/operations/reference-absolute.operation.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/reference-absolute.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/reference-absolute.operation.ts
index 1ce473b17c..1966441dbd 100644
--- a/packages/sheets-formula/src/commands/operations/reference-absolute.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/reference-absolute.operation.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IAccessor, ICommand } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IAccessor, ICommand } from '@univerjs/core';
export const ReferenceAbsoluteOperation: ICommand = {
id: 'formula-ui.operation.change-ref-to-absolute',
diff --git a/packages/sheets-formula/src/commands/operations/search-function.operation.ts b/packages/sheets-formula-ui/src/commands/operations/search-function.operation.ts
similarity index 100%
rename from packages/sheets-formula/src/commands/operations/search-function.operation.ts
rename to packages/sheets-formula-ui/src/commands/operations/search-function.operation.ts
index 9ad0d78a3e..f72428b889 100644
--- a/packages/sheets-formula/src/commands/operations/search-function.operation.ts
+++ b/packages/sheets-formula-ui/src/commands/operations/search-function.operation.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import type { IAccessor, ICommand } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IAccessor, ICommand } from '@univerjs/core';
-import type { ISearchFunctionOperationParams } from '../../services/prompt.service';
import { IFormulaPromptService } from '../../services/prompt.service';
+import type { ISearchFunctionOperationParams } from '../../services/prompt.service';
export const SearchFunctionOperation: ICommand = {
id: 'formula-ui.operation.search-function',
diff --git a/packages/sheets-formula-ui/src/common/plugin-name.ts b/packages/sheets-formula-ui/src/common/plugin-name.ts
new file mode 100644
index 0000000000..0c3b288e7e
--- /dev/null
+++ b/packages/sheets-formula-ui/src/common/plugin-name.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const FORMULA_UI_PLUGIN_NAME = 'SHEET_FORMULA_UI_PLUGIN';
diff --git a/packages/sheets-formula-ui/src/common/prompt.ts b/packages/sheets-formula-ui/src/common/prompt.ts
new file mode 100644
index 0000000000..cd126d6cf8
--- /dev/null
+++ b/packages/sheets-formula-ui/src/common/prompt.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export const META_KEY_CTRL_AND_SHIFT = 'meta_key_ctrl_And_Shift';
diff --git a/packages/sheets-formula-ui/src/common/selection.ts b/packages/sheets-formula-ui/src/common/selection.ts
new file mode 100644
index 0000000000..e7adb25f31
--- /dev/null
+++ b/packages/sheets-formula-ui/src/common/selection.ts
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ColorKit, type ThemeService } from '@univerjs/core';
+import type { ISelectionStyle } from '@univerjs/sheets';
+
+export const FORMULA_REF_SELECTION_PLUGIN_NAME = 'formula_reference_selection_plugin_name';
+
+export function getFormulaRefSelectionStyle(themeService: ThemeService, refColor: string, id: string): ISelectionStyle {
+ const style = themeService.getCurrentTheme();
+ const fill = new ColorKit(refColor).setAlpha(0.05).toRgbString();
+ return {
+ id,
+ strokeWidth: 1,
+ stroke: refColor,
+ fill,
+ widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true },
+ widgetSize: 6,
+ widgetStrokeWidth: 1,
+ widgetStroke: style.colorWhite,
+ hasAutoFill: false,
+ hasRowHeader: false,
+ hasColumnHeader: false,
+ };
+}
diff --git a/packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/__tests__/create-command-test-bed.ts
rename to packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts
diff --git a/packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/__tests__/formula-auto-fill.controller.spec.ts
rename to packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts
diff --git a/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/formula-clipboard.controller.spec.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts
rename to packages/sheets-formula-ui/src/controllers/__tests__/formula-clipboard.controller.spec.ts
index 5404747e66..173fc1e6ef 100644
--- a/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts
+++ b/packages/sheets-formula-ui/src/controllers/__tests__/formula-clipboard.controller.spec.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import type { ICellData, Injector, Nullable, Univer } from '@univerjs/core';
import { ICommandService, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
import { FormulaDataModel, LexerTreeBuilder } from '@univerjs/engine-formula';
import { type ISetRangeValuesMutationParams, SetRangeValuesMutation } from '@univerjs/sheets';
-import type { ICellDataWithSpanInfo } from '@univerjs/sheets-ui';
import { COPY_TYPE, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME, SheetSelectionRenderService } from '@univerjs/sheets-ui';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import type { ICellData, Injector, Nullable, Univer } from '@univerjs/core';
+import type { ICellDataWithSpanInfo } from '@univerjs/sheets-ui';
import { getSetCellFormulaMutations } from '../formula-clipboard.controller';
import { createCommandTestBed } from './create-command-test-bed';
diff --git a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
similarity index 99%
rename from packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts
rename to packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
index 83120ea7f1..28c4bad415 100644
--- a/packages/sheets-formula/src/controllers/__tests__/update-formula.controller.spec.ts
+++ b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
@@ -17,11 +17,11 @@
import { CellValueType, Direction, ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE, RedoCommand, UndoCommand } from '@univerjs/core';
import { SetArrayFormulaDataMutation, SetFormulaDataMutation } from '@univerjs/engine-formula';
import { DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertColCommand, InsertColMutation, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, InsertRowMutation, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, RemoveColCommand, RemoveColMutation, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, SetRangeValuesCommand, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetNameCommand, SetWorksheetNameMutation, SheetsSelectionsService } from '@univerjs/sheets';
+import { UpdateFormulaController } from '@univerjs/sheets-formula';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import type { ICellData, Injector, IObjectMatrixPrimitiveType, IWorkbookData, Nullable, Univer } from '@univerjs/core';
+import type { ICellData, Injector, IObjectMatrixPrimitiveType, IWorkbookData, Nullable, Univer } from '@univerjs/core';
import type { IDeleteRangeMoveLeftCommandParams, IDeleteRangeMoveUpCommandParams, IInsertColCommandParams, IInsertRowCommandParams, IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, InsertRangeMoveDownCommandParams, InsertRangeMoveRightCommandParams, IRemoveRowColCommandParams, IRemoveSheetCommandParams, ISetRangeValuesCommandParams, ISetWorksheetNameCommandParams } from '@univerjs/sheets';
-import { UpdateFormulaController } from '../update-formula.controller';
import { createCommandTestBed } from './create-command-test-bed';
const TEST_WORKBOOK_DATA_DEMO = (): IWorkbookData => ({
diff --git a/packages/sheets-formula-ui/src/controllers/config.schema.ts b/packages/sheets-formula-ui/src/controllers/config.schema.ts
new file mode 100644
index 0000000000..43ab276198
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/config.schema.ts
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Ctor } from '@univerjs/core';
+import type { BaseFunction, IFunctionInfo, IFunctionNames } from '@univerjs/engine-formula';
+import type { MenuConfig } from '@univerjs/ui';
+
+/**
+ * Base configuration for the plugin.
+ */
+export const PLUGIN_CONFIG_KEY_BASE = 'sheets-formula.base.config';
+
+export const configSymbolBase = Symbol(PLUGIN_CONFIG_KEY_BASE);
+
+export interface IUniverSheetsFormulaBaseConfig {
+ menu?: MenuConfig;
+ notExecuteFormula?: boolean;
+ description?: IFunctionInfo[];
+ function?: Array<[Ctor<BaseFunction>, IFunctionNames]>;
+}
+
+export const defaultPluginBaseConfig: IUniverSheetsFormulaBaseConfig = {};
diff --git a/packages/sheets-formula/src/controllers/formula-alert-render.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-alert-render.controller.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/formula-alert-render.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-alert-render.controller.ts
diff --git a/packages/sheets-formula/src/controllers/formula-auto-fill.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/formula-auto-fill.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts
index d08ed6258f..43c92667cf 100644
--- a/packages/sheets-formula/src/controllers/formula-auto-fill.controller.ts
+++ b/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { ICellData, Nullable } from '@univerjs/core';
import {
Direction,
Disposable,
@@ -26,8 +25,9 @@ import {
Tools,
} from '@univerjs/core';
import { LexerTreeBuilder } from '@univerjs/engine-formula';
-import type { AutoFillService, IAutoFillRule, ICopyDataInTypeIndexInfo, ICopyDataPiece } from '@univerjs/sheets-ui';
import { APPLY_TYPE, DATA_TYPE, IAutoFillService } from '@univerjs/sheets-ui';
+import type { ICellData, Nullable } from '@univerjs/core';
+import type { AutoFillService, IAutoFillRule, ICopyDataInTypeIndexInfo, ICopyDataPiece } from '@univerjs/sheets-ui';
@OnLifecycle(LifecycleStages.Ready, FormulaAutoFillController)
export class FormulaAutoFillController extends Disposable {
diff --git a/packages/sheets-formula/src/controllers/formula-clipboard.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/formula-clipboard.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts
index 9164d042a1..0cb859a177 100644
--- a/packages/sheets-formula/src/controllers/formula-clipboard.controller.ts
+++ b/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { IAccessor, ICellData, IMutationInfo, Workbook } from '@univerjs/core';
import {
DEFAULT_EMPTY_DOCUMENT_VALUE,
Disposable,
@@ -30,9 +29,10 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { FormulaDataModel, LexerTreeBuilder } from '@univerjs/engine-formula';
-import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
import { COPY_TYPE, ISheetClipboardService, PREDEFINED_HOOK_NAME } from '@univerjs/sheets-ui';
+import type { IAccessor, ICellData, IMutationInfo, Workbook } from '@univerjs/core';
+import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';
import type { ICellDataWithSpanInfo, ICopyPastePayload, IDiscreteRange, ISheetClipboardHook, ISheetDiscreteRangeLocation } from '@univerjs/sheets-ui';
export const DEFAULT_PASTE_FORMULA = 'default-paste-formula';
diff --git a/packages/sheets-formula/src/controllers/formula-editor-show.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-editor-show.controller.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/formula-editor-show.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-editor-show.controller.ts
diff --git a/packages/sheets-formula-ui/src/controllers/formula-process.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-process.controller.ts
new file mode 100644
index 0000000000..cf732b1e13
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/formula-process.controller.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/packages/sheets-formula/src/controllers/formula-render.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-render.controller.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/formula-render.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-render.controller.ts
diff --git a/packages/sheets-formula/src/controllers/formula-ui.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts
similarity index 95%
rename from packages/sheets-formula/src/controllers/formula-ui.controller.ts
rename to packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts
index 3fbc580051..0e1a5d1f1c 100644
--- a/packages/sheets-formula/src/controllers/formula-ui.controller.ts
+++ b/packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts
@@ -15,12 +15,11 @@
*/
import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
+import { IRenderManagerService } from '@univerjs/engine-render';
import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
-import type { Dependency } from '@univerjs/core';
-import { IRenderManagerService } from '@univerjs/engine-render';
+import type { Dependency } from '@univerjs/core';
import { SheetOnlyPasteFormulaCommand } from '../commands/commands/formula-clipboard.command';
-import { InsertFunctionCommand } from '../commands/commands/insert-function.command';
import { SelectEditorFormulaOperation } from '../commands/operations/editor-formula.operation';
import { HelpFunctionOperation } from '../commands/operations/help-function.operation';
import { InsertFunctionOperation } from '../commands/operations/insert-function.operation';
@@ -30,7 +29,8 @@ import { SearchFunctionOperation } from '../commands/operations/search-function.
import { RenderFormulaPromptContent } from '../views/FormulaPromptContainer';
import { MORE_FUNCTIONS_COMPONENT } from '../views/more-functions/interface';
import { MoreFunctions } from '../views/more-functions/MoreFunctions';
-import { OtherFormulaMarkDirty } from '../commands/mutations/formula.mutation';
+import { FormulaEditorShowController } from './formula-editor-show.controller';
+import { menuSchema } from './menu.schema';
import {
ChangeRefToAbsoluteShortcut,
promptSelectionShortcutItem,
@@ -39,8 +39,6 @@ import {
promptSelectionShortcutItemShift,
singleEditorPromptSelectionShortcutItem,
} from './shortcuts/prompt.shortcut';
-import { FormulaEditorShowController } from './formula-editor-show.controller';
-import { menuSchema } from './menu.schema';
@OnLifecycle(LifecycleStages.Ready, FormulaUIController)
export class FormulaUIController extends Disposable {
@@ -72,7 +70,6 @@ export class FormulaUIController extends Disposable {
private _registerCommands(): void {
[
- InsertFunctionCommand,
SheetOnlyPasteFormulaCommand,
InsertFunctionOperation,
MoreFunctionsOperation,
@@ -80,7 +77,6 @@ export class FormulaUIController extends Disposable {
HelpFunctionOperation,
SelectEditorFormulaOperation,
ReferenceAbsoluteOperation,
- OtherFormulaMarkDirty,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
}
diff --git a/packages/sheets-formula/src/controllers/menu.schema.ts b/packages/sheets-formula-ui/src/controllers/menu.schema.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/menu.schema.ts
rename to packages/sheets-formula-ui/src/controllers/menu.schema.ts
index 3e09b17e49..b4bf30b56a 100644
--- a/packages/sheets-formula/src/controllers/menu.schema.ts
+++ b/packages/sheets-formula-ui/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { MenuSchemaType } from '@univerjs/ui';
-import { RibbonStartGroup } from '@univerjs/ui';
import { PASTE_SPECIAL_MENU_ID } from '@univerjs/sheets-ui';
+import { RibbonStartGroup } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
+import { SheetOnlyPasteFormulaCommand } from '../commands/commands/formula-clipboard.command';
import { InsertFunctionOperation } from '../commands/operations/insert-function.operation';
import { MoreFunctionsOperation } from '../commands/operations/more-functions.operation';
-import { SheetOnlyPasteFormulaCommand } from '../commands/commands/formula-clipboard.command';
import { InsertFunctionMenuItemFactory, MoreFunctionsMenuItemFactory, PasteFormulaMenuItemFactory } from './menu';
export const menuSchema: MenuSchemaType = {
diff --git a/packages/sheets-formula/src/controllers/menu.ts b/packages/sheets-formula-ui/src/controllers/menu.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/menu.ts
rename to packages/sheets-formula-ui/src/controllers/menu.ts
index acc9c614db..5c54d2c037 100644
--- a/packages/sheets-formula/src/controllers/menu.ts
+++ b/packages/sheets-formula-ui/src/controllers/menu.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import type { IAccessor, Workbook } from '@univerjs/core';
import { IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
+import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
import { getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
-import type { IMenuItem } from '@univerjs/ui';
import { getMenuHiddenObservable, IClipboardInterfaceService, MenuItemType } from '@univerjs/ui';
import { combineLatestWith, map, Observable, of, switchMap } from 'rxjs';
+import type { IAccessor, Workbook } from '@univerjs/core';
-import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';
+import type { IMenuItem } from '@univerjs/ui';
import { SheetOnlyPasteFormulaCommand } from '../commands/commands/formula-clipboard.command';
import { InsertFunctionOperation } from '../commands/operations/insert-function.operation';
import { MoreFunctionsOperation } from '../commands/operations/more-functions.operation';
diff --git a/packages/sheets-formula/src/controllers/prompt.controller.ts b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts
similarity index 99%
rename from packages/sheets-formula/src/controllers/prompt.controller.ts
rename to packages/sheets-formula-ui/src/controllers/prompt.controller.ts
index 800df076ce..d9f7803cc6 100644
--- a/packages/sheets-formula/src/controllers/prompt.controller.ts
+++ b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts
@@ -86,6 +86,8 @@ import {
setEndForRange,
SheetsSelectionsService,
} from '@univerjs/sheets';
+import { IDescriptionService } from '@univerjs/sheets-formula';
+
import {
ExpandSelectionCommand,
getEditorObject,
@@ -103,7 +105,6 @@ import { ReferenceAbsoluteOperation } from '../commands/operations/reference-abs
import { SearchFunctionOperation } from '../commands/operations/search-function.operation';
import { META_KEY_CTRL_AND_SHIFT } from '../common/prompt';
import { getFormulaRefSelectionStyle } from '../common/selection';
-import { IDescriptionService } from '../services/description.service';
import { IFormulaPromptService } from '../services/prompt.service';
import { RefSelectionsRenderService } from '../services/render-services/ref-selections.render-service';
diff --git a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts b/packages/sheets-formula-ui/src/controllers/shortcuts/prompt.shortcut.ts
similarity index 100%
rename from packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
rename to packages/sheets-formula-ui/src/controllers/shortcuts/prompt.shortcut.ts
index bb0835020f..9e3fe812e4 100644
--- a/packages/sheets-formula/src/controllers/shortcuts/prompt.shortcut.ts
+++ b/packages/sheets-formula-ui/src/controllers/shortcuts/prompt.shortcut.ts
@@ -16,8 +16,8 @@
import { DeviceInputEventType } from '@univerjs/engine-render';
import { whenFormulaEditorActivated } from '@univerjs/sheets-ui';
-import type { IShortcutItem } from '@univerjs/ui';
import { KeyCode, MetaKeys } from '@univerjs/ui';
+import type { IShortcutItem } from '@univerjs/ui';
import { SelectEditorFormulaOperation } from '../../commands/operations/editor-formula.operation';
import { ReferenceAbsoluteOperation } from '../../commands/operations/reference-absolute.operation';
diff --git a/packages/sheets-formula-ui/src/controllers/utils/__tests__/offset-formula-data.spec.ts b/packages/sheets-formula-ui/src/controllers/utils/__tests__/offset-formula-data.spec.ts
new file mode 100644
index 0000000000..79769873c6
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/__tests__/offset-formula-data.spec.ts
@@ -0,0 +1,133 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { removeFormulaData } from '../offset-formula-data';
+
+describe('Utils offset formula data test', () => {
+ describe('function removeFormulaData, remove sheet', () => {
+ it('remove data', () => {
+ const unitId = 'workbook-01';
+ const sheetId = 'sheet-0011';
+ const formulaData = {
+ [unitId]: {
+ [sheetId]: {
+ 0: {
+ 0: {
+ f: '=SUM(A1)',
+ },
+ },
+ },
+ },
+ };
+
+ removeFormulaData(formulaData, unitId, sheetId);
+
+ expect(formulaData).toStrictEqual({
+ [unitId]: {},
+ });
+ });
+
+ it('remove blank worksheet', () => {
+ const unitId = 'workbook-01';
+ const sheetId = 'sheet-0011';
+ const formulaData = {
+ [unitId]: {
+ [sheetId]: {},
+ },
+ };
+
+ removeFormulaData(formulaData, unitId, sheetId);
+
+ expect(formulaData).toStrictEqual({
+ [unitId]: {},
+ });
+ });
+
+ it('remove blank workbook', () => {
+ const unitId = 'workbook-01';
+ const sheetId = 'sheet-0011';
+ const formulaData = {
+ [unitId]: {},
+ };
+
+ removeFormulaData(formulaData, unitId, sheetId);
+
+ expect(formulaData).toStrictEqual({
+ [unitId]: {},
+ });
+ });
+ it('remove blank object', () => {
+ const unitId = 'workbook-01';
+ const sheetId = 'sheet-0011';
+ const formulaData = {};
+
+ removeFormulaData(formulaData, unitId, sheetId);
+
+ expect(formulaData).toStrictEqual({});
+ });
+ });
+
+ describe('function removeUnitFormulaData, remove unit', () => {
+ it('remove data', () => {
+ const unitId = 'workbook-01';
+ const sheetId = 'sheet-0011';
+ const formulaData = {
+ [unitId]: {
+ [sheetId]: {
+ 0: {
+ 0: {
+ f: '=SUM(A1)',
+ },
+ },
+ },
+ },
+ 'unit-2': {
+ },
+ };
+
+ removeFormulaData(formulaData, unitId);
+
+ expect(formulaData).toStrictEqual({
+ 'unit-2': {},
+ });
+ });
+
+ it('remove blank workbook', () => {
+ const unitId = 'workbook-01';
+ const formulaData = {
+ [unitId]: {},
+ 'unit-2': {},
+ };
+
+ removeFormulaData(formulaData, unitId);
+
+ expect(formulaData).toStrictEqual({
+ 'unit-2': {},
+ });
+ });
+
+ it('remove blank object', () => {
+ const unitId = 'workbook-01';
+ const formulaData = {};
+
+ removeFormulaData(formulaData, unitId);
+
+ expect(formulaData).toStrictEqual({});
+ });
+ });
+});
diff --git a/packages/sheets-formula-ui/src/controllers/utils/__tests__/ref-range-formula.spec.ts b/packages/sheets-formula-ui/src/controllers/utils/__tests__/ref-range-formula.spec.ts
new file mode 100644
index 0000000000..37c07d08c2
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/__tests__/ref-range-formula.spec.ts
@@ -0,0 +1,145 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import type { IFormulaDataItem } from '@univerjs/engine-formula';
+import { formulaDataItemToCellData, formulaDataToCellData, isFormulaDataItem } from '../ref-range-formula';
+
+describe('Ref range formula test', () => {
+ describe('Util function', () => {
+ it('Function formulaDataItemToCellData', () => {
+ let formulaDataItem: IFormulaDataItem = {
+ f: '=SUM(1)',
+ };
+
+ let result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({
+ f: '=SUM(1)',
+ si: null,
+ });
+
+ formulaDataItem = {
+ f: '',
+ si: 'id1',
+ };
+
+ result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({
+ si: 'id1',
+ f: null,
+ });
+
+ formulaDataItem = {
+ f: '=SUM(1)',
+ si: 'id1',
+ };
+
+ result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({
+ f: '=SUM(1)',
+ si: 'id1',
+ });
+
+ formulaDataItem = {
+ f: '=SUM(1)',
+ si: 'id1',
+ x: 0,
+ y: 0,
+ };
+
+ result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({
+ f: '=SUM(1)',
+ si: 'id1',
+ });
+
+ formulaDataItem = {
+ f: '=SUM(1)',
+ si: 'id1',
+ x: 0,
+ y: 1,
+ };
+
+ result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({
+ si: 'id1',
+ f: null,
+ });
+
+ formulaDataItem = {
+ f: '',
+ si: '',
+ x: 0,
+ y: 1,
+ };
+
+ result = formulaDataItemToCellData(formulaDataItem);
+
+ expect(result).toStrictEqual({ f: null, si: null });
+ });
+
+ it('Function formulaDataToCellData', () => {
+ const formulaData = {
+ 0: {
+ 0: {
+ f: '=SUM(1)',
+ },
+ 1: {
+ f: '',
+ si: 'id1',
+ },
+ 2: {
+ f: '=SUM(1)',
+ si: 'id2',
+ x: 0,
+ y: 1,
+ },
+ },
+ };
+
+ const cellData = {
+ 0: {
+ 0: {
+ f: '=SUM(1)',
+ si: null,
+ },
+ 1: {
+ f: null,
+ si: 'id1',
+ },
+ 2: {
+ f: null,
+ si: 'id2',
+ },
+ },
+ };
+ expect(formulaDataToCellData(formulaData)).toStrictEqual(cellData);
+ });
+
+ it('isFormulaDataItem', () => {
+ expect(isFormulaDataItem({ f: '=SUM(1)' })).toBeTruthy();
+ expect(isFormulaDataItem({ f: '' })).toBeFalsy();
+ expect(isFormulaDataItem({ f: '', si: 'id1' })).toBeTruthy();
+ expect(isFormulaDataItem({ f: '', si: undefined })).toBeFalsy();
+ });
+ });
+});
diff --git a/packages/sheets-formula-ui/src/controllers/utils/__tests__/utils.spec.ts b/packages/sheets-formula-ui/src/controllers/utils/__tests__/utils.spec.ts
new file mode 100644
index 0000000000..24852a4944
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/__tests__/utils.spec.ts
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { CellValueType } from '@univerjs/core';
+
+import { ErrorType } from '@univerjs/engine-formula';
+import { describe, expect, it } from 'vitest';
+import { extractFormulaError, extractFormulaNumber } from '../utils';
+
+describe('Test utils', () => {
+ it('Function extractFormulaError', () => {
+ expect(extractFormulaError({ v: ErrorType.DIV_BY_ZERO, f: '=1/0' })).toBe(ErrorType.DIV_BY_ZERO);
+ expect(extractFormulaError({ v: ErrorType.NAME, f: '=S' })).toBe(ErrorType.NAME);
+ expect(extractFormulaError({ v: ErrorType.VALUE, f: '=SUM(A1)' })).toBe(ErrorType.VALUE);
+ expect(extractFormulaError({ v: ErrorType.NUM, f: '=SUM(A1)' })).toBe(ErrorType.NUM);
+ expect(extractFormulaError({ v: ErrorType.NA, f: '=SUM(A1)' })).toBe(ErrorType.NA);
+ expect(extractFormulaError({ v: ErrorType.CYCLE, f: '=SUM(A1)' })).toBe(ErrorType.CYCLE);
+ expect(extractFormulaError({ v: ErrorType.REF, f: '=SUM(A1)' })).toBe(ErrorType.REF);
+ expect(extractFormulaError({ v: ErrorType.SPILL, f: '=SUM(A1)' })).toBe(ErrorType.SPILL);
+ expect(extractFormulaError({ v: ErrorType.CALC, f: '=SUM(A1)' })).toBe(ErrorType.CALC);
+ expect(extractFormulaError({ v: ErrorType.ERROR, f: '=SUM(A1)' })).toBe(ErrorType.ERROR);
+ expect(extractFormulaError({ v: ErrorType.CONNECT, f: '=SUM(A1)' })).toBe(ErrorType.CONNECT);
+
+ expect(extractFormulaError({ v: ErrorType.NULL, f: '=SUM(A1)' })).toBe(ErrorType.NULL);
+ expect(extractFormulaError({ v: ErrorType.NULL, f: '=SUM(A1)', si: 'id1' })).toBe(ErrorType.NULL);
+ expect(extractFormulaError({ v: ErrorType.NULL, si: 'id1' })).toBe(ErrorType.NULL);
+ expect(extractFormulaError({ v: ErrorType.NULL })).toBeNull();
+
+ expect(extractFormulaError({ f: '=SUM(1)' })).toBeNull();
+ expect(extractFormulaError({ si: 'id1' })).toBeNull();
+ expect(extractFormulaError({ p: null })).toBeNull();
+ expect(extractFormulaError({ v: 'test' })).toBeNull();
+ expect(extractFormulaError({ v: 1 })).toBeNull();
+ expect(extractFormulaError({})).toBeNull();
+ expect(extractFormulaError(null)).toBeNull();
+ expect(extractFormulaError(undefined)).toBeNull();
+ });
+
+ it('Function extractFormulaNumber', () => {
+ const v = 0.07 / 0.1;
+ expect(extractFormulaNumber({ v })).toBeNull();
+ expect(extractFormulaNumber({ v, f: '=SUM(A1)' })).toBeNull();
+ expect(extractFormulaNumber({ v, si: 'id1', f: '=SUM(A1)', t: CellValueType.NUMBER })).toBe(0.7);
+ });
+});
diff --git a/packages/sheets-formula-ui/src/controllers/utils/offset-formula-data.ts b/packages/sheets-formula-ui/src/controllers/utils/offset-formula-data.ts
new file mode 100644
index 0000000000..66680a9e79
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/offset-formula-data.ts
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { IRange } from '@univerjs/core';
+import type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData } from '@univerjs/engine-formula';
+
+export interface IRefRangeWithPosition {
+ row: number;
+ column: number;
+ range: IRange;
+}
+
+export function checkFormulaDataNull(formulaData: IFormulaData, unitId: string, sheetId: string) {
+ if (formulaData == null || formulaData[unitId] == null || formulaData[unitId]?.[sheetId] == null) {
+ return true;
+ }
+
+ return false;
+}
+
+export function removeFormulaData(formulaData: IFormulaData | IArrayFormulaRangeType | IArrayFormulaUnitCellType, unitId: string, sheetId?: string) {
+ if (sheetId) {
+ if (formulaData && formulaData[unitId] && formulaData[unitId]?.[sheetId]) {
+ delete formulaData[unitId]![sheetId];
+ return {
+ [unitId]: {
+ [sheetId]: null,
+ },
+ };
+ }
+ } else {
+ if (formulaData && formulaData[unitId]) {
+ delete formulaData[unitId];
+ return {
+ [unitId]: null,
+ };
+ }
+ }
+}
diff --git a/packages/sheets-formula-ui/src/controllers/utils/ref-range-formula.ts b/packages/sheets-formula-ui/src/controllers/utils/ref-range-formula.ts
new file mode 100644
index 0000000000..2a85859634
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/ref-range-formula.ts
@@ -0,0 +1,583 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { cellToRange, Direction, isFormulaId, isFormulaString, ObjectMatrix } from '@univerjs/core';
+import { EffectRefRangId, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleIRemoveCol, handleIRemoveRow, handleMoveCols, handleMoveRange, handleMoveRows, runRefRangeMutations, SetRangeValuesMutation } from '@univerjs/sheets';
+import type { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
+import type { IFormulaData, IFormulaDataItem, IRangeChange } from '@univerjs/engine-formula';
+import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';
+import { checkFormulaDataNull } from './offset-formula-data';
+
+export enum FormulaReferenceMoveType {
+ MoveRange, // range
+ MoveRows, // move rows
+ MoveCols, // move columns
+ InsertRow, // row
+ InsertColumn, // column
+ RemoveRow, // row
+ RemoveColumn, // column
+ DeleteMoveLeft, // range
+ DeleteMoveUp, // range
+ InsertMoveDown, // range
+ InsertMoveRight, // range
+ SetName,
+ RemoveSheet,
+}
+
+export interface IFormulaReferenceMoveParam {
+ type: FormulaReferenceMoveType;
+ unitId: string;
+ sheetId: string;
+ range?: IRange;
+ from?: IRange;
+ to?: IRange;
+ sheetName?: string;
+}
+
+export function getFormulaReferenceMoveUndoRedo(oldFormulaData: IFormulaData,
+ newFormulaData: IFormulaData,
+ formulaReferenceMoveParam: IFormulaReferenceMoveParam) {
+ const { type } = formulaReferenceMoveParam;
+
+ if (type === FormulaReferenceMoveType.SetName || type === FormulaReferenceMoveType.RemoveSheet) {
+ return getFormulaReferenceSheet(oldFormulaData, newFormulaData);
+ } else {
+ return getFormulaReferenceRange(oldFormulaData, newFormulaData, formulaReferenceMoveParam);
+ }
+}
+
+export function getFormulaReferenceSheet(oldFormulaData: IFormulaData,
+ newFormulaData: IFormulaData) {
+ const undos: IMutationInfo[] = [];
+ const redos: IMutationInfo[] = [];
+
+ Object.keys(newFormulaData).forEach((unitId) => {
+ const newSheetData = newFormulaData[unitId];
+ const oldSheetData = oldFormulaData[unitId];
+
+ if (newSheetData == null) {
+ return true;
+ }
+
+ if (oldSheetData == null) {
+ return true;
+ }
+
+ Object.keys(newSheetData).forEach((subUnitId) => {
+ const newSheetFormula = new ObjectMatrix(newSheetData[subUnitId] || {});
+ const oldSheetFormula = new ObjectMatrix(oldSheetData[subUnitId] || {});
+ const redoFormulaMatrix = new ObjectMatrix<Nullable<ICellData>>();
+ const undoFormulaMatrix = new ObjectMatrix<Nullable<ICellData>>();
+
+ newSheetFormula.forValue((r, c, cell) => {
+ if (cell == null) {
+ return true;
+ }
+ const newValue = formulaDataItemToCellData(cell);
+
+ if (newValue === null) {
+ return;
+ }
+
+ redoFormulaMatrix.setValue(r, c, newValue);
+ undoFormulaMatrix.setValue(r, c, oldSheetFormula.getValue(r, c));
+ });
+
+ if (redoFormulaMatrix.getSizeOf() === 0) {
+ return;
+ }
+
+ const redoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ subUnitId,
+ unitId,
+ cellValue: redoFormulaMatrix.clone(),
+ };
+
+ const redoMutation = {
+ id: SetRangeValuesMutation.id,
+ params: redoSetRangeValuesMutationParams,
+ };
+
+ redos.push(redoMutation);
+
+ const undoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ subUnitId,
+ unitId,
+ cellValue: undoFormulaMatrix.clone(),
+ };
+
+ const undoMutation = {
+ id: SetRangeValuesMutation.id,
+ params: undoSetRangeValuesMutationParams,
+ };
+
+ undos.push(undoMutation);
+ });
+ });
+
+ return {
+ undos,
+ redos,
+ };
+}
+
+export function getFormulaReferenceRange(oldFormulaData: IFormulaData,
+ newFormulaData: IFormulaData,
+ formulaReferenceMoveParam: IFormulaReferenceMoveParam) {
+ const { sheetId: subUnitId, unitId } = formulaReferenceMoveParam;
+ const { redoFormulaData, undoFormulaData } = refRangeFormula(oldFormulaData, newFormulaData, formulaReferenceMoveParam);
+
+ const redos: IMutationInfo[] = [];
+ const undos: IMutationInfo[] = [];
+
+ if (Object.keys(redoFormulaData).length !== 0) {
+ const redoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ subUnitId,
+ unitId,
+ cellValue: redoFormulaData,
+ };
+
+ const redoMutation = {
+ id: SetRangeValuesMutation.id,
+ params: redoSetRangeValuesMutationParams,
+ };
+
+ redos.push(redoMutation);
+ }
+
+ if (Object.keys(undoFormulaData).length !== 0) {
+ const undoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = {
+ subUnitId,
+ unitId,
+ cellValue: undoFormulaData,
+ };
+
+ const undoMutation = {
+ id: SetRangeValuesMutation.id,
+ params: undoSetRangeValuesMutationParams,
+ };
+
+ undos.push(undoMutation);
+ }
+
+ return {
+ undos,
+ redos,
+ };
+}
+
+/**
+ * For different Command operations, it may be necessary to perform traversal in reverse or in forward order, so first determine the type of Command and then perform traversal.
+ * @param oldFormulaData
+ * @param newFormulaData
+ * @param formulaReferenceMoveParam
+ * @returns
+ */
+export function refRangeFormula(oldFormulaData: IFormulaData,
+ newFormulaData: IFormulaData,
+ formulaReferenceMoveParam: IFormulaReferenceMoveParam) {
+ let redoFormulaData: IObjectMatrixPrimitiveType<Nullable<ICellData>> = {};
+ let undoFormulaData: IObjectMatrixPrimitiveType<Nullable<ICellData>> = {};
+
+ const { type, unitId, sheetId, range, from, to } = formulaReferenceMoveParam;
+
+ if (checkFormulaDataNull(oldFormulaData, unitId, sheetId)) {
+ return {
+ redoFormulaData,
+ undoFormulaData,
+ };
+ }
+
+ const currentOldFormulaData = oldFormulaData[unitId]![sheetId];
+ const currentNewFormulaData = newFormulaData[unitId]![sheetId];
+
+ const oldFormulaMatrix = new ObjectMatrix(currentOldFormulaData || {});
+ const newFormulaMatrix = new ObjectMatrix(currentNewFormulaData || {});
+
+ const rangeList = processFormulaChanges(oldFormulaMatrix, type, from, to, range);
+
+ redoFormulaData = getRedoFormulaData(rangeList, oldFormulaMatrix, newFormulaMatrix);
+ undoFormulaData = getUndoFormulaData(rangeList, oldFormulaMatrix);
+
+ return {
+ redoFormulaData,
+ undoFormulaData,
+ };
+}
+
+function processFormulaChanges(oldFormulaMatrix: ObjectMatrix<Nullable<IFormulaDataItem>>, type: FormulaReferenceMoveType, from: Nullable<IRange>, to: Nullable<IRange>, range: Nullable<IRange>) {
+ // When undoing and redoing, the traversal order may be different. Record the range list of all single formula offsets, and then retrieve the traversal as needed.
+ const rangeList: IRangeChange[] = [];
+
+ oldFormulaMatrix.forValue((row, column, cell) => {
+ // Offset is only needed when there is a formula
+ if (cell == null || !isFormulaDataItem(cell)) return true;
+
+ const oldCell = cellToRange(row, column);
+ let newCell = null;
+ let isReverse = false;
+
+ // Handle moves
+ if ([FormulaReferenceMoveType.MoveRange, FormulaReferenceMoveType.MoveRows, FormulaReferenceMoveType.MoveCols].includes(type)) {
+ newCell = handleMove(type, from, to, oldCell);
+ } else if (range !== undefined && range !== null) { // Handle inserts and deletes
+ const result = handleInsertDelete(type, range, oldCell);
+ // When removing a cell containing a formula, newCell is null, but the formula value of oldCell is required when undoing it, newCell can be null
+ newCell = result.newCell;
+ isReverse = result.isReverse;
+ }
+
+ // Don't intercept newCell null here
+
+ // Note: The formula may only update the reference and not offset the position. The situation where the position is not shifted cannot be intercepted here.
+ isReverse ? rangeList.unshift({ oldCell, newCell }) : rangeList.push({ oldCell, newCell });
+ });
+
+ return rangeList;
+}
+
+function handleMove(type: FormulaReferenceMoveType, from: Nullable<IRange>, to: Nullable<IRange>, oldCell: IRange) {
+ if (from == null || to == null) {
+ return null;
+ }
+
+ switch (type) {
+ case FormulaReferenceMoveType.MoveRange:
+
+ return handleRefMoveRange(from, to, oldCell);
+ case FormulaReferenceMoveType.MoveRows:
+
+ return handleRefMoveRows(from, to, oldCell);
+ case FormulaReferenceMoveType.MoveCols:
+
+ return handleRefMoveCols(from, to, oldCell);
+ default:
+ return null;
+ }
+}
+
+function handleInsertDelete(type: FormulaReferenceMoveType, range: IRange, oldCell: IRange) {
+ let newCell: IRange | null = null;
+ let isReverse = false;
+
+ switch (type) {
+ case FormulaReferenceMoveType.InsertRow:
+ newCell = handleRefInsertRow(range, oldCell);
+ isReverse = true;
+ break;
+ case FormulaReferenceMoveType.InsertColumn:
+ newCell = handleRefInsertCol(range, oldCell);
+ isReverse = true;
+ break;
+ case FormulaReferenceMoveType.RemoveRow:
+ newCell = handleRefRemoveRow(range, oldCell);
+ break;
+ case FormulaReferenceMoveType.RemoveColumn:
+ newCell = handleRefRemoveCol(range, oldCell);
+ break;
+ case FormulaReferenceMoveType.DeleteMoveLeft:
+ newCell = handleRefDeleteMoveLeft(range, oldCell);
+ break;
+ case FormulaReferenceMoveType.DeleteMoveUp:
+ newCell = handleRefDeleteMoveUp(range, oldCell);
+ break;
+ case FormulaReferenceMoveType.InsertMoveDown:
+ newCell = handleRefInsertMoveDown(range, oldCell);
+ isReverse = true;
+ break;
+ case FormulaReferenceMoveType.InsertMoveRight:
+ newCell = handleRefInsertMoveRight(range, oldCell);
+ isReverse = true;
+ break;
+ default:
+ break;
+ }
+
+ return { newCell, isReverse };
+}
+
+function handleRefMoveRange(from: IRange, to: IRange, oldCell: IRange) {
+ const operators = handleMoveRange(
+ {
+ id: EffectRefRangId.MoveRangeCommandId,
+ params: { toRange: to, fromRange: from },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefMoveRows(from: IRange, to: IRange, oldCell: IRange) {
+ const operators = handleMoveRows(
+ {
+ id: EffectRefRangId.MoveRowsCommandId,
+ params: { toRange: to, fromRange: from },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefMoveCols(from: IRange, to: IRange, oldCell: IRange) {
+ const operators = handleMoveCols(
+ {
+ id: EffectRefRangId.MoveColsCommandId,
+ params: { toRange: to, fromRange: from },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefInsertRow(range: IRange, oldCell: IRange) {
+ const operators = handleInsertRow(
+ {
+ id: EffectRefRangId.InsertRowCommandId,
+ params: { range, unitId: '', subUnitId: '', direction: Direction.DOWN },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefInsertCol(range: IRange, oldCell: IRange) {
+ const operators = handleInsertCol(
+ {
+ id: EffectRefRangId.InsertColCommandId,
+ params: { range, unitId: '', subUnitId: '', direction: Direction.RIGHT },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefRemoveRow(range: IRange, oldCell: IRange) {
+ const operators = handleIRemoveRow(
+ {
+ id: EffectRefRangId.RemoveRowCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefRemoveCol(range: IRange, oldCell: IRange) {
+ const operators = handleIRemoveCol(
+ {
+ id: EffectRefRangId.RemoveColCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefDeleteMoveLeft(range: IRange, oldCell: IRange) {
+ const operators = handleDeleteRangeMoveLeft(
+ {
+ id: EffectRefRangId.DeleteRangeMoveLeftCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefDeleteMoveUp(range: IRange, oldCell: IRange) {
+ const operators = handleDeleteRangeMoveUp(
+ {
+ id: EffectRefRangId.DeleteRangeMoveUpCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefInsertMoveDown(range: IRange, oldCell: IRange) {
+ const operators = handleInsertRangeMoveDown(
+ {
+ id: EffectRefRangId.InsertRangeMoveDownCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+function handleRefInsertMoveRight(range: IRange, oldCell: IRange) {
+ const operators = handleInsertRangeMoveRight(
+ {
+ id: EffectRefRangId.InsertRangeMoveRightCommandId,
+ params: { range },
+ },
+ oldCell
+ );
+
+ return runRefRangeMutations(operators, oldCell);
+}
+
+/**
+ * Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
+ * @param rangeList
+ * @param oldFormulaData
+ * @param newFormulaData
+ */
+function getRedoFormulaData(rangeList: IRangeChange[], oldFormulaMatrix: ObjectMatrix<Nullable<IFormulaDataItem>>, newFormulaMatrix: ObjectMatrix<Nullable<IFormulaDataItem>>) {
+ const redoFormulaData = new ObjectMatrix<Nullable<ICellData>>({});
+
+ rangeList.forEach((item) => {
+ const { oldCell, newCell } = item;
+
+ const { startRow: oldStartRow, startColumn: oldStartColumn } = oldCell;
+
+ const newFormula = newFormulaMatrix.getValue(oldStartRow, oldStartColumn) || oldFormulaMatrix.getValue(oldStartRow, oldStartColumn);
+ // Use the formula result value to update the data to ensure accuracy, otherwise the new formula cannot be inferred from #REF
+ const newValue = formulaDataItemToCellData(newFormula);
+
+ redoFormulaData.setValue(oldStartRow, oldStartColumn, { f: null, si: null });
+
+ if (newCell) {
+ const { startRow: newStartRow, startColumn: newStartColumn } = newCell;
+ redoFormulaData.setValue(newStartRow, newStartColumn, newValue);
+ }
+ });
+
+ return redoFormulaData.clone();
+}
+
+/**
+ * The old position on the match saves the old value, and the new position delete value(for formulaData)
+ * @param rangeList
+ * @param oldFormulaData
+ * @param newFormulaData
+ */
+function getUndoFormulaData(rangeList: IRangeChange[], oldFormulaMatrix: ObjectMatrix<Nullable<IFormulaDataItem>>) {
+ const undoFormulaData = new ObjectMatrix<Nullable<ICellData>>({});
+
+ // Maintaining the correct assignment order prevents overwriting data
+ rangeList.reverse().forEach((item) => {
+ const { oldCell, newCell } = item;
+
+ const { startRow: oldStartRow, startColumn: oldStartColumn } = oldCell;
+
+ const oldFormula = oldFormulaMatrix.getValue(oldStartRow, oldStartColumn);
+ const oldValue = formulaDataItemToCellData(oldFormula);
+
+ if (newCell) {
+ const { startRow: newStartRow, startColumn: newStartColumn } = newCell;
+ undoFormulaData.setValue(newStartRow, newStartColumn, { f: null, si: null });
+ }
+
+ undoFormulaData.setValue(oldStartRow, oldStartColumn, oldValue);
+ });
+
+ return undoFormulaData.clone();
+}
+
+/**
+ * Transfer the formulaDataItem to the cellData
+ * ┌────────────────────────────────┬─────────────────┐
+ * │ IFormulaDataItem │ ICellData │
+ * ├──────────────────┬─────┬───┬───┼───────────┬─────┤
+ * │ f │ si │ x │ y │ f │ si │
+ * ├──────────────────┼─────┼───┼───┼───────────┼─────┤
+ * │ =SUM(1) │ │ │ │ =SUM(1) │ │
+ * │ │ id1 │ │ │ │ id1 │
+ * │ =SUM(1) │ id1 │ │ │ =SUM(1) │ id1 │
+ * │ =SUM(1) │ id1 │ 0 │ 0 │ =SUM(1) │ id1 │
+ * │ =SUM(1) │ id1 │ 0 │ 1 │ │ id1 │
+ * └──────────────────┴─────┴───┴───┴───────────┴─────┘
+ */
+export function formulaDataItemToCellData(formulaDataItem: Nullable<IFormulaDataItem>): Nullable<ICellData> {
+ if (formulaDataItem == null) {
+ return;
+ }
+ const { f, si, x = 0, y = 0 } = formulaDataItem;
+ const checkFormulaString = isFormulaString(f);
+ const checkFormulaId = isFormulaId(si);
+
+ if (!checkFormulaString && !checkFormulaId) {
+ return {
+ f: null,
+ si: null,
+ };
+ }
+
+ const cellData: ICellData = {};
+
+ if (checkFormulaId) {
+ cellData.si = si;
+ }
+
+ if (checkFormulaString && x === 0 && y === 0) {
+ cellData.f = f;
+ }
+
+ if (cellData.f === undefined) {
+ cellData.f = null;
+ }
+
+ if (cellData.si === undefined) {
+ cellData.si = null;
+ }
+
+ return cellData;
+}
+
+/**
+ * Convert formulaData to cellData
+ * @param formulaData
+ * @returns
+ */
+export function formulaDataToCellData(formulaData: IObjectMatrixPrimitiveType<IFormulaDataItem | null>
+): IObjectMatrixPrimitiveType<Nullable<ICellData>> {
+ const cellData = new ObjectMatrix<Nullable<ICellData>>({});
+ const formulaDataMatrix = new ObjectMatrix(formulaData);
+
+ formulaDataMatrix.forValue((r, c, formulaDataItem) => {
+ const cellDataItem = formulaDataItemToCellData(formulaDataItem);
+ cellData.setValue(r, c, cellDataItem);
+ });
+
+ return cellData.clone();
+}
+
+export function isFormulaDataItem(cell: IFormulaDataItem) {
+ const formulaString = cell?.f || '';
+ const formulaId = cell?.si || '';
+
+ const checkFormulaString = isFormulaString(formulaString);
+ const checkFormulaId = isFormulaId(formulaId);
+
+ if (checkFormulaString || checkFormulaId) {
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/packages/sheets-formula-ui/src/controllers/utils/utils.ts b/packages/sheets-formula-ui/src/controllers/utils/utils.ts
new file mode 100644
index 0000000000..272d240120
--- /dev/null
+++ b/packages/sheets-formula-ui/src/controllers/utils/utils.ts
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { CellValueType, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, isFormulaId, isFormulaString } from '@univerjs/core';
+import { ERROR_TYPE_SET, stripErrorMargin } from '@univerjs/engine-formula';
+import type { ICellData, IContextService, Nullable } from '@univerjs/core';
+import type { ErrorType } from '@univerjs/engine-formula';
+
+export function whenEditorStandalone(contextService: IContextService) {
+ return (
+ contextService.getContextValue(FOCUSING_DOC) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
+ contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)
+ );
+}
+
+/**
+ * Extract the formula error from the cell
+ * @param cell
+ * @returns
+ */
+export function extractFormulaError(cell: Nullable<ICellData>) {
+ // Must contain a formula
+ if ((isFormulaString(cell?.f) || isFormulaId(cell?.si)) && typeof cell?.v === 'string' && ERROR_TYPE_SET.has(cell.v as ErrorType)) {
+ return cell.v as ErrorType;
+ }
+
+ return null;
+}
+
+/**
+ * Extract the formula number from the cell, handle the precision issue
+ * @param cell
+ * @returns
+ */
+export function extractFormulaNumber(cell: Nullable<ICellData>) {
+ if ((isFormulaString(cell?.f) || isFormulaId(cell?.si)) && cell?.t === CellValueType.NUMBER && typeof cell?.v === 'number') {
+ return stripErrorMargin(cell.v);
+ }
+ return null;
+}
diff --git a/packages/sheets-formula-ui/src/index.ts b/packages/sheets-formula-ui/src/index.ts
new file mode 100644
index 0000000000..b8a38ff903
--- /dev/null
+++ b/packages/sheets-formula-ui/src/index.ts
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export { SheetOnlyPasteFormulaCommand } from './commands/commands/formula-clipboard.command';
+export { SelectEditorFormulaOperation } from './commands/operations/editor-formula.operation';
+export { HelpFunctionOperation } from './commands/operations/help-function.operation';
+export { InsertFunctionOperation } from './commands/operations/insert-function.operation';
+export { MoreFunctionsOperation } from './commands/operations/more-functions.operation';
+export { ReferenceAbsoluteOperation } from './commands/operations/reference-absolute.operation';
+export { SearchFunctionOperation } from './commands/operations/search-function.operation';
+
+// #region - all commands
+
+export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
+export { FORMULA_PROMPT_ACTIVATED } from './services/prompt.service';
+export { UniverSheetsFormulaUIPlugin } from './sheets-formula-ui.plugin';
+
+// #endregion
diff --git a/packages/sheets-formula/src/locale/en-US.ts b/packages/sheets-formula-ui/src/locale/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/en-US.ts
rename to packages/sheets-formula-ui/src/locale/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/array/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/array/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/array/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/array/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/array/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/array/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/array/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/array/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/array/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/compatibility/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/compatibility/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/compatibility/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/cube/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/cube/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/cube/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/cube/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/database/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/database/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/database/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/database/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/database/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/database/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/database/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/database/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/database/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/date/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/date/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/date/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/engineering/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/engineering/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/engineering/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/engineering/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/financial/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/financial/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/financial/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/financial/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/information/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/information/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/information/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/logical/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/logical/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/logical/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/logical/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/lookup/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/lookup/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/lookup/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/lookup/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/math/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/math/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/math/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/math/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/math/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/math/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/math/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/math/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/math/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/statistical/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/statistical/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/statistical/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/text/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/text/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/text/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/text/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/text/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/text/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/text/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/text/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/text/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/univer/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/univer/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/univer/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/univer/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/en-US.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/en-US.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/ja-JP.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/ja-JP.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/ru-RU.ts b/packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/function-list/web/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/function-list/web/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/function-list/web/zh-TW.ts
diff --git a/packages/sheets-formula/src/locale/ru-RU.ts b/packages/sheets-formula-ui/src/locale/ru-RU.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/ru-RU.ts
rename to packages/sheets-formula-ui/src/locale/ru-RU.ts
diff --git a/packages/sheets-formula/src/locale/vi-VN.ts b/packages/sheets-formula-ui/src/locale/vi-VN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/vi-VN.ts
rename to packages/sheets-formula-ui/src/locale/vi-VN.ts
diff --git a/packages/sheets-formula/src/locale/zh-CN.ts b/packages/sheets-formula-ui/src/locale/zh-CN.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/zh-CN.ts
rename to packages/sheets-formula-ui/src/locale/zh-CN.ts
diff --git a/packages/sheets-formula/src/locale/zh-TW.ts b/packages/sheets-formula-ui/src/locale/zh-TW.ts
similarity index 100%
rename from packages/sheets-formula/src/locale/zh-TW.ts
rename to packages/sheets-formula-ui/src/locale/zh-TW.ts
diff --git a/packages/sheets-formula-ui/src/services/formula-common.ts b/packages/sheets-formula-ui/src/services/formula-common.ts
new file mode 100644
index 0000000000..61dcbb006f
--- /dev/null
+++ b/packages/sheets-formula-ui/src/services/formula-common.ts
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ICellData, Nullable } from '@univerjs/core';
+
+export enum FormulaResultStatus {
+ NOT_REGISTER = 1,
+ SUCCESS,
+ WAIT,
+ ERROR,
+}
+
+export interface IOtherFormulaResult {
+ result?: Nullable<ICellData>[][];
+ status: FormulaResultStatus;
+ formulaId: string;
+ callbacks: Set<(value: Nullable<ICellData>[][]) => void>;
+ extra?: Record<string, any>;
+}
+
+export interface IFormulaInfo {
+ id: string;
+ text: string;
+}
diff --git a/packages/sheets-formula/src/services/prompt.service.ts b/packages/sheets-formula-ui/src/services/prompt.service.ts
similarity index 99%
rename from packages/sheets-formula/src/services/prompt.service.ts
rename to packages/sheets-formula-ui/src/services/prompt.service.ts
index ec54da2d92..a884556075 100644
--- a/packages/sheets-formula/src/services/prompt.service.ts
+++ b/packages/sheets-formula-ui/src/services/prompt.service.ts
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-import type { Direction, IDisposable } from '@univerjs/core';
-import { type IFunctionInfo, type ISequenceNode, sequenceNodeType } from '@univerjs/engine-formula';
import { createIdentifier, IContextService } from '@univerjs/core';
-import type { Observable } from 'rxjs';
+import { type IFunctionInfo, type ISequenceNode, sequenceNodeType } from '@univerjs/engine-formula';
import { Subject } from 'rxjs';
-
-import type { ISearchItem } from './description.service';
+import type { Direction, IDisposable } from '@univerjs/core';
+import type { ISearchItem } from '@univerjs/sheets-formula';
+import type { Observable } from 'rxjs';
/** If the formula prompt is visible. */
export const FORMULA_PROMPT_ACTIVATED = 'FORMULA_PROMPT_ACTIVATED';
diff --git a/packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts b/packages/sheets-formula-ui/src/services/render-services/ref-selections.render-service.ts
similarity index 100%
rename from packages/sheets-formula/src/services/render-services/ref-selections.render-service.ts
rename to packages/sheets-formula-ui/src/services/render-services/ref-selections.render-service.ts
diff --git a/packages/sheets-formula-ui/src/services/utils.ts b/packages/sheets-formula-ui/src/services/utils.ts
new file mode 100644
index 0000000000..09d5408e60
--- /dev/null
+++ b/packages/sheets-formula-ui/src/services/utils.ts
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { LocaleService } from '@univerjs/core';
+import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
+
+export function getFunctionTypeValues(
+ enumObj: any,
+ localeService: LocaleService
+): Array<{ label: string; value: string }> {
+ // Exclude the DefinedName key
+ return Object.keys(enumObj)
+ .filter((key) => isNaN(Number(key)) && key !== 'DefinedName')
+ .map((key) => ({
+ label: localeService.t(`formula.functionType.${key.toLocaleLowerCase()}`),
+ value: `${enumObj[key]}`,
+ }));
+}
+
+export function getFunctionName(item: IFunctionInfo, localeService: LocaleService) {
+ let functionName = '';
+ if (item.aliasFunctionName) {
+ functionName = localeService.t(item.aliasFunctionName);
+
+ if (functionName === item.aliasFunctionName) {
+ functionName = item.functionName;
+ }
+ } else {
+ functionName = item.functionName;
+ }
+
+ return functionName;
+}
+
+export function generateParam(param: IFunctionParam) {
+ if (!param.require && !param.repeat) {
+ return `[${param.name}]`;
+ } else if (param.require && !param.repeat) {
+ return param.name;
+ } else if (!param.require && param.repeat) {
+ return `[${param.name},...]`;
+ } else if (param.require && param.repeat) {
+ return `${param.name},...`;
+ }
+}
diff --git a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts
new file mode 100644
index 0000000000..cf84fac633
--- /dev/null
+++ b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
+import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
+import { IRenderManagerService } from '@univerjs/engine-render';
+import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
+import type { Dependency } from '@univerjs/core';
+import { FORMULA_UI_PLUGIN_NAME } from './common/plugin-name';
+import {
+ defaultPluginBaseConfig,
+ PLUGIN_CONFIG_KEY_BASE,
+} from './controllers/config.schema';
+import { FormulaAlertRenderController } from './controllers/formula-alert-render.controller';
+import { FormulaAutoFillController } from './controllers/formula-auto-fill.controller';
+import { FormulaClipboardController } from './controllers/formula-clipboard.controller';
+import { FormulaEditorShowController } from './controllers/formula-editor-show.controller';
+import { FormulaRenderManagerController } from './controllers/formula-render.controller';
+import { FormulaUIController } from './controllers/formula-ui.controller';
+import { PromptController } from './controllers/prompt.controller';
+import { FormulaPromptService, IFormulaPromptService } from './services/prompt.service';
+import { RefSelectionsRenderService } from './services/render-services/ref-selections.render-service';
+import type { IUniverSheetsFormulaBaseConfig } from './controllers/config.schema';
+
+/**
+ * The configuration of the formula UI plugin.
+ */
+@DependentOn(UniverFormulaEnginePlugin, UniverSheetsFormulaPlugin)
+export class UniverSheetsFormulaUIPlugin extends Plugin {
+ static override pluginName = FORMULA_UI_PLUGIN_NAME;
+ static override type = UniverInstanceType.UNIVER_SHEET;
+
+ constructor(
+ private readonly _config: Partial<IUniverSheetsFormulaBaseConfig> = defaultPluginBaseConfig,
+ @Inject(Injector) override readonly _injector: Injector,
+ @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
+ @IConfigService private readonly _configService: IConfigService
+ ) {
+ super();
+
+ // Manage the plugin configuration.
+ const { menu, ...rest } = this._config;
+ if (menu) {
+ this._configService.setConfig('menu', menu, { merge: true });
+ }
+ this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest);
+ }
+
+ override onStarting(): void {
+ const j = this._injector;
+ const dependencies: Dependency[] = [
+ [IFormulaPromptService, { useClass: FormulaPromptService }],
+ [FormulaUIController],
+ [FormulaAutoFillController],
+ [FormulaClipboardController],
+ [FormulaEditorShowController],
+ [FormulaRenderManagerController],
+ [PromptController],
+ ];
+
+ dependencies.forEach((dependency) => j.add(dependency));
+ }
+
+ override onRendered(): void {
+ ([
+ [RefSelectionsRenderService],
+ [FormulaAlertRenderController],
+ ] as Dependency[]).forEach((dep) => {
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, dep));
+ });
+ }
+}
diff --git a/packages/sheets-formula/src/views/FormulaPromptContainer.tsx b/packages/sheets-formula-ui/src/views/FormulaPromptContainer.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/FormulaPromptContainer.tsx
rename to packages/sheets-formula-ui/src/views/FormulaPromptContainer.tsx
diff --git a/packages/sheets-formula/src/views/more-functions/MoreFunctions.tsx b/packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/MoreFunctions.tsx
rename to packages/sheets-formula-ui/src/views/more-functions/MoreFunctions.tsx
diff --git a/packages/sheets-formula/src/views/more-functions/function-help/FunctionHelp.tsx b/packages/sheets-formula-ui/src/views/more-functions/function-help/FunctionHelp.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/function-help/FunctionHelp.tsx
rename to packages/sheets-formula-ui/src/views/more-functions/function-help/FunctionHelp.tsx
index 7953be140c..dc938a31b1 100644
--- a/packages/sheets-formula/src/views/more-functions/function-help/FunctionHelp.tsx
+++ b/packages/sheets-formula-ui/src/views/more-functions/function-help/FunctionHelp.tsx
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IFunctionParam } from '@univerjs/engine-formula';
import React from 'react';
+import type { IFunctionParam } from '@univerjs/engine-formula';
import { generateParam } from '../../../services/utils';
interface IFunctionHelpProps {
diff --git a/packages/sheets-formula/src/views/more-functions/function-params/FunctionParams.tsx b/packages/sheets-formula-ui/src/views/more-functions/function-params/FunctionParams.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/function-params/FunctionParams.tsx
rename to packages/sheets-formula-ui/src/views/more-functions/function-params/FunctionParams.tsx
diff --git a/packages/sheets-formula/src/views/more-functions/function-params/index.module.less b/packages/sheets-formula-ui/src/views/more-functions/function-params/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/function-params/index.module.less
rename to packages/sheets-formula-ui/src/views/more-functions/function-params/index.module.less
diff --git a/packages/sheets-formula/src/views/more-functions/index.module.less b/packages/sheets-formula-ui/src/views/more-functions/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/index.module.less
rename to packages/sheets-formula-ui/src/views/more-functions/index.module.less
diff --git a/packages/sheets-formula/src/views/more-functions/input-params/InputParams.tsx b/packages/sheets-formula-ui/src/views/more-functions/input-params/InputParams.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/input-params/InputParams.tsx
rename to packages/sheets-formula-ui/src/views/more-functions/input-params/InputParams.tsx
index 5e1dbf6677..09d8b15da0 100644
--- a/packages/sheets-formula/src/views/more-functions/input-params/InputParams.tsx
+++ b/packages/sheets-formula-ui/src/views/more-functions/input-params/InputParams.tsx
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
import React, { useState } from 'react';
+import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
import { FunctionHelp } from '../function-help/FunctionHelp';
import { FunctionParams } from '../function-params/FunctionParams';
diff --git a/packages/sheets-formula/src/views/more-functions/input-params/index.module.less b/packages/sheets-formula-ui/src/views/more-functions/input-params/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/input-params/index.module.less
rename to packages/sheets-formula-ui/src/views/more-functions/input-params/index.module.less
diff --git a/packages/sheets-formula/src/views/more-functions/interface.ts b/packages/sheets-formula-ui/src/views/more-functions/interface.ts
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/interface.ts
rename to packages/sheets-formula-ui/src/views/more-functions/interface.ts
diff --git a/packages/sheets-formula/src/views/more-functions/select-function/SelectFunction.tsx b/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx
similarity index 98%
rename from packages/sheets-formula/src/views/more-functions/select-function/SelectFunction.tsx
rename to packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx
index 43a23a72ac..babbfb5cf7 100644
--- a/packages/sheets-formula/src/views/more-functions/select-function/SelectFunction.tsx
+++ b/packages/sheets-formula-ui/src/views/more-functions/select-function/SelectFunction.tsx
@@ -16,13 +16,12 @@
import { LocaleService, useDependency } from '@univerjs/core';
import { Input, Select } from '@univerjs/design';
-import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
import { FunctionType } from '@univerjs/engine-formula';
import { CheckMarkSingle } from '@univerjs/icons';
+import { IDescriptionService } from '@univerjs/sheets-formula';
import React, { useEffect, useState } from 'react';
-
-import type { ISearchItem } from '../../../services/description.service';
-import { IDescriptionService } from '../../../services/description.service';
+import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
+import type { ISearchItem } from '@univerjs/sheets-formula';
import { getFunctionTypeValues } from '../../../services/utils';
import { FunctionHelp } from '../function-help/FunctionHelp';
import { FunctionParams } from '../function-params/FunctionParams';
diff --git a/packages/sheets-formula/src/views/more-functions/select-function/index.module.less b/packages/sheets-formula-ui/src/views/more-functions/select-function/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/more-functions/select-function/index.module.less
rename to packages/sheets-formula-ui/src/views/more-functions/select-function/index.module.less
diff --git a/packages/sheets-formula/src/views/prompt/help-function/HelpFunction.tsx b/packages/sheets-formula-ui/src/views/prompt/help-function/HelpFunction.tsx
similarity index 100%
rename from packages/sheets-formula/src/views/prompt/help-function/HelpFunction.tsx
rename to packages/sheets-formula-ui/src/views/prompt/help-function/HelpFunction.tsx
index cb9d6d8909..08aa12f4ff 100644
--- a/packages/sheets-formula/src/views/prompt/help-function/HelpFunction.tsx
+++ b/packages/sheets-formula-ui/src/views/prompt/help-function/HelpFunction.tsx
@@ -19,8 +19,8 @@ import { Popup } from '@univerjs/design';
import { IEditorService } from '@univerjs/docs-ui';
import { CloseSingle, DetailsSingle, MoreSingle } from '@univerjs/icons';
import { ILayoutService, ISidebarService } from '@univerjs/ui';
-
import React, { useEffect, useState } from 'react';
+
import { throttleTime } from 'rxjs';
import type { IFunctionInfo, IFunctionParam } from '@univerjs/engine-formula';
import { IFormulaPromptService } from '../../../services/prompt.service';
diff --git a/packages/sheets-formula/src/views/prompt/help-function/index.module.less b/packages/sheets-formula-ui/src/views/prompt/help-function/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/prompt/help-function/index.module.less
rename to packages/sheets-formula-ui/src/views/prompt/help-function/index.module.less
diff --git a/packages/sheets-formula/src/views/prompt/resize-scroll-observer.ts b/packages/sheets-formula-ui/src/views/prompt/resize-scroll-observer.ts
similarity index 100%
rename from packages/sheets-formula/src/views/prompt/resize-scroll-observer.ts
rename to packages/sheets-formula-ui/src/views/prompt/resize-scroll-observer.ts
diff --git a/packages/sheets-formula/src/views/prompt/search-function/SearchFunction.tsx b/packages/sheets-formula-ui/src/views/prompt/search-function/SearchFunction.tsx
similarity index 98%
rename from packages/sheets-formula/src/views/prompt/search-function/SearchFunction.tsx
rename to packages/sheets-formula-ui/src/views/prompt/search-function/SearchFunction.tsx
index 073574c188..352763f9cc 100644
--- a/packages/sheets-formula/src/views/prompt/search-function/SearchFunction.tsx
+++ b/packages/sheets-formula-ui/src/views/prompt/search-function/SearchFunction.tsx
@@ -19,9 +19,9 @@ import { Popup } from '@univerjs/design';
import { IEditorService } from '@univerjs/docs-ui';
import React, { useEffect, useRef, useState } from 'react';
+import type { ISearchItem } from '@univerjs/sheets-formula';
import { IFormulaPromptService } from '../../../services/prompt.service';
import styles from './index.module.less';
-import type { ISearchItem } from '../../../services/description.service';
import type { INavigateParam, ISearchFunctionOperationParams } from '../../../services/prompt.service';
export function SearchFunction() {
diff --git a/packages/sheets-formula/src/views/prompt/search-function/index.module.less b/packages/sheets-formula-ui/src/views/prompt/search-function/index.module.less
similarity index 100%
rename from packages/sheets-formula/src/views/prompt/search-function/index.module.less
rename to packages/sheets-formula-ui/src/views/prompt/search-function/index.module.less
diff --git a/packages/sheets-formula-ui/src/vite-env.d.ts b/packages/sheets-formula-ui/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/packages/sheets-formula-ui/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/packages/sheets-formula-ui/tsconfig.json b/packages/sheets-formula-ui/tsconfig.json
new file mode 100644
index 0000000000..c62210cbad
--- /dev/null
+++ b/packages/sheets-formula-ui/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/base",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "lib/types"
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src"]
+}
diff --git a/packages/sheets-formula-ui/tsconfig.node.json b/packages/sheets-formula-ui/tsconfig.node.json
new file mode 100644
index 0000000000..50ef1e6862
--- /dev/null
+++ b/packages/sheets-formula-ui/tsconfig.node.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@univerjs-infra/shared/tsconfigs/node",
+ "include": ["vite.config.ts"]
+}
diff --git a/packages/sheets-formula-ui/vite.config.ts b/packages/sheets-formula-ui/vite.config.ts
new file mode 100644
index 0000000000..ff0e0966ce
--- /dev/null
+++ b/packages/sheets-formula-ui/vite.config.ts
@@ -0,0 +1,12 @@
+import createViteConfig from '@univerjs-infra/shared/vite';
+import pkg from './package.json';
+
+export default ({ mode }) => createViteConfig({}, {
+ mode,
+ pkg,
+ features: {
+ react: true,
+ css: true,
+ dom: true,
+ },
+});
diff --git a/packages/sheets-formula/package.json b/packages/sheets-formula/package.json
index ddeb4e1772..521fff217b 100644
--- a/packages/sheets-formula/package.json
+++ b/packages/sheets-formula/package.json
@@ -21,8 +21,7 @@
],
"exports": {
".": "./src/index.ts",
- "./*": "./src/*",
- "./locale/*": "./src/locale/*.ts"
+ "./*": "./src/*"
},
"main": "./lib/cjs/index.js",
"module": "./lib/es/index.js",
@@ -42,8 +41,7 @@
"require": "./lib/cjs/*",
"types": "./lib/types/index.d.ts"
},
- "./lib/*": "./lib/*",
- "./locale/*": "./lib/locale/*.json"
+ "./lib/*": "./lib/*"
}
},
"directories": {
@@ -63,13 +61,9 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
- "@univerjs/engine-render": "workspace:*",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*",
- "@univerjs/sheets-ui": "workspace:*",
- "@univerjs/ui": "workspace:*",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
},
@@ -77,9 +71,7 @@
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/docs": "workspace:*",
- "@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-formula": "workspace:*",
- "@univerjs/engine-render": "workspace:*",
"@univerjs/icons": "^0.1.78",
"@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*",
@@ -109,7 +101,6 @@
"require": "./lib/cjs/*",
"types": "./lib/types/index.d.ts"
},
- "./lib/*": "./lib/*",
- "./locale/*": "./lib/locale/*.json"
+ "./lib/*": "./lib/*"
}
}
diff --git a/packages/sheets-formula/src/commands/mutations/formula.mutation.ts b/packages/sheets-formula/src/commands/mutations/formula.mutation.ts
index fb1892ec79..4e7cb5fd4d 100644
--- a/packages/sheets-formula/src/commands/mutations/formula.mutation.ts
+++ b/packages/sheets-formula/src/commands/mutations/formula.mutation.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { IMutation } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
+import type { IMutation } from '@univerjs/core';
export interface IOtherFormulaMarkDirtyParams { [unitId: string]: { [sunUnitId: string]: { [formulaId: string]: boolean } } }
diff --git a/packages/sheets-formula/src/common/plugin-name.ts b/packages/sheets-formula/src/common/plugin-name.ts
index 0c3b288e7e..d2c35d4c43 100644
--- a/packages/sheets-formula/src/common/plugin-name.ts
+++ b/packages/sheets-formula/src/common/plugin-name.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export const FORMULA_UI_PLUGIN_NAME = 'SHEET_FORMULA_UI_PLUGIN';
+export const SHEETS_FORMULA_PLUGIN_NAME = 'SHEETS_FORMULA_PLUGIN';
diff --git a/packages/sheets-formula/src/controllers/array-formula-display.controller.ts b/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts
similarity index 92%
rename from packages/sheets-formula/src/controllers/array-formula-display.controller.ts
rename to packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts
index 61d49f3809..f1b78f271e 100644
--- a/packages/sheets-formula/src/controllers/array-formula-display.controller.ts
+++ b/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-import { CellValueType, Disposable, ICommandService, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle, ThemeService } from '@univerjs/core';
+import { CellValueType, Disposable, ICommandService, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle } from '@univerjs/core';
import { FormulaDataModel, SetArrayFormulaDataMutation, stripErrorMargin } from '@univerjs/engine-formula';
import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';
import type { ICommandInfo } from '@univerjs/core';
import type { ISetArrayFormulaDataMutationParams } from '@univerjs/engine-formula';
-@OnLifecycle(LifecycleStages.Ready, ArrayFormulaDisplayController)
-export class ArrayFormulaDisplayController extends Disposable {
+@OnLifecycle(LifecycleStages.Ready, ArrayFormulaCellInterceptorController)
+export class ArrayFormulaCellInterceptorController extends Disposable {
constructor(
@ICommandService private readonly _commandService: ICommandService,
@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,
- @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel,
- @Inject(ThemeService) private readonly _themeService: ThemeService
+ @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel
) {
super();
diff --git a/packages/sheets-formula/src/controllers/config.schema.ts b/packages/sheets-formula/src/controllers/config.schema.ts
index be09b61b17..9ba378e35b 100644
--- a/packages/sheets-formula/src/controllers/config.schema.ts
+++ b/packages/sheets-formula/src/controllers/config.schema.ts
@@ -14,9 +14,8 @@
* limitations under the License.
*/
-import type { MenuConfig } from '@univerjs/ui';
-import type { BaseFunction, IFunctionInfo, IFunctionNames } from '@univerjs/engine-formula';
import type { Ctor } from '@univerjs/core';
+import type { BaseFunction, IFunctionInfo, IFunctionNames } from '@univerjs/engine-formula';
/**
* Base configuration for the plugin.
@@ -26,7 +25,6 @@ export const PLUGIN_CONFIG_KEY_BASE = 'sheets-formula.base.config';
export const configSymbolBase = Symbol(PLUGIN_CONFIG_KEY_BASE);
export interface IUniverSheetsFormulaBaseConfig {
- menu?: MenuConfig;
notExecuteFormula?: boolean;
description?: IFunctionInfo[];
function?: Array<[Ctor<BaseFunction>, IFunctionNames]>;
@@ -52,9 +50,3 @@ export const defaultPluginRemoteConfig: IUniverSheetsFormulaRemoteConfig = {};
export const PLUGIN_CONFIG_KEY_MOBILE = 'sheets-formula.mobile.config';
export const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
-
-export interface IUniverSheetsFormulaMobileConfig {
- menu?: MenuConfig;
-}
-
-export const defaultPluginMobileConfig: IUniverSheetsFormulaMobileConfig = {};
diff --git a/packages/sheets-formula/src/controllers/defined-name.controller.ts b/packages/sheets-formula/src/controllers/defined-name.controller.ts
index 70a7569c7d..e54c4e89df 100644
--- a/packages/sheets-formula/src/controllers/defined-name.controller.ts
+++ b/packages/sheets-formula/src/controllers/defined-name.controller.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { ICommandInfo, IExecutionOptions, Nullable, Workbook } from '@univerjs/core';
import {
Disposable,
ICommandService,
@@ -24,10 +23,11 @@ import {
toDisposable,
UniverInstanceType,
} from '@univerjs/core';
-import type { IFunctionInfo, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
import { FunctionType, IDefinedNamesService } from '@univerjs/engine-formula';
-import type { ISetDefinedNameCommandParams } from '@univerjs/sheets';
import { InsertDefinedNameCommand, RemoveDefinedNameCommand, SetDefinedNameCommand, SetWorksheetActiveOperation } from '@univerjs/sheets';
+import type { ICommandInfo, IExecutionOptions, Nullable, Workbook } from '@univerjs/core';
+import type { IFunctionInfo, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
+import type { ISetDefinedNameCommandParams } from '@univerjs/sheets';
import { IDescriptionService } from '../services/description.service';
export const SCOPE_WORKBOOK_VALUE = 'AllDefaultWorkbook';
diff --git a/packages/sheets-formula/src/controllers/formula.controller.ts b/packages/sheets-formula/src/controllers/formula.controller.ts
new file mode 100644
index 0000000000..05285a6313
--- /dev/null
+++ b/packages/sheets-formula/src/controllers/formula.controller.ts
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Disposable, ICommandService } from '@univerjs/core';
+import { InsertFunctionCommand } from '../commands/commands/insert-function.command';
+import { OtherFormulaMarkDirty } from '../commands/mutations/formula.mutation';
+
+export class FormulaController extends Disposable {
+ constructor(
+ @ICommandService private readonly _commandService: ICommandService
+ ) {
+ super();
+
+ [
+ InsertFunctionCommand,
+ OtherFormulaMarkDirty,
+ ].forEach((c) => this._commandService.registerCommand(c));
+ }
+}
diff --git a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
index 36113cf695..b875ae2026 100644
--- a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
+++ b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
@@ -14,18 +14,8 @@
* limitations under the License.
*/
-import type { ICommandInfo, IUnitRange, Nullable } from '@univerjs/core';
-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle, throttle } from '@univerjs/core';
-import type {
- IDirtyUnitFeatureMap,
- IDirtyUnitOtherFormulaMap,
- IDirtyUnitSheetNameMap,
- IExecutionInProgressParams,
- IFormulaDirtyData,
- ISetFormulaCalculationNotificationMutation,
-} from '@univerjs/engine-formula';
+import { Disposable, ICommandService, throttle } from '@univerjs/core';
import {
- FormulaDataModel,
FormulaExecutedStateType,
FormulaExecuteStageType,
IActiveDirtyManagerService,
@@ -33,17 +23,36 @@ import {
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
} from '@univerjs/engine-formula';
-import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';
import {
ClearSelectionFormatCommand,
- INumfmtService,
SetBorderCommand,
SetRangeValuesMutation,
SetStyleCommand,
} from '@univerjs/sheets';
-import { IProgressService } from '@univerjs/ui';
+import { BehaviorSubject } from 'rxjs';
+import type { ICommandInfo, IUnitRange, Nullable } from '@univerjs/core';
+import type {
+ IDirtyUnitFeatureMap,
+ IDirtyUnitOtherFormulaMap,
+ IDirtyUnitSheetNameMap,
+ IExecutionInProgressParams,
+ IFormulaDirtyData,
+ ISetFormulaCalculationNotificationMutation,
+} from '@univerjs/engine-formula';
+import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';
+
+/**
+ * This interface is for the progress bar to display the calculation progress.
+ */
+export interface ICalculationProgress {
+ done: number;
+ /** The total number of formulas need to calculate. */
+ count: number;
+}
+const NilProgress: ICalculationProgress = { done: 0, count: 0 };
+
+const lo = { onlyLocal: true };
-@OnLifecycle(LifecycleStages.Ready, TriggerCalculationController)
export class TriggerCalculationController extends Disposable {
private _waitingCommandQueue: ICommandInfo[] = [];
@@ -68,43 +77,29 @@ export class TriggerCalculationController extends Disposable {
private _restartCalculation = false;
+ private readonly _progress$ = new BehaviorSubject<ICalculationProgress>(NilProgress);
+ readonly progress$ = this._progress$.asObservable();
+
constructor(
@ICommandService private readonly _commandService: ICommandService,
- @IActiveDirtyManagerService private readonly _activeDirtyManagerService: IActiveDirtyManagerService,
- @Inject(INumfmtService) private readonly _numfmtService: INumfmtService,
- @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel,
- @Inject(IProgressService) private readonly _progressService: IProgressService
+ @IActiveDirtyManagerService private readonly _activeDirtyManagerService: IActiveDirtyManagerService
) {
super();
- this._initialize();
- }
-
- private _initialize(): void {
this._commandExecutedListener();
-
this._initialExecuteFormulaProcessListener();
-
this._initialExecuteFormula();
-
this._initialProgressBar();
}
- private _commandExecutedListener() {
- // const updateCommandList = [
- // SetRangeValuesMutation.id,
- // MoveRangeMutation.id,
- // MoveRowsMutation.id,
- // MoveColsMutation.id,
- // DeleteRangeMutation.id,
- // InsertRangeMutation.id,
- // RemoveRowMutation.id,
- // RemoveColMutation.id,
- // RemoveSheetMutation.id,
- // // SetWorksheetNameMutation.id,
- // InsertSheetMutation.id,
- // ];
+ override dispose(): void {
+ super.dispose();
+ this._progress$.next(NilProgress);
+ this._progress$.complete();
+ }
+
+ private _commandExecutedListener() {
this.disposeWithMe(
this._commandService.onCommandExecuted((command: ICommandInfo, options) => {
if (!this._activeDirtyManagerService.get(command.id)) {
@@ -133,18 +128,10 @@ export class TriggerCalculationController extends Disposable {
this._executingDirtyData = this._mergeDirty(this._executingDirtyData, dirtyData);
if (this._executionInProgressParams == null) {
- this._commandService.executeCommand(
- SetFormulaCalculationStartMutation.id,
- {
- ...this._executingDirtyData,
- },
- {
- onlyLocal: true,
- }
- );
+ this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, { ...this._executingDirtyData }, lo);
} else {
this._restartCalculation = true;
- this._commandService.executeCommand(SetFormulaCalculationStopMutation.id, {});
+ this._commandService.executeCommand(SetFormulaCalculationStopMutation.id);
}
this._startExecutionTime = performance.now();
@@ -203,7 +190,6 @@ export class TriggerCalculationController extends Disposable {
dirtyUnitFeatureMap: allDirtyUnitFeatureMap,
dirtyUnitOtherFormulaMap: allDirtyUnitOtherFormulaMap,
forceCalculation: false,
- // numfmtItemMap,
};
}
@@ -268,9 +254,7 @@ export class TriggerCalculationController extends Disposable {
// eslint-disable-next-line max-lines-per-function
private _initialExecuteFormulaProcessListener() {
- /**
- * Assignment operation after formula calculation.
- */
+ // Assignment operation after formula calculation.
const debouncedFormulaPushTask = throttle(this._pushFormulaTask.bind(this), 300);
const debouncedArrayFormulaPushTask = throttle(this._pushArrayFormulaTask.bind(this), 300);
let startDependencyTimer: NodeJS.Timeout | null = null;
@@ -312,8 +296,8 @@ export class TriggerCalculationController extends Disposable {
startDependencyTimer = setTimeout(() => {
// Ignore progress deviations, and finally the complete method ensures the correct completion of the progress
const taskCount = (formulaCalculationCount - this._formulaCalculationDoneCount) + (arrayFormulaCalculationCount - this._arrayFormulaCalculationDoneCount) + 100;
- this._progressService.insertTaskCount(taskCount);
- this._progressService.pushTask({ count: 5 });
+ // this._progressService.insertTaskCount(taskCount);
+ // this._progressService.pushTask({ count: 5 });
startDependencyTimer = null;
}, 1000);
} else if (stage === FormulaExecuteStageType.CURRENTLY_CALCULATING) {
@@ -323,7 +307,7 @@ export class TriggerCalculationController extends Disposable {
if (startDependencyTimer) {
formulaCalculationCount += totalFormulasToCalculate;
} else {
- this._progressService.insertTaskCount(totalFormulasToCalculate);
+ // this._progressService.insertTaskCount(totalFormulasToCalculate);
}
}
@@ -338,7 +322,7 @@ export class TriggerCalculationController extends Disposable {
if (startDependencyTimer) {
arrayFormulaCalculationCount += totalArrayFormulasToCalculate;
} else {
- this._progressService.insertTaskCount(totalArrayFormulasToCalculate);
+ // this._progressService.insertTaskCount(totalArrayFormulasToCalculate);
}
}
@@ -350,16 +334,6 @@ export class TriggerCalculationController extends Disposable {
}
this._executionInProgressParams = params.stageInfo;
-
- // if (totalArrayFormulasToCalculate > 0) {
- // console.warn(
- // `Stage ${stage} Array formula.There are ${totalArrayFormulasToCalculate} functions to be executed, ${completedArrayFormulasCount} complete.`
- // );
- // } else {
- // console.warn(
- // `Stage ${stage} .There are ${totalFormulasToCalculate} functions to be executed, ${completedFormulasCount} complete.`
- // );
- // }
} else {
const state = params.functionsExecutedState;
let result = '';
@@ -375,7 +349,7 @@ export class TriggerCalculationController extends Disposable {
case FormulaExecutedStateType.STOP_EXECUTION:
result = 'The execution of the formula has been stopped';
// this._executingCommandQueue = [];
- this._progressService.stop();
+ // this._progressService.stop();
calculationProcessCount = 0;
break;
case FormulaExecutedStateType.SUCCESS:
@@ -397,7 +371,7 @@ export class TriggerCalculationController extends Disposable {
} else {
// Manually hide the progress bar only if no other calculations are in process
if (state === FormulaExecutedStateType.SUCCESS) {
- this._progressService.complete();
+ // this._progressService.complete();
}
}
@@ -414,9 +388,7 @@ export class TriggerCalculationController extends Disposable {
{
...this._executingDirtyData,
},
- {
- onlyLocal: true,
- }
+ lo
);
} else {
this._executionInProgressParams = null;
@@ -446,9 +418,7 @@ export class TriggerCalculationController extends Disposable {
commands: [],
forceCalculation: true,
},
- {
- onlyLocal: true,
- }
+ lo
);
}
@@ -456,11 +426,12 @@ export class TriggerCalculationController extends Disposable {
* The user manually stops the progress bar
*/
private _initialProgressBar() {
- this.disposeWithMe(this._progressService.progressVisible$.subscribe((isVisible) => {
- if (!isVisible) {
- this._commandService.executeCommand(SetFormulaCalculationStopMutation.id, {});
- }
- }));
+ // TODO: expose method to stop calculation
+ // this.disposeWithMe(this._progressService.progressVisible$.subscribe((isVisible) => {
+ // if (!isVisible) {
+ // this._commandService.executeCommand(SetFormulaCalculationStopMutation.id, {});
+ // }
+ // }));
}
/**
@@ -468,13 +439,13 @@ export class TriggerCalculationController extends Disposable {
* @param completedCount
*/
private _pushFormulaTask(completedCount: number) {
- if (this._progressService.getTaskCount() === 0) {
- return;
- }
+ // if (this._progressService.getTaskCount() === 0) {
+ // return;
+ // }
const count = completedCount - this._formulaCalculationDoneCount;
this._formulaCalculationDoneCount = completedCount;
- this._progressService.pushTask({ count });
+ // this._progressService.pushTask({ count });
}
/**
@@ -482,12 +453,12 @@ export class TriggerCalculationController extends Disposable {
* @param completedCount
*/
private _pushArrayFormulaTask(completedCount: number) {
- if (this._progressService.getTaskCount() === 0) {
- return;
- }
+ // if (this._progressService.getTaskCount() === 0) {
+ // return;
+ // }
- const count = completedCount - this._arrayFormulaCalculationDoneCount;
- this._arrayFormulaCalculationDoneCount = completedCount;
- this._progressService.pushTask({ count });
+ // const count = completedCount - this._arrayFormulaCalculationDoneCount;
+ // this._arrayFormulaCalculationDoneCount = completedCount;
+ // this._progressService.pushTask({ count });
}
}
diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.ts
index f9cd88a625..df80480046 100644
--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts
+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts
@@ -20,18 +20,16 @@ import {
ICommandService,
Inject,
Injector,
- isInternalEditorID,
IUniverInstanceService,
LifecycleStages,
ObjectMatrix,
OnLifecycle,
RANGE_TYPE,
Rectangle,
- toDisposable,
+
Tools,
UniverInstanceType,
} from '@univerjs/core';
-import { IEditorService } from '@univerjs/docs-ui';
import { deserializeRangeWithSheet,
ErrorType,
FormulaDataModel,
@@ -78,20 +76,16 @@ import {
SetStyleCommand,
SetWorksheetNameCommand,
SheetInterceptorService,
- SheetsSelectionsService,
} from '@univerjs/sheets';
-import { filter, map, merge } from 'rxjs';
+import { map } from 'rxjs';
import type {
- DocumentDataModel,
ICommandInfo,
IExecutionOptions,
IRange,
IUnitRange,
Nullable,
- SlideDataModel,
- Workbook,
-} from '@univerjs/core';
+ Workbook } from '@univerjs/core';
import type { IFormulaData, IFormulaDataItem, ISequenceNode, IUnitSheetNameMap } from '@univerjs/engine-formula';
import type {
@@ -159,11 +153,11 @@ enum OriginRangeEdgeType {
*
* 1. Command intercepts, converts the command information to adapt refRange, offsets the formula content, and obtains the formula that requires offset content.
*
- 2. Use refRange to offset the formula position and return undo/redo data to setRangeValues mutation
- - Redo data: Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
- - Undo data: the old position on the match saves the old value, and the new position delete value. Using undos when undoing will operate the data after the offset position.
-
- 3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)
+ * 2. Use refRange to offset the formula position and return undo/redo data to setRangeValues mutation
+ * - Redo data: Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
+ * - Undo data: the old position on the match saves the old value, and the new position delete value. Using undos when undoing will operate the data after the offset position.
+ *
+ * 3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)
*/
@OnLifecycle(LifecycleStages.Ready, UpdateFormulaController)
export class UpdateFormulaController extends Disposable {
@@ -173,24 +167,17 @@ export class UpdateFormulaController extends Disposable {
@Inject(LexerTreeBuilder) private readonly _lexerTreeBuilder: LexerTreeBuilder,
@Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel,
@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,
- @Inject(SheetsSelectionsService) private _selectionManagerService: SheetsSelectionsService,
- @IEditorService private readonly _editorService: IEditorService,
@Inject(Injector) readonly _injector: Injector
) {
super();
- this._initialize();
- }
- private _initialize(): void {
this._commandExecutedListener();
}
private _commandExecutedListener() {
- this.disposeWithMe(
- this._sheetInterceptorService.interceptCommand({
- getMutations: (command) => this._getUpdateFormula(command),
- })
- );
+ this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
+ getMutations: (command) => this._getUpdateFormula(command),
+ }));
this.disposeWithMe(
this._commandService.onCommandExecuted((command: ICommandInfo, options?: IExecutionOptions) => {
@@ -210,38 +197,18 @@ export class UpdateFormulaController extends Disposable {
this._handleSetRangeValuesMutation(params as ISetRangeValuesMutationParams);
} else if (command.id === RemoveSheetMutation.id) {
const { subUnitId: sheetId, unitId } = command.params as IRemoveSheetMutationParams;
- this._handleRemoveSheetMutation(unitId, sheetId);
+ this._handleWorkbookDisposed(unitId, sheetId);
} else if (command.id === InsertSheetMutation.id) {
this._handleInsertSheetMutation(command.params as IInsertSheetMutationParams);
}
})
);
- // When a unit is added or removed, update the formula data
- this.disposeWithMe(
- toDisposable(
- merge(
- this._univerInstanceService.getTypeOfUnitAdded$<Workbook>(UniverInstanceType.UNIVER_SHEET),
- this._univerInstanceService.getTypeOfUnitAdded$<DocumentDataModel>(UniverInstanceType.UNIVER_DOC),
- this._univerInstanceService.getTypeOfUnitAdded$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE)
- ).pipe(
- filter((unit) => this._editorService.getEditor(unit.getUnitId()) == null),
- filter((unit) => !isInternalEditorID(unit.getUnitId()))
- ).subscribe((unit) => this._handleUnitAdded(unit))
- )
- );
-
- this.disposeWithMe(
- toDisposable(
- merge(
- this._univerInstanceService.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SHEET).pipe(map((sheet) => sheet.getUnitId())),
- this._univerInstanceService.getTypeOfUnitDisposed$<DocumentDataModel>(UniverInstanceType.UNIVER_DOC).pipe(map((doc) => doc.getUnitId())),
- this._univerInstanceService.getTypeOfUnitDisposed$<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).pipe(map((slide) => slide.getUnitId()))
- ).pipe(
- filter((unitId) => this._editorService.getEditor(unitId) == null)
- ).subscribe((id) => this._handleRemoveSheetMutation(id))
- )
- );
+ this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$<Workbook>(UniverInstanceType.UNIVER_SHEET)
+ .subscribe((unit) => this._handleWorkbookAdded(unit)));
+ this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SHEET)
+ .pipe(map((unit) => unit.getUnitId()))
+ .subscribe((unitId) => this._handleWorkbookDisposed(unitId)));
}
private _handleSetRangeValuesMutation(params: ISetRangeValuesMutationParams) {
@@ -299,7 +266,7 @@ export class UpdateFormulaController extends Disposable {
);
}
- private _handleRemoveSheetMutation(unitId: string, sheetId?: string) {
+ private _handleWorkbookDisposed(unitId: string, sheetId?: string) {
const formulaData = this._formulaDataModel.getFormulaData();
const newFormulaData = removeFormulaData(formulaData, unitId, sheetId);
@@ -354,51 +321,23 @@ export class UpdateFormulaController extends Disposable {
);
}
- private _handleUnitAdded(unit: Workbook | DocumentDataModel | SlideDataModel) {
+ private _handleWorkbookAdded(unit: Workbook) {
const formulaData = this._formulaDataModel.getFormulaData();
const unitId = unit.getUnitId();
- const unitType = unit.type;
- const newFormulaData: IFormulaData = {
- [unitId]: {},
- };
+ const newFormulaData: IFormulaData = { [unitId]: {} };
- if (unitType === UniverInstanceType.UNIVER_SHEET) {
- const worksheets = unit.getSheets();
- worksheets.forEach((worksheet) => {
- const cellMatrix = worksheet.getCellMatrix();
- const sheetId = worksheet.getSheetId();
+ const worksheets = unit.getSheets();
+ worksheets.forEach((worksheet) => {
+ const cellMatrix = worksheet.getCellMatrix();
+ const sheetId = worksheet.getSheetId();
- const currentSheetData = initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
-
- newFormulaData[unitId]![sheetId] = currentSheetData[unitId]?.[sheetId];
- });
- } else if (unitType === UniverInstanceType.UNIVER_DOC) {
- // TODO@Dushusir add doc formula data
- } else if (unitType === UniverInstanceType.UNIVER_SLIDE) {
- // TODO@Dushusir add slide formula data
- }
+ const currentSheetData = initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
- this._commandService.executeCommand(
- SetFormulaDataMutation.id,
- {
- formulaData: newFormulaData,
- },
- {
- onlyLocal: true,
- }
- );
+ newFormulaData[unitId]![sheetId] = currentSheetData[unitId]?.[sheetId];
+ });
- // start calculation
- this._commandService.executeCommand(
- SetFormulaCalculationStartMutation.id,
- {
- commands: [],
- forceCalculation: true,
- },
- {
- onlyLocal: true,
- }
- );
+ this._commandService.executeCommand(SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
+ this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, { commands: [], forceCalculation: true }, { onlyLocal: true });
}
private _getUpdateFormula(command: ICommandInfo) {
diff --git a/packages/sheets-formula/src/index.ts b/packages/sheets-formula/src/index.ts
index f796bbdd67..b1e85fdec5 100644
--- a/packages/sheets-formula/src/index.ts
+++ b/packages/sheets-formula/src/index.ts
@@ -14,28 +14,19 @@
* limitations under the License.
*/
-export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaMobilePlugin, UniverSheetsFormulaPlugin } from './formula-ui-plugin';
-export { IDescriptionService } from './services/description.service';
-export { DescriptionService } from './services/description.service';
+export { type IInsertFunction, type IInsertFunctionCommandParams, InsertFunctionCommand } from './commands/commands/insert-function.command';
+export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';
+// #region - all commands
+
+export { UpdateFormulaController } from './controllers/update-formula.controller';
+export { DescriptionService, IDescriptionService, type ISearchItem } from './services/description.service';
+export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
+export { FormulaRefRangeService } from './services/formula-ref-range.service';
export type { IRegisterFunctionParams, IUnregisterFunctionParams } from './services/register-function.service';
export { RegisterFunctionService } from './services/register-function.service';
export { IRegisterFunctionService } from './services/register-function.service';
-export { IRemoteRegisterFunctionService, RemoteRegisterFunctionService } from './services/remote/remote-register-function.service';
-export { FormulaRefRangeService } from './services/formula-ref-range.service';
-export { FORMULA_PROMPT_ACTIVATED } from './services/prompt.service';
export { RegisterOtherFormulaService } from './services/register-other-formula.service';
-export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
-
-// #region - all commands
-
-export { SheetOnlyPasteFormulaCommand } from './commands/commands/formula-clipboard.command';
-export { InsertFunctionCommand } from './commands/commands/insert-function.command';
-export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';
-export { SelectEditorFormulaOperation } from './commands/operations/editor-formula.operation';
-export { HelpFunctionOperation } from './commands/operations/help-function.operation';
-export { InsertFunctionOperation } from './commands/operations/insert-function.operation';
-export { MoreFunctionsOperation } from './commands/operations/more-functions.operation';
-export { ReferenceAbsoluteOperation } from './commands/operations/reference-absolute.operation';
-export { SearchFunctionOperation } from './commands/operations/search-function.operation';
+export { IRemoteRegisterFunctionService, RemoteRegisterFunctionService } from './services/remote/remote-register-function.service';
+export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaMobilePlugin, UniverSheetsFormulaPlugin } from './sheets-formula.plugin';
// #endregion
diff --git a/packages/sheets-formula/src/services/description.service.ts b/packages/sheets-formula/src/services/description.service.ts
index 1f060d8337..3ace4df222 100644
--- a/packages/sheets-formula/src/services/description.service.ts
+++ b/packages/sheets-formula/src/services/description.service.ts
@@ -15,7 +15,6 @@
*/
import { createIdentifier, IConfigService, Inject, LocaleService, toDisposable } from '@univerjs/core';
-import type { IFunctionInfo, IFunctionNames } from '@univerjs/engine-formula';
import {
functionArray,
functionCompatibility,
@@ -38,11 +37,12 @@ import {
isReferenceStrings,
} from '@univerjs/engine-formula';
import type { IDisposable } from '@univerjs/core';
+import type { IFunctionInfo, IFunctionNames } from '@univerjs/engine-formula';
-import type { IUniverSheetsFormulaBaseConfig } from '../controllers/config.schema';
import { PLUGIN_CONFIG_KEY_BASE } from '../controllers/config.schema';
import { FUNCTION_LIST } from './function-list/function-list';
import { getFunctionName } from './utils';
+import type { IUniverSheetsFormulaBaseConfig } from '../controllers/config.schema';
export interface ISearchItem {
name: string;
diff --git a/packages/sheets-formula/src/formula-ui-plugin.ts b/packages/sheets-formula/src/sheets-formula.plugin.ts
similarity index 61%
rename from packages/sheets-formula/src/formula-ui-plugin.ts
rename to packages/sheets-formula/src/sheets-formula.plugin.ts
index 2cb74aabef..48220d62c1 100644
--- a/packages/sheets-formula/src/formula-ui-plugin.ts
+++ b/packages/sheets-formula/src/sheets-formula.plugin.ts
@@ -15,45 +15,33 @@
*/
import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
-import type { Dependency } from '@univerjs/core';
-import { fromModule, IRPCChannelService, toModule } from '@univerjs/rpc';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
-import { IRenderManagerService } from '@univerjs/engine-render';
-import { IRefSelectionsService, RefSelectionsService } from '@univerjs/sheets';
+import { fromModule, IRPCChannelService, toModule } from '@univerjs/rpc';
+import { UniverSheetsPlugin } from '@univerjs/sheets';
-import { FORMULA_UI_PLUGIN_NAME } from './common/plugin-name';
+import type { Dependency } from '@univerjs/core';
+import { SHEETS_FORMULA_PLUGIN_NAME } from './common/plugin-name';
import { ActiveDirtyController } from './controllers/active-dirty.controller';
-import { ArrayFormulaDisplayController } from './controllers/array-formula-display.controller';
-import { FormulaAutoFillController } from './controllers/formula-auto-fill.controller';
-import { FormulaClipboardController } from './controllers/formula-clipboard.controller';
-import { FormulaEditorShowController } from './controllers/formula-editor-show.controller';
-import { FormulaUIController } from './controllers/formula-ui.controller';
+import { ArrayFormulaCellInterceptorController } from './controllers/array-formula-cell-interceptor.controller';
+import {
+ defaultPluginBaseConfig,
+ defaultPluginRemoteConfig,
+ PLUGIN_CONFIG_KEY_BASE,
+ PLUGIN_CONFIG_KEY_REMOTE,
+} from './controllers/config.schema';
+import { DefinedNameController } from './controllers/defined-name.controller';
+import { FormulaController } from './controllers/formula.controller';
import { TriggerCalculationController } from './controllers/trigger-calculation.controller';
import { UpdateFormulaController } from './controllers/update-formula.controller';
import { DescriptionService, IDescriptionService } from './services/description.service';
-import { FormulaPromptService, IFormulaPromptService } from './services/prompt.service';
-import { IRegisterFunctionService, RegisterFunctionService } from './services/register-function.service';
-import { DefinedNameController } from './controllers/defined-name.controller';
import { FormulaRefRangeService } from './services/formula-ref-range.service';
+import { IRegisterFunctionService, RegisterFunctionService } from './services/register-function.service';
import { RegisterOtherFormulaService } from './services/register-other-formula.service';
-import { FormulaAlertRenderController } from './controllers/formula-alert-render.controller';
-import { FormulaRenderManagerController } from './controllers/formula-render.controller';
-import { RefSelectionsRenderService } from './services/render-services/ref-selections.render-service';
-import { PromptController } from './controllers/prompt.controller';
import { IRemoteRegisterFunctionService, RemoteRegisterFunctionService, RemoteRegisterFunctionServiceName } from './services/remote/remote-register-function.service';
import type {
IUniverSheetsFormulaBaseConfig,
- IUniverSheetsFormulaMobileConfig,
IUniverSheetsFormulaRemoteConfig,
} from './controllers/config.schema';
-import {
- defaultPluginBaseConfig,
- defaultPluginMobileConfig,
- defaultPluginRemoteConfig,
- PLUGIN_CONFIG_KEY_BASE,
- PLUGIN_CONFIG_KEY_MOBILE,
- PLUGIN_CONFIG_KEY_REMOTE,
-} from './controllers/config.schema';
@DependentOn(UniverFormulaEnginePlugin)
export class UniverRemoteSheetsFormulaPlugin extends Plugin {
@@ -81,53 +69,39 @@ export class UniverRemoteSheetsFormulaPlugin extends Plugin {
}
}
-/**
- * The configuration of the formula UI plugin.
- */
-@DependentOn(UniverFormulaEnginePlugin)
+@DependentOn(UniverFormulaEnginePlugin, UniverSheetsPlugin)
export class UniverSheetsFormulaPlugin extends Plugin {
- static override pluginName = FORMULA_UI_PLUGIN_NAME;
+ static override pluginName = SHEETS_FORMULA_PLUGIN_NAME;
static override type = UniverInstanceType.UNIVER_SHEET;
constructor(
private readonly _config: Partial<IUniverSheetsFormulaBaseConfig> = defaultPluginBaseConfig,
@Inject(Injector) override readonly _injector: Injector,
- @IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
@IConfigService private readonly _configService: IConfigService
) {
super();
// Manage the plugin configuration.
- const { menu, ...rest } = this._config;
- if (menu) {
- this._configService.setConfig('menu', menu, { merge: true });
- }
+ const { ...rest } = this._config;
this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest);
}
override onStarting(): void {
const j = this._injector;
const dependencies: Dependency[] = [
- [IFormulaPromptService, { useClass: FormulaPromptService }],
- [IRefSelectionsService, { useClass: RefSelectionsService }],
- [IDescriptionService, { useClass: DescriptionService }],
[IRegisterFunctionService, { useClass: RegisterFunctionService }],
+ [IDescriptionService, { useClass: DescriptionService }],
+ [FormulaController],
[FormulaRefRangeService],
[RegisterOtherFormulaService],
- [FormulaUIController],
- [FormulaAutoFillController],
- [FormulaClipboardController],
- [ArrayFormulaDisplayController],
+ [ArrayFormulaCellInterceptorController],
[TriggerCalculationController],
[UpdateFormulaController],
- [FormulaEditorShowController],
[ActiveDirtyController],
[DefinedNameController],
- [FormulaRenderManagerController],
- [PromptController],
];
- // If the plugin do not execute formula, it should delegate a remote calculator.
+ // If the plugin do not execute formula, it should delegate a remote proxy.
// So custom functions should be synced to that remote calculator.
if (this._config.notExecuteFormula) {
const rpcChannelService = j.get(IRPCChannelService);
@@ -139,56 +113,43 @@ export class UniverSheetsFormulaPlugin extends Plugin {
dependencies.forEach((dependency) => j.add(dependency));
}
- override onRendered(): void {
- ([
- [RefSelectionsRenderService],
- [FormulaAlertRenderController],
- ] as Dependency[]).forEach((dep) => {
- this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, dep));
- });
+ override onReady(): void {
+ this._injector.get(TriggerCalculationController);
+ this._injector.get(FormulaController);
}
}
+// TODO@wzhudev: after I separate the sheets-formula-ui plugin,
+// I found out that `UniverSheetsFormulaPlugin` provides the same services as `UniverSheetsFormulaMobilePlugin`.
+// The the later on can be removed.
+
export class UniverSheetsFormulaMobilePlugin extends Plugin {
- static override pluginName = FORMULA_UI_PLUGIN_NAME;
+ static override pluginName = SHEETS_FORMULA_PLUGIN_NAME;
static override type = UniverInstanceType.UNIVER_SHEET;
constructor(
- private readonly _config: Partial<IUniverSheetsFormulaMobileConfig> = defaultPluginMobileConfig,
- @Inject(Injector) override readonly _injector: Injector,
- @IConfigService private readonly _configService: IConfigService
+ private readonly _config: undefined,
+ @Inject(Injector) override readonly _injector: Injector
) {
super();
-
- // Manage the plugin configuration.
- const { menu, ...rest } = this._config;
- if (menu) {
- this._configService.setConfig('menu', menu, { merge: true });
- }
- this._configService.setConfig(PLUGIN_CONFIG_KEY_MOBILE, rest);
}
override onStarting(): void {
- this._init();
- }
-
- _init(): void {
const dependencies: Dependency[] = [
- // services
- [IFormulaPromptService, { useClass: FormulaPromptService }],
- [IDescriptionService, { useClass: DescriptionService }],
[IRegisterFunctionService, { useClass: RegisterFunctionService }],
[FormulaRefRangeService],
[RegisterOtherFormulaService],
- [FormulaClipboardController],
- [ArrayFormulaDisplayController],
+ [ArrayFormulaCellInterceptorController],
[TriggerCalculationController],
[UpdateFormulaController],
[ActiveDirtyController],
[DefinedNameController],
- [FormulaRenderManagerController],
];
dependencies.forEach((dependency) => this._injector.add(dependency));
}
+
+ override onReady(): void {
+ ([TriggerCalculationController]).forEach((module) => this._injector.get(module));
+ }
}
diff --git a/packages/sheets-ui/src/sheets-ui-plugin.ts b/packages/sheets-ui/src/sheets-ui-plugin.ts
index e381ac2baf..08e66ecf6d 100644
--- a/packages/sheets-ui/src/sheets-ui-plugin.ts
+++ b/packages/sheets-ui/src/sheets-ui-plugin.ts
@@ -16,7 +16,7 @@
import { DependentOn, IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
-import { UniverSheetsPlugin } from '@univerjs/sheets';
+import { IRefSelectionsService, RefSelectionsService, UniverSheetsPlugin } from '@univerjs/sheets';
import { PLUGIN_CONFIG_KEY as UI_PLUGIN_CONFIG_KEY } from '@univerjs/ui';
import { filter } from 'rxjs/operators';
@@ -119,6 +119,7 @@ export class UniverSheetsUIPlugin extends Plugin {
[IFormatPainterService, { useClass: FormatPainterService }],
[ICellEditorManagerService, { useClass: CellEditorManagerService }],
[IFormulaEditorManagerService, { useClass: FormulaEditorManagerService }],
+ [IRefSelectionsService, { useClass: RefSelectionsService }],
[IAutoFillService, { useClass: AutoFillService }],
[SheetPrintInterceptorService],
[IStatusBarService, { useClass: StatusBarService }],
diff --git a/packages/sheets/src/controllers/calculate-result-apply.controller.ts b/packages/sheets/src/controllers/calculate-result-apply.controller.ts
index 186935d069..1c9d17b7dd 100644
--- a/packages/sheets/src/controllers/calculate-result-apply.controller.ts
+++ b/packages/sheets/src/controllers/calculate-result-apply.controller.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle } from '@univerjs/core';
-import type { ISetFormulaCalculationResultMutation } from '@univerjs/engine-formula';
import { handleNumfmtInCell, SetFormulaCalculationResultMutation } from '@univerjs/engine-formula';
+import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
+import type { ISetFormulaCalculationResultMutation } from '@univerjs/engine-formula';
import { SetRangeValuesMutation } from '../commands/mutations/set-range-values.mutation';
diff --git a/packages/sheets/src/services/sheet-interceptor/interceptor-const.ts b/packages/sheets/src/services/sheet-interceptor/interceptor-const.ts
index 303b2ac07f..fb39360aa1 100644
--- a/packages/sheets/src/services/sheet-interceptor/interceptor-const.ts
+++ b/packages/sheets/src/services/sheet-interceptor/interceptor-const.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { createInterceptorKey } from '@univerjs/core';
import type { ICellData, ICellDataForSheetInterceptor, ICellInterceptor, Nullable } from '@univerjs/core';
-
import type { ISheetLocation, ISheetRowLocation } from './utils/interceptor';
+import { createInterceptorKey } from '@univerjs/core';
+
const CELL_CONTENT = createInterceptorKey<ICellDataForSheetInterceptor, ISheetLocation & { rawData: Nullable<ICellData> }>('CELL_CONTENT') as ICellInterceptor<ICellDataForSheetInterceptor, ISheetLocation & { rawData: Nullable<ICellData> }>;
const ROW_FILTERED = createInterceptorKey<boolean, ISheetRowLocation>('ROW_FILTERED');
diff --git a/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts b/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts
index f82229846e..738308cf5b 100644
--- a/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts
+++ b/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts
@@ -14,16 +14,6 @@
* limitations under the License.
*/
-import {
- composeInterceptors,
- Disposable,
- DisposableCollection,
- InterceptorEffectEnum,
- IUniverInstanceService,
- remove,
- toDisposable,
- UniverInstanceType,
-} from '@univerjs/core';
import type {
ICellData,
ICellInterceptor,
@@ -36,6 +26,16 @@ import type {
Workbook,
Worksheet,
} from '@univerjs/core';
+import {
+ composeInterceptors,
+ Disposable,
+ DisposableCollection,
+ InterceptorEffectEnum,
+ IUniverInstanceService,
+ remove,
+ toDisposable,
+ UniverInstanceType,
+} from '@univerjs/core';
import { INTERCEPTOR_POINT } from './interceptor-const';
diff --git a/packages/sheets/src/sheets-plugin.ts b/packages/sheets/src/sheets-plugin.ts
index 9a8f2f7854..0a320426ca 100644
--- a/packages/sheets/src/sheets-plugin.ts
+++ b/packages/sheets/src/sheets-plugin.ts
@@ -16,7 +16,6 @@
import type { Dependency } from '@univerjs/core';
import type { IUniverSheetsConfig } from './controllers/config.schema';
-
import { DependentOn, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { BasicWorksheetController } from './controllers/basic-worksheet.controller';
@@ -25,14 +24,13 @@ import { ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY } from './controllers/confi
import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
import { DefinedNameDataController } from './controllers/defined-name-data.controller';
import { MergeCellController } from './controllers/merge-cell.controller';
-
import { NumberCellDisplayController } from './controllers/number-cell.controller';
import { RangeProtectionCache } from './model/range-protection.cache';
import { RangeProtectionRenderModel } from './model/range-protection-render.model';
import { RangeProtectionRuleModel } from './model/range-protection-rule.model';
import { BorderStyleManagerService } from './services/border-style-manager.service';
-import { ExclusiveRangeService, IExclusiveRangeService } from './services/exclusive-range/exclusive-range-service';
+import { ExclusiveRangeService, IExclusiveRangeService } from './services/exclusive-range/exclusive-range-service';
import { NumfmtService } from './services/numfmt/numfmt.service';
import { INumfmtService } from './services/numfmt/type';
import { RangeProtectionRefRangeService } from './services/permission/range-permission/range-protection.ref-range';
diff --git a/packages/ui/src/services/progress/progress.service.ts b/packages/ui/src/services/progress/progress.service.ts
index 1ddbfbe373..8004fd2db6 100644
--- a/packages/ui/src/services/progress/progress.service.ts
+++ b/packages/ui/src/services/progress/progress.service.ts
@@ -15,9 +15,9 @@
*/
import { createIdentifier, Disposable } from '@univerjs/core';
+import { Subject } from 'rxjs';
import type { IDisposable } from '@univerjs/core';
import type { Observable } from 'rxjs';
-import { Subject } from 'rxjs';
export interface IProgressCount {
count: number;
@@ -32,14 +32,17 @@ export interface IProgressService {
progressVisible$: Observable<boolean>;
/**
- * Append subtask quantity during loading, when the number of added subtasks reaches the total number of tasks, the loading is completed.
+ * Append subtask quantity during loading, when the number of added subtasks reaches the total number
+ * of tasks, the loading is completed.
* @param task
*/
pushTask(task: IProgressCount): void;
/**
- * Insert a new number of tasks, do not set the start loading mechanism, when insertTaskCount finds that the original number of tasks is 0, it starts loading
+ * Insert a new number of tasks, do not set the start loading mechanism, when insertTaskCount finds that the
+ * original number of tasks is 0, it starts loading
* @param count
+ this._progress$.complete();
*/
insertTaskCount(count: number): void;
diff --git a/playwright.config.ts b/playwright.config.ts
index c0dd322a0c..406f78285a 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -81,7 +81,7 @@ export default defineConfig({
webServer: {
command: 'pnpm serve:e2e',
- url: 'http://localhost:3000/sheets',
+ url: 'http://localhost:3000',
reuseExistingServer: !isCI,
timeout: 10_000,
stdout: 'ignore',
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 261c82c3e7..ce76dff89a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -273,6 +273,9 @@ importers:
'@univerjs/sheets-data-validation':
specifier: workspace:*
version: link:../packages/sheets-data-validation
+ '@univerjs/sheets-data-validation-ui':
+ specifier: workspace:*
+ version: link:../packages/sheets-data-validation-ui
'@univerjs/sheets-drawing':
specifier: workspace:*
version: link:../packages/sheets-drawing
@@ -291,6 +294,9 @@ importers:
'@univerjs/sheets-formula':
specifier: workspace:*
version: link:../packages/sheets-formula
+ '@univerjs/sheets-formula-ui':
+ specifier: workspace:*
+ version: link:../packages/sheets-formula-ui
'@univerjs/sheets-hyper-link':
specifier: workspace:*
version: link:../packages/sheets-hyper-link
@@ -793,6 +799,9 @@ importers:
'@univerjs/sheets-formula':
specifier: workspace:*
version: link:../../packages/sheets-formula
+ '@univerjs/sheets-formula-ui':
+ specifier: workspace:*
+ version: link:../../packages/sheets-formula-ui
'@univerjs/slides':
specifier: workspace:*
version: link:../../packages/slides
@@ -1739,6 +1748,9 @@ importers:
'@univerjs/sheets-formula':
specifier: workspace:*
version: link:../sheets-formula
+ '@univerjs/sheets-formula-ui':
+ specifier: workspace:*
+ version: link:../sheets-formula-ui
'@univerjs/sheets-hyper-link':
specifier: workspace:*
version: link:../sheets-hyper-link
@@ -2073,6 +2085,73 @@ importers:
packages/sheets-data-validation:
+ dependencies:
+ '@flatten-js/interval-tree':
+ specifier: ^1.1.3
+ version: 1.1.3
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/data-validation':
+ specifier: workspace:*
+ version: link:../data-validation
+ '@univerjs/design':
+ specifier: workspace:*
+ version: link:../design
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/engine-formula':
+ specifier: workspace:*
+ version: link:../engine-formula
+ '@univerjs/engine-render':
+ specifier: workspace:*
+ version: link:../engine-render
+ '@univerjs/icons':
+ specifier: ^0.1.78
+ '@univerjs/protocol':
+ specifier: 0.1.39-alpha.15
+ version: 0.1.39-alpha.15(@grpc/[email protected])([email protected])
+ '@univerjs/sheets':
+ specifier: workspace:*
+ version: link:../sheets
+ '@univerjs/sheets-formula':
+ specifier: workspace:*
+ version: link:../sheets-formula
+ '@univerjs/sheets-numfmt':
+ specifier: workspace:*
+ version: link:../sheets-numfmt
+ clsx:
+ specifier: ^2.1.1
+ version: 2.1.1
+ dayjs:
+ specifier: ^1.11.13
+ version: 1.11.13
+ devDependencies:
+ '@univerjs-infra/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ less:
+ specifier: ^4.2.0
+ version: 4.2.0
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.6.2
+ version: 5.6.2
+ vite:
+ specifier: ^5.4.8
+ vitest:
+ specifier: ^2.1.1
+
+ packages/sheets-data-validation-ui:
dependencies:
'@flatten-js/interval-tree':
specifier: ^1.1.3
@@ -2107,6 +2186,9 @@ importers:
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
+ '@univerjs/sheets-data-validation':
+ specifier: workspace:*
+ version: link:../sheets-data-validation
'@univerjs/sheets-formula':
specifier: workspace:*
version: link:../sheets-formula
@@ -2358,6 +2440,67 @@ importers:
packages/sheets-formula:
+ dependencies:
+ '@univerjs/core':
+ specifier: workspace:*
+ version: link:../core
+ '@univerjs/design':
+ specifier: workspace:*
+ version: link:../design
+ '@univerjs/docs':
+ specifier: workspace:*
+ version: link:../docs
+ '@univerjs/engine-formula':
+ specifier: workspace:*
+ version: link:../engine-formula
+ '@univerjs/icons':
+ specifier: ^0.1.78
+ '@univerjs/rpc':
+ specifier: workspace:*
+ version: link:../rpc
+ '@univerjs/sheets':
+ specifier: workspace:*
+ version: link:../sheets
+ '@univerjs/sheets-numfmt':
+ specifier: workspace:*
+ version: link:../sheets-numfmt
+ '@univerjs/sheets-ui':
+ specifier: workspace:*
+ version: link:../sheets-ui
+ '@univerjs/ui':
+ specifier: workspace:*
+ version: link:../ui
+ devDependencies:
+ '@types/react':
+ specifier: ^18.3.9
+ version: 18.3.9
+ '@univerjs-infra/shared':
+ specifier: workspace:*
+ version: link:../../common/shared
+ '@vitejs/plugin-react':
+ specifier: ^4.3.1
+ less:
+ specifier: ^4.2.0
+ version: 4.2.0
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ rxjs:
+ specifier: ^7.8.1
+ version: 7.8.1
+ typescript:
+ specifier: ^5.6.2
+ version: 5.6.2
+ vite:
+ specifier: ^5.4.8
+ vitest:
+ specifier: ^2.1.1
+
+ packages/sheets-formula-ui:
dependencies:
'@univerjs/core':
specifier: workspace:*
@@ -2386,6 +2529,12 @@ importers:
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
+ '@univerjs/sheets-filter':
+ specifier: workspace:*
+ version: link:../sheets-filter
+ '@univerjs/sheets-formula':
+ specifier: workspace:*
+ version: link:../sheets-formula
'@univerjs/sheets-numfmt':
specifier: workspace:*
version: link:../sheets-numfmt
@@ -2397,7 +2546,7 @@ importers:
version: link:../ui
devDependencies:
'@types/react':
- specifier: ^18.3.9
+ specifier: ^18.3.5
version: 18.3.9
'@univerjs-infra/shared':
specifier: workspace:*
@@ -2418,10 +2567,10 @@ importers:
specifier: ^5.6.2
version: 5.6.2
vite:
- specifier: ^5.4.8
+ specifier: ^5.4.4
vitest:
- specifier: ^2.1.1
+ specifier: ^2.0.5
packages/sheets-hyper-link: