@univerjs/sheets-data-validation 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +29 -0
  3. package/lib/cjs/index.js +9 -0
  4. package/lib/es/index.js +6749 -0
  5. package/lib/index.css +1 -0
  6. package/lib/types/commands/commands/data-validation.command.d.ts +21 -0
  7. package/lib/types/commands/mutations/formula.mutation.d.ts +10 -0
  8. package/lib/types/commands/operations/data-validation.operation.d.ts +18 -0
  9. package/lib/types/common/const.d.ts +18 -0
  10. package/lib/types/common/date-text-map.d.ts +6 -0
  11. package/lib/types/controllers/dv-alert.controller.d.ts +14 -0
  12. package/lib/types/controllers/dv-auto-fill.controller.d.ts +10 -0
  13. package/lib/types/controllers/dv-copy-paste.controller.d.ts +13 -0
  14. package/lib/types/controllers/dv-ref-range.controller.d.ts +29 -0
  15. package/lib/types/controllers/dv-reject-input.controller.d.ts +14 -0
  16. package/lib/types/controllers/dv-render.controller.d.ts +29 -0
  17. package/lib/types/controllers/dv-resource.controller.d.ts +14 -0
  18. package/lib/types/controllers/dv-sheet.controller.d.ts +13 -0
  19. package/lib/types/controllers/dv.controller.d.ts +22 -0
  20. package/lib/types/controllers/dv.menu.d.ts +7 -0
  21. package/lib/types/index.d.ts +37 -0
  22. package/lib/types/locale/en-US.d.ts +4 -0
  23. package/lib/types/locale/index.d.ts +17 -0
  24. package/lib/types/locale/zh-CN.d.ts +160 -0
  25. package/lib/types/models/rule-matrix.d.ts +28 -0
  26. package/lib/types/models/sheet-data-validation-manager.d.ts +28 -0
  27. package/lib/types/plugin.d.ts +10 -0
  28. package/lib/types/services/data-validation-panel.service.d.ts +27 -0
  29. package/lib/types/services/dropdown-manager.service.d.ts +37 -0
  30. package/lib/types/services/dv-cache.service.d.ts +21 -0
  31. package/lib/types/services/dv-custom-formula.service.d.ts +41 -0
  32. package/lib/types/services/dv-formula.service.d.ts +21 -0
  33. package/lib/types/services/dv.service.d.ts +20 -0
  34. package/lib/types/services/dv.tips.d.ts +17 -0
  35. package/lib/types/services/formula-common.d.ts +19 -0
  36. package/lib/types/services/register-formula.service.d.ts +28 -0
  37. package/lib/types/types/const/index.d.ts +17 -0
  38. package/lib/types/types/const/operator-text-map.d.ts +5 -0
  39. package/lib/types/types/const/two-formula-operators.d.ts +3 -0
  40. package/lib/types/types/index.d.ts +17 -0
  41. package/lib/types/types/interface/i-update-rule-formula.d.ts +19 -0
  42. package/lib/types/types/interface/index.d.ts +16 -0
  43. package/lib/types/utils/date.d.ts +17 -0
  44. package/lib/types/utils/formula.d.ts +3 -0
  45. package/lib/types/utils/get-cell-data-origin.d.ts +3 -0
  46. package/lib/types/validators/checkbox-validator.d.ts +25 -0
  47. package/lib/types/validators/custom-validator.d.ts +15 -0
  48. package/lib/types/validators/date-validator.d.ts +31 -0
  49. package/lib/types/validators/decimal-validator.d.ts +36 -0
  50. package/lib/types/validators/index.d.ts +20 -0
  51. package/lib/types/validators/list-multiple-validator.d.ts +27 -0
  52. package/lib/types/validators/list-validator.d.ts +28 -0
  53. package/lib/types/validators/text-length-validator.d.ts +32 -0
  54. package/lib/types/validators/util.d.ts +6 -0
  55. package/lib/types/validators/whole-validator.d.ts +35 -0
  56. package/lib/types/views/date-dropdown/index.d.ts +4 -0
  57. package/lib/types/views/detail/index.d.ts +3 -0
  58. package/lib/types/views/drop-down/CellDropdown.d.ts +3 -0
  59. package/lib/types/views/drop-down/index.d.ts +18 -0
  60. package/lib/types/views/formula-input/base-formula-input.d.ts +4 -0
  61. package/lib/types/views/formula-input/checkbox-formula-input.d.ts +4 -0
  62. package/lib/types/views/formula-input/custom-formula-input.d.ts +4 -0
  63. package/lib/types/views/formula-input/formula-input.d.ts +5 -0
  64. package/lib/types/views/formula-input/index.d.ts +7 -0
  65. package/lib/types/views/formula-input/list-formula-input.d.ts +4 -0
  66. package/lib/types/views/index.d.ts +20 -0
  67. package/lib/types/views/item/index.d.ts +10 -0
  68. package/lib/types/views/list/index.d.ts +3 -0
  69. package/lib/types/views/list-dropdown/index.d.ts +4 -0
  70. package/lib/types/views/options/index.d.ts +9 -0
  71. package/lib/types/views/panel/index.d.ts +3 -0
  72. package/lib/types/views/render-mode/index.d.ts +11 -0
  73. package/lib/types/widgets/checkbox-widget.d.ts +20 -0
  74. package/lib/types/widgets/dropdown-multiple-widget.d.ts +20 -0
  75. package/lib/types/widgets/dropdown-widget.d.ts +32 -0
  76. package/lib/types/widgets/shape/dropdown.d.ts +13 -0
  77. package/lib/types/widgets/shape/index.d.ts +18 -0
  78. package/lib/types/widgets/shape/layout.d.ts +38 -0
  79. package/lib/umd/index.js +9 -0
  80. package/package.json +79 -0
@@ -0,0 +1,21 @@
1
+ import { ObjectMatrix, CellValue, DataValidationStatus, IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';
2
+
3
+ export interface IDataValidationResCache {
4
+ value: Nullable<CellValue>;
5
+ status: DataValidationStatus;
6
+ ruleId: string;
7
+ temp?: boolean;
8
+ }
9
+ export declare class DataValidationCacheService {
10
+ private _cacheMatrix;
11
+ private _ensureCache;
12
+ ensureCache(unitId: string, subUnitId: string): ObjectMatrix<Nullable<IDataValidationResCache>>;
13
+ addRule(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
14
+ removeRule(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
15
+ updateRuleRanges(unitId: string, subUnitId: string, ruleId: string, newRanges: IRange[], oldRanges: IRange[]): void;
16
+ markRangeDirty(unitId: string, subUnitId: string, ranges: IRange[]): void;
17
+ markCellDirty(unitId: string, subUnitId: string, row: number, col: number): void;
18
+ private _deleteRange;
19
+ getValue(unitId: string, subUnitId: string, row: number, col: number): Nullable<IDataValidationResCache>;
20
+ setValue(unitId: string, subUnitId: string, row: number, col: number, value: IDataValidationResCache): void;
21
+ }
@@ -0,0 +1,41 @@
1
+ import { DataValidationCacheService } from './dv-cache.service';
2
+ import { RegisterOtherFormulaService } from './register-formula.service';
3
+ import { DataValidationModel } from '@univerjs/data-validation';
4
+ import { LexerTreeBuilder } from '@univerjs/engine-formula';
5
+ import { IRange, ISheetDataValidationRule, Disposable, IUniverInstanceService } from '@univerjs/core';
6
+
7
+ interface IFormulaData {
8
+ formula: string;
9
+ originRow: number;
10
+ originCol: number;
11
+ isTransformable: boolean;
12
+ formulaId?: string;
13
+ }
14
+ export declare class DataValidationCustomFormulaService extends Disposable {
15
+ private _registerOtherFormulaService;
16
+ private _lexerTreeBuilder;
17
+ private readonly _univerInstanceService;
18
+ private readonly _dataValidationModel;
19
+ private readonly _dataValidationCacheService;
20
+ private _formulaMap;
21
+ /**
22
+ * Map of origin formula of rule
23
+ */
24
+ private _ruleFormulaMap;
25
+ /**
26
+ * reflect of formulaId to cell, only store transformable formula
27
+ */
28
+ private _formulaCellMap;
29
+ constructor(_registerOtherFormulaService: RegisterOtherFormulaService, _lexerTreeBuilder: LexerTreeBuilder, _univerInstanceService: IUniverInstanceService, _dataValidationModel: DataValidationModel, _dataValidationCacheService: DataValidationCacheService);
30
+ private _initFormulaResultHandler;
31
+ private _ensureMaps;
32
+ private _registerFormula;
33
+ deleteByRuleId(unitId: string, subUnitId: string, ruleId: string): void;
34
+ private _addFormulaByRange;
35
+ addRule(unitId: string, subUnitId: string, rule: ISheetDataValidationRule): void;
36
+ updateRuleRanges(unitId: string, subUnitId: string, ruleId: string, oldRanges: IRange[], newRanges: IRange[]): void;
37
+ updateRuleFormula(unitId: string, subUnitId: string, ruleId: string, ranges: IRange[], formula: string): void;
38
+ getCellFormulaValue(unitId: string, subUnitId: string, row: number, col: number): Promise<import('@univerjs/core').Nullable<import("./formula-common").IDataValidationFormulaResult>>;
39
+ getRuleFormulaInfo(unitId: string, subUnitId: string, ruleId: string): IFormulaData | undefined;
40
+ }
41
+ export {};
@@ -0,0 +1,21 @@
1
+ import { DataValidationCacheService } from './dv-cache.service';
2
+ import { RegisterOtherFormulaService } from './register-formula.service';
3
+ import { IDataValidationFormulaResult, IFormulaInfo } from './formula-common';
4
+ import { DataValidationModel } from '@univerjs/data-validation';
5
+ import { Nullable, Disposable } from '@univerjs/core';
6
+
7
+ export declare class DataValidationFormulaService extends Disposable {
8
+ private _registerOtherFormulaService;
9
+ private readonly _dataValidationCacheService;
10
+ private readonly _dataValidationModel;
11
+ private _formulaRuleMap;
12
+ constructor(_registerOtherFormulaService: RegisterOtherFormulaService, _dataValidationCacheService: DataValidationCacheService, _dataValidationModel: DataValidationModel);
13
+ private _initFormulaResultHandler;
14
+ private _ensureRuleFormulaMap;
15
+ addRule(unitId: string, subUnitId: string, ruleId: string, formula1: string | undefined, formula2: string | undefined): void;
16
+ removeRule(unitId: string, subUnitId: string, ruleId: string): void;
17
+ updateRuleFormulaText(unitId: string, subUnitId: string, ruleId: string, formula1: string | undefined, formula2: string | undefined): void;
18
+ getRuleFormulaResult(unitId: string, subUnitId: string, ruleId: string): Promise<Nullable<[Nullable<IDataValidationFormulaResult>, Nullable<IDataValidationFormulaResult>]>>;
19
+ getRuleFormulaResultSync(unitId: string, subUnitId: string, ruleId: string): Nullable<IDataValidationFormulaResult>[] | undefined;
20
+ getRuleFormulaInfo(unitId: string, subUnitId: string, ruleId: string): [IFormulaInfo | undefined, IFormulaInfo | undefined] | undefined;
21
+ }
@@ -0,0 +1,20 @@
1
+ import { SheetDataValidationManager } from '../models/sheet-data-validation-manager';
2
+ import { DataValidationModel } from '@univerjs/data-validation';
3
+ import { Nullable } from '@univerjs/core';
4
+
5
+ export interface ICurrentDataValidationManager {
6
+ manager: SheetDataValidationManager;
7
+ unitId: string;
8
+ subUnitId: string;
9
+ }
10
+ export declare class SheetDataValidationService {
11
+ private _dataValidationModel;
12
+ private _currentManager;
13
+ private _currentManager$;
14
+ get currentManager(): Nullable<ICurrentDataValidationManager>;
15
+ currentManager$: import('rxjs').Observable<ICurrentDataValidationManager>;
16
+ constructor(_dataValidationModel: DataValidationModel);
17
+ private _ensureManager;
18
+ switchCurrent(unitId: string, subUnitId: string): void;
19
+ get(unitId: string, subUnitId: string): SheetDataValidationManager;
20
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare class SheetDataValidationTipsService {
17
+ }
@@ -0,0 +1,19 @@
1
+ import { ICellData, Nullable } from '@univerjs/core';
2
+
3
+ export declare enum FormulaResultStatus {
4
+ NOT_REGISTER = 1,
5
+ SUCCESS = 2,
6
+ WAIT = 3,
7
+ ERROR = 4
8
+ }
9
+ export interface IDataValidationFormulaResult {
10
+ result?: Nullable<ICellData>[][];
11
+ status: FormulaResultStatus;
12
+ ruleId: string;
13
+ formulaId: string;
14
+ callbacks: Set<(value: Nullable<ICellData>[][]) => void>;
15
+ }
16
+ export interface IFormulaInfo {
17
+ id: string;
18
+ text: string;
19
+ }
@@ -0,0 +1,28 @@
1
+ import { IDataValidationFormulaResult } from './formula-common';
2
+ import { IActiveDirtyManagerService } from '@univerjs/engine-formula';
3
+ import { Nullable, Disposable, ICommandService } from '@univerjs/core';
4
+
5
+ export declare class RegisterOtherFormulaService extends Disposable {
6
+ private readonly _commandService;
7
+ private _activeDirtyManagerService;
8
+ private _formulaCacheMap;
9
+ private _formulaChange$;
10
+ formulaChange$: import('rxjs').Observable<{
11
+ unitId: string;
12
+ subUnitId: string;
13
+ ruleId: string;
14
+ formulaText: string;
15
+ formulaId: string;
16
+ }>;
17
+ private _formulaResult$;
18
+ formulaResult$: import('rxjs').Observable<Record<string, Record<string, IDataValidationFormulaResult[]>>>;
19
+ constructor(_commandService: ICommandService, _activeDirtyManagerService: IActiveDirtyManagerService);
20
+ private _ensureCacheMap;
21
+ private _createFormulaId;
22
+ private _initFormulaRegister;
23
+ private _initFormulaCalculationResultChange;
24
+ registerFormula(unitId: string, subUnitId: string, ruleId: string, formulaText: string): string;
25
+ deleteFormula(unitId: string, subUnitId: string, formulaIdList: string[]): void;
26
+ getFormulaValue(unitId: string, subUnitId: string, formulaId: string): Promise<Nullable<IDataValidationFormulaResult>>;
27
+ getFormulaValueSync(unitId: string, subUnitId: string, formulaId: string): Nullable<IDataValidationFormulaResult>;
28
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './operator-text-map';
17
+ export * from './two-formula-operators';
@@ -0,0 +1,5 @@
1
+ import { DataValidationOperator } from '@univerjs/core';
2
+
3
+ export declare const OperatorTextMap: Record<DataValidationOperator, string>;
4
+ export declare const OperatorTitleMap: Record<DataValidationOperator, string>;
5
+ export declare const OperatorErrorTitleMap: Record<DataValidationOperator, string>;
@@ -0,0 +1,3 @@
1
+ import { DataValidationOperator } from '@univerjs/core';
2
+
3
+ export declare const TWO_FORMULA_OPERATOR_COUNT: DataValidationOperator[];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './interface';
17
+ export * from './const';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export interface IUpdateDataValidationFormulaPayload {
17
+ type: 'formula1' | 'formula2';
18
+ formulaString: string;
19
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './i-update-rule-formula';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare function toYMD_1900(ord: number, leap1900?: boolean): number[];
17
+ export declare const serialTimeToTimestamp: (value: number) => number;
@@ -0,0 +1,3 @@
1
+ import { ICellData, Nullable } from '@univerjs/core';
2
+
3
+ export declare function getFormulaResult(result: Nullable<Nullable<ICellData>[][]>): Nullable<import('@univerjs/core').CellValue>;
@@ -0,0 +1,3 @@
1
+ import { ICellData, Nullable } from '@univerjs/core';
2
+
3
+ export declare function getCellValueOrigin(cell: Nullable<ICellData>): Nullable<import('@univerjs/core').CellValue>;
@@ -0,0 +1,25 @@
1
+ import { CheckboxRender } from '../widgets/checkbox-widget';
2
+ import { ISheetLocation } from '@univerjs/sheets';
3
+ import { BaseDataValidator, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
4
+ import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
5
+
6
+ export declare const CHECKBOX_FORMULA_1 = 1;
7
+ export declare const CHECKBOX_FORMULA_2 = 0;
8
+ export declare class CheckboxValidator extends BaseDataValidator {
9
+ id: string;
10
+ title: string;
11
+ operators: DataValidationOperator[];
12
+ scopes: string | string[];
13
+ formulaInput: string;
14
+ canvasRender: CheckboxRender;
15
+ private _formulaService;
16
+ skipDefaultFontRender(rule: ISheetDataValidationRule, cellValue: Nullable<CellValue>, pos: ISheetLocation): boolean;
17
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
18
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult>;
19
+ parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string): {
20
+ formula1: Nullable<CellValue>;
21
+ formula2: Nullable<CellValue>;
22
+ };
23
+ isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
24
+ generateRuleErrorMessage(rule: IDataValidationRuleBase): string;
25
+ }
@@ -0,0 +1,15 @@
1
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
2
+ import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
3
+
4
+ export declare class CustomFormulaValidator extends BaseDataValidator {
5
+ id: string;
6
+ title: string;
7
+ operators: DataValidationOperator[];
8
+ scopes: string | string[];
9
+ formulaInput: string;
10
+ private _customFormulaService;
11
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
12
+ parseFormula(_rule: IDataValidationRule, _unitId: string, _subUnitId: string): Promise<IFormulaResult>;
13
+ isValidType(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
14
+ generateRuleErrorMessage(rule: IDataValidationRuleBase): string;
15
+ }
@@ -0,0 +1,31 @@
1
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
2
+ import { Dayjs } from 'dayjs';
3
+ import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
4
+
5
+ export declare class DateValidator extends BaseDataValidator<Dayjs> {
6
+ id: string;
7
+ title: string;
8
+ operators: DataValidationOperator[];
9
+ scopes: string | string[];
10
+ formulaInput: string;
11
+ dropdown: string;
12
+ private _formulaService;
13
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<Dayjs | undefined>>;
14
+ transformDate: (value: Nullable<CellValue>) => Dayjs | undefined;
15
+ isValidType(info: IValidatorCellInfo): Promise<boolean>;
16
+ private _validatorSingleFormula;
17
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
18
+ transform(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): IValidatorCellInfo<Dayjs>;
19
+ validatorIsEqual(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>, _rule: IDataValidationRule): Promise<boolean>;
20
+ validatorIsNotEqual(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
21
+ validatorIsBetween(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
22
+ validatorIsNotBetween(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
23
+ validatorIsGreaterThan(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
24
+ validatorIsGreaterThanOrEqual(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
25
+ validatorIsLessThan(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
26
+ validatorIsLessThanOrEqual(info: IValidatorCellInfo<Dayjs>, formula: IFormulaResult<Dayjs | undefined>): Promise<boolean>;
27
+ validatorFormulaValue(rule: IDataValidationRuleBase): string | undefined;
28
+ get operatorNames(): string[];
29
+ generateRuleName(rule: IDataValidationRuleBase): string;
30
+ generateRuleErrorMessage(rule: IDataValidationRuleBase): string;
31
+ }
@@ -0,0 +1,36 @@
1
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
2
+ import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
3
+
4
+ export declare function getCellValueNumber(cellValue: CellValue): number;
5
+ export declare class DecimalValidator extends BaseDataValidator<number> {
6
+ private _formulaService;
7
+ id: string;
8
+ title: string;
9
+ operators: DataValidationOperator[];
10
+ scopes: string | string[];
11
+ formulaInput: string;
12
+ dropDownInput?: string;
13
+ private _isFormulaOrNumber;
14
+ isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
15
+ transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
16
+ value: number;
17
+ row: number;
18
+ column: number;
19
+ unitId: string;
20
+ subUnitId: string;
21
+ };
22
+ private _parseNumber;
23
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<{
24
+ formula1: number;
25
+ formula2: number;
26
+ }>;
27
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
28
+ validatorIsEqual(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
29
+ validatorIsNotEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
30
+ validatorIsBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
31
+ validatorIsNotBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
32
+ validatorIsGreaterThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
33
+ validatorIsGreaterThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
34
+ validatorIsLessThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
35
+ validatorIsLessThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
36
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CheckboxValidator, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from './checkbox-validator';
17
+ export { DateValidator } from './date-validator';
18
+ export { ListValidator } from './list-validator';
19
+ export { DecimalValidator } from './decimal-validator';
20
+ export { TextLengthValidator } from './text-length-validator';
@@ -0,0 +1,27 @@
1
+ import { DropdownMultipleWidget } from '../widgets/dropdown-multiple-widget';
2
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
+ import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
4
+
5
+ export declare class ListMultipleValidator extends BaseDataValidator {
6
+ id: string;
7
+ title: string;
8
+ operators: DataValidationOperator[];
9
+ scopes: string | string[];
10
+ formulaInput: string;
11
+ private _univerInstanceService;
12
+ canvasRender: DropdownMultipleWidget;
13
+ dropdown: string | undefined;
14
+ skipDefaultFontRender(): boolean;
15
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
16
+ parseCellValue(cellValue: CellValue, rule: IDataValidationRule): string[];
17
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<string[] | undefined>>;
18
+ isValidType(cellInfo: IValidatorCellInfo<Nullable<CellValue>>, formula: IFormulaResult<any>, rule: IDataValidationRule): Promise<boolean>;
19
+ generateRuleName(): string;
20
+ generateRuleErrorMessage(): string;
21
+ getList(rule: IDataValidationRule, propUnitId?: string, propSubUnitId?: string): string[];
22
+ getListWithColor(rule: IDataValidationRule, currentUnitId?: string, currentSubUnitId?: string): {
23
+ label: string;
24
+ color: string;
25
+ }[];
26
+ getListWithColorMap(rule: IDataValidationRule, currentUnitId?: string, currentSubUnitId?: string): Record<string, string>;
27
+ }
@@ -0,0 +1,28 @@
1
+ import { DropdownWidget } from '../widgets/dropdown-widget';
2
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
+ import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
4
+
5
+ export declare class ListValidator extends BaseDataValidator {
6
+ id: string;
7
+ title: string;
8
+ operators: DataValidationOperator[];
9
+ scopes: string | string[];
10
+ formulaInput: string;
11
+ private _univerInstanceService;
12
+ canvasRender: DropdownWidget;
13
+ dropdown: string | undefined;
14
+ optionsInput: string | undefined;
15
+ skipDefaultFontRender(rule: ISheetDataValidationRule): boolean;
16
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
17
+ private _parseCellValue;
18
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<string[] | undefined>>;
19
+ isValidType(cellInfo: IValidatorCellInfo<Nullable<CellValue>>, formula: IFormulaResult<any>, rule: IDataValidationRule): Promise<boolean>;
20
+ generateRuleName(): string;
21
+ generateRuleErrorMessage(): string;
22
+ getList(rule: IDataValidationRule, currentUnitId?: string, currentSubUnitId?: string): string[];
23
+ getListWithColor(rule: IDataValidationRule, currentUnitId?: string, currentSubUnitId?: string): {
24
+ label: string;
25
+ color: string;
26
+ }[];
27
+ getListWithColorMap(rule: IDataValidationRule, currentUnitId?: string, currentSubUnitId?: string): Record<string, string>;
28
+ }
@@ -0,0 +1,32 @@
1
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
2
+ import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
3
+
4
+ export declare class TextLengthValidator extends BaseDataValidator<number> {
5
+ id: string;
6
+ title: string;
7
+ operators: DataValidationOperator[];
8
+ scopes: string | string[];
9
+ formulaInput: string;
10
+ private _formulaService;
11
+ private _isFormulaOrInt;
12
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
13
+ private _parseNumber;
14
+ private _isValidFormula;
15
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<any>>;
16
+ transform(cellInfo: IValidatorCellInfo<CellValue>, _formula: IFormulaResult, _rule: IDataValidationRule): {
17
+ value: number;
18
+ row: number;
19
+ column: number;
20
+ unitId: string;
21
+ subUnitId: string;
22
+ };
23
+ isValidType(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
24
+ validatorIsEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
25
+ validatorIsNotEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
26
+ validatorIsBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
27
+ validatorIsNotBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
28
+ validatorIsGreaterThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
29
+ validatorIsGreaterThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
30
+ validatorIsLessThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
31
+ validatorIsLessThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
32
+ }
@@ -0,0 +1,6 @@
1
+ import { ICellData, IUnitRangeName, IUniverInstanceService, Nullable } from '@univerjs/core';
2
+
3
+ export declare function getSheetRangeValueSet(grid: IUnitRangeName, univerInstanceService: IUniverInstanceService, currUnitId: string, currSubUnitId: string): string[];
4
+ export declare function serializeListOptions(options: string[]): string;
5
+ export declare function deserializeListOptions(optionsStr: string): string[];
6
+ export declare function getDataValidationCellValue(cellData: Nullable<ICellData>): string;
@@ -0,0 +1,35 @@
1
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
2
+ import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
3
+
4
+ export declare class WholeValidator extends BaseDataValidator<number> {
5
+ private _formulaService;
6
+ id: string;
7
+ title: string;
8
+ operators: DataValidationOperator[];
9
+ scopes: string | string[];
10
+ formulaInput: string;
11
+ dropDownInput?: string;
12
+ private _isFormulaOrInt;
13
+ isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
14
+ transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
15
+ value: number;
16
+ row: number;
17
+ column: number;
18
+ unitId: string;
19
+ subUnitId: string;
20
+ };
21
+ private _parseNumber;
22
+ parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<{
23
+ formula1: number;
24
+ formula2: number;
25
+ }>;
26
+ validatorFormula(rule: IDataValidationRuleBase): IFormulaValidResult;
27
+ validatorIsEqual(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
28
+ validatorIsNotEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
29
+ validatorIsBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
30
+ validatorIsNotBetween(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
31
+ validatorIsGreaterThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
32
+ validatorIsGreaterThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
33
+ validatorIsLessThan(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
34
+ validatorIsLessThanOrEqual(cellInfo: IValidatorCellInfo<number>, formula: IFormulaResult, _rule: IDataValidationRule): Promise<boolean>;
35
+ }
@@ -0,0 +1,4 @@
1
+ import { IDropdownComponentProps } from '../../services/dropdown-manager.service';
2
+ import { default as React } from 'react';
3
+
4
+ export declare function DateDropdown(props: IDropdownComponentProps): React.JSX.Element | null | undefined;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare function DataValidationDetail(): React.JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare function CellDropdown(): React.JSX.Element | null;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CellDropdown } from './CellDropdown';
17
+ declare const DROP_DOWN_KEY = "sheet.ui.dropdown";
18
+ export { DROP_DOWN_KEY };
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { IFormulaInputProps } from '@univerjs/data-validation';
3
+
4
+ export declare const BaseFormulaInput: (props: IFormulaInputProps) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { IFormulaInputProps } from '@univerjs/data-validation';
3
+
4
+ export declare function CheckboxFormulaInput(props: IFormulaInputProps): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { IFormulaInputProps } from '@univerjs/data-validation';
2
+ import { default as React } from 'react';
3
+
4
+ export declare function CustomFormulaInput(props: IFormulaInputProps): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { FormulaInputType } from '@univerjs/data-validation';
2
+
3
+ export declare const BASE_FORMULA_INPUT_NAME = "data-validation.formula-input";
4
+ export declare const LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input";
5
+ export declare const FORMULA_INPUTS: [string, FormulaInputType][];
@@ -0,0 +1,7 @@
1
+ import { FormulaInputType } from '@univerjs/data-validation';
2
+
3
+ export declare const CUSTOM_FORMULA_INPUT_NAME = "data-validation.custom-formula-input";
4
+ export declare const BASE_FORMULA_INPUT_NAME = "data-validation.formula-input";
5
+ export declare const LIST_FORMULA_INPUT_NAME = "data-validation.list-formula-input";
6
+ export declare const CHECKBOX_FORMULA_INPUT_NAME = "data-validation.checkbox-formula-input";
7
+ export declare const FORMULA_INPUTS: [string, FormulaInputType][];