@univerjs/sheets-data-validation 0.3.0 → 0.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +2 -2
  2. package/lib/cjs/index.js +1 -9
  3. package/lib/es/index.js +321 -3172
  4. package/lib/types/commands/commands/data-validation.command.d.ts +0 -1
  5. package/lib/types/common/const.d.ts +0 -1
  6. package/lib/types/controllers/config.schema.d.ts +15 -3
  7. package/lib/types/controllers/dv-ref-range.controller.d.ts +1 -1
  8. package/lib/types/controllers/dv.controller.d.ts +1 -4
  9. package/lib/types/index.d.ts +10 -4
  10. package/lib/types/plugin.d.ts +3 -1
  11. package/lib/types/utils/create.d.ts +1 -1
  12. package/lib/types/validators/checkbox-validator.d.ts +2 -5
  13. package/lib/types/validators/custom-validator.d.ts +0 -1
  14. package/lib/types/validators/date-validator.d.ts +2 -5
  15. package/lib/types/validators/decimal-validator.d.ts +1 -3
  16. package/lib/types/validators/list-multiple-validator.d.ts +0 -2
  17. package/lib/types/validators/list-validator.d.ts +2 -6
  18. package/lib/types/validators/text-length-validator.d.ts +1 -2
  19. package/lib/types/validators/whole-validator.d.ts +1 -3
  20. package/lib/umd/index.js +1 -9
  21. package/package.json +17 -37
  22. package/lib/index.css +0 -1
  23. package/lib/locale/en-US.json +0 -167
  24. package/lib/locale/ru-RU.json +0 -167
  25. package/lib/locale/vi-VN.json +0 -167
  26. package/lib/locale/zh-CN.json +0 -167
  27. package/lib/locale/zh-TW.json +0 -167
  28. package/lib/types/commands/operations/data-validation.operation.d.ts +0 -17
  29. package/lib/types/controllers/dv-alert.controller.d.ts +0 -14
  30. package/lib/types/controllers/dv-auto-fill.controller.d.ts +0 -10
  31. package/lib/types/controllers/dv-copy-paste.controller.d.ts +0 -13
  32. package/lib/types/controllers/dv-permission.controller.d.ts +0 -9
  33. package/lib/types/controllers/dv-reject-input.controller.d.ts +0 -15
  34. package/lib/types/controllers/dv-render.controller.d.ts +0 -39
  35. package/lib/types/controllers/dv.menu.d.ts +0 -7
  36. package/lib/types/controllers/menu.schema.d.ts +0 -2
  37. package/lib/types/locale/en-US.d.ts +0 -3
  38. package/lib/types/locale/ru-RU.d.ts +0 -3
  39. package/lib/types/locale/vi-VN.d.ts +0 -3
  40. package/lib/types/locale/zh-CN.d.ts +0 -183
  41. package/lib/types/locale/zh-TW.d.ts +0 -3
  42. package/lib/types/mobile-plugin.d.ts +0 -12
  43. package/lib/types/services/data-validation-panel.service.d.ts +0 -32
  44. package/lib/types/services/dropdown-manager.service.d.ts +0 -40
  45. package/lib/types/views/date-dropdown/index.d.ts +0 -3
  46. package/lib/types/views/detail/index.d.ts +0 -2
  47. package/lib/types/views/drop-down/CellDropdown.d.ts +0 -2
  48. package/lib/types/views/drop-down/index.d.ts +0 -18
  49. package/lib/types/views/formula-input/base-formula-input.d.ts +0 -3
  50. package/lib/types/views/formula-input/checkbox-formula-input.d.ts +0 -3
  51. package/lib/types/views/formula-input/custom-formula-input.d.ts +0 -3
  52. package/lib/types/views/formula-input/formula-input.d.ts +0 -4
  53. package/lib/types/views/formula-input/index.d.ts +0 -6
  54. package/lib/types/views/formula-input/list-formula-input.d.ts +0 -3
  55. package/lib/types/views/index.d.ts +0 -20
  56. package/lib/types/views/item/index.d.ts +0 -10
  57. package/lib/types/views/list/index.d.ts +0 -2
  58. package/lib/types/views/list-dropdown/index.d.ts +0 -3
  59. package/lib/types/views/options/index.d.ts +0 -8
  60. package/lib/types/views/panel/index.d.ts +0 -2
  61. package/lib/types/views/render-mode/index.d.ts +0 -10
  62. package/lib/types/views/show-time/index.d.ts +0 -10
  63. package/lib/types/widgets/checkbox-widget.d.ts +0 -19
  64. package/lib/types/widgets/dropdown-multiple-widget.d.ts +0 -19
  65. package/lib/types/widgets/dropdown-widget.d.ts +0 -28
  66. package/lib/types/widgets/shape/dropdown.d.ts +0 -12
  67. package/lib/types/widgets/shape/index.d.ts +0 -18
  68. package/lib/types/widgets/shape/layout.d.ts +0 -37
@@ -19,7 +19,6 @@ export interface IAddSheetDataValidationCommandParams {
19
19
  rule: ISheetDataValidationRule;
20
20
  }
21
21
  export declare const AddSheetDataValidationCommand: ICommand<IAddSheetDataValidationCommandParams>;
22
- export declare const AddSheetDataValidationAndOpenCommand: ICommand;
23
22
  export interface IUpdateSheetDataValidationSettingCommandParams extends ISheetCommandSharedParams {
24
23
  ruleId: string;
25
24
  setting: IDataValidationRuleBase;
@@ -14,5 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN";
17
- export declare const DROP_DOWN_DEFAULT_COLOR = "#ECECEC";
18
17
  export declare const DROP_DOWN_COLORS: never[];
@@ -1,8 +1,20 @@
1
- import { MenuConfig } from '@univerjs/ui';
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
+ */
2
16
  export declare const PLUGIN_CONFIG_KEY = "sheets-data-validation.config";
3
17
  export declare const configSymbol: unique symbol;
4
18
  export interface IUniverSheetsDataValidationConfig {
5
- menu?: MenuConfig;
6
- showEditOnDropdown?: boolean;
7
19
  }
8
20
  export declare const defaultPluginConfig: IUniverSheetsDataValidationConfig;
@@ -1,4 +1,4 @@
1
- import { Disposable, Injector, ISheetDataValidationRule } from '@univerjs/core';
1
+ import { ISheetDataValidationRule, Disposable, Injector } from '@univerjs/core';
2
2
  import { RefRangeService } from '@univerjs/sheets';
3
3
  import { FormulaRefRangeService } from '@univerjs/sheets-formula';
4
4
  import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
@@ -1,19 +1,16 @@
1
1
  import { Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
2
  import { DataValidatorRegistryService } from '@univerjs/data-validation';
3
3
  import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
4
- import { ComponentManager } from '@univerjs/ui';
5
4
  import { SheetDataValidationModel } from '../models/sheet-data-validation-model';
6
5
  export declare class DataValidationController extends RxDisposable {
7
6
  private readonly _univerInstanceService;
8
7
  private readonly _dataValidatorRegistryService;
9
8
  private readonly _injector;
10
- private readonly _componentManger;
11
9
  private _selectionManagerService;
12
10
  private readonly _sheetInterceptorService;
13
11
  private readonly _sheetDataValidationModel;
14
- constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _injector: Injector, _componentManger: ComponentManager, _selectionManagerService: SheetsSelectionsService, _sheetInterceptorService: SheetInterceptorService, _sheetDataValidationModel: SheetDataValidationModel);
12
+ constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _injector: Injector, _selectionManagerService: SheetsSelectionsService, _sheetInterceptorService: SheetInterceptorService, _sheetDataValidationModel: SheetDataValidationModel);
15
13
  private _init;
16
14
  private _registerValidators;
17
15
  private _initCommandInterceptor;
18
- private _initComponents;
19
16
  }
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { DATA_VALIDATION_PLUGIN_NAME } from './common/const';
17
- export { UniverSheetsDataValidationMobilePlugin } from './mobile-plugin';
18
17
  export { SheetDataValidationModel } from './models/sheet-data-validation-model';
19
18
  export { UniverSheetsDataValidationPlugin } from './plugin';
20
19
  export { DataValidationCacheService } from './services/dv-cache.service';
@@ -22,7 +21,14 @@ export type { IDataValidationResCache } from './services/dv-cache.service';
22
21
  export { DataValidationCustomFormulaService } from './services/dv-custom-formula.service';
23
22
  export { DataValidationFormulaService } from './services/dv-formula.service';
24
23
  export { SheetsDataValidationValidatorService } from './services/dv-validator-service';
25
- export { DATE_DROPDOWN_KEY, LIST_DROPDOWN_KEY } from './views';
24
+ export { createDefaultNewRule } from './utils/create';
25
+ export { DataValidationFormulaController } from './controllers/dv-formula.controller';
26
+ export { getFormulaCellData, getFormulaResult } from './utils/formula';
27
+ export { getCellValueOrigin } from './utils/get-cell-data-origin';
28
+ export { ListValidator } from './validators/list-validator';
29
+ export { DateValidator } from './validators/date-validator';
30
+ export { CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CheckboxValidator, transformCheckboxValue } from './validators/checkbox-validator';
31
+ export { ListMultipleValidator } from './validators/list-multiple-validator';
32
+ export { deserializeListOptions, getDataValidationCellValue, serializeListOptions } from './validators/util';
26
33
  export { DataValidationModel } from '@univerjs/data-validation';
27
- export { AddSheetDataValidationAndOpenCommand, AddSheetDataValidationCommand, ClearRangeDataValidationCommand, type IAddSheetDataValidationCommandParams, type IClearRangeDataValidationCommandParams, type IRemoveSheetAllDataValidationCommandParams, type IRemoveSheetDataValidationCommandParams, type IUpdateSheetDataValidationOptionsCommandParams, type IUpdateSheetDataValidationRangeCommandParams, type IUpdateSheetDataValidationSettingCommandParams, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, } from './commands/commands/data-validation.command';
28
- export { CloseValidationPanelOperation, HideDataValidationDropdown, OpenValidationPanelOperation, ShowDataValidationDropdown, ToggleValidationPanelOperation, } from './commands/operations/data-validation.operation';
34
+ export { AddSheetDataValidationCommand, ClearRangeDataValidationCommand, getDataValidationDiffMutations, type IAddSheetDataValidationCommandParams, type IClearRangeDataValidationCommandParams, type IRemoveSheetAllDataValidationCommandParams, type IRemoveSheetDataValidationCommandParams, type IUpdateSheetDataValidationOptionsCommandParams, type IUpdateSheetDataValidationRangeCommandParams, type IUpdateSheetDataValidationSettingCommandParams, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, } from './commands/commands/data-validation.command';
@@ -1,5 +1,5 @@
1
- import { ICommandService, IConfigService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
2
1
  import { IUniverSheetsDataValidationConfig } from './controllers/config.schema';
2
+ import { ICommandService, IConfigService, Plugin, UniverInstanceType, Injector } from '@univerjs/core';
3
3
  export declare class UniverSheetsDataValidationPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
@@ -9,4 +9,6 @@ export declare class UniverSheetsDataValidationPlugin extends Plugin {
9
9
  static type: UniverInstanceType;
10
10
  constructor(_config: Partial<IUniverSheetsDataValidationConfig> | undefined, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
11
11
  onStarting(): void;
12
+ onReady(): void;
13
+ onRendered(): void;
12
14
  }
@@ -1,4 +1,4 @@
1
- import { DataValidationOperator, DataValidationType, IAccessor } from '@univerjs/core';
1
+ import { IAccessor, DataValidationOperator, DataValidationType } from '@univerjs/core';
2
2
  export declare function createDefaultNewRule(accessor: IAccessor): {
3
3
  uid: string;
4
4
  type: DataValidationType;
@@ -1,6 +1,5 @@
1
- import { WrapStrategy, CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
2
- import { BaseDataValidator, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
3
- import { CheckboxRender } from '../widgets/checkbox-widget';
1
+ import { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable, WrapStrategy } from '@univerjs/core';
2
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
4
3
  export declare const CHECKBOX_FORMULA_1 = 1;
5
4
  export declare const CHECKBOX_FORMULA_2 = 0;
6
5
  interface ICheckboxFormulaResult extends IFormulaResult {
@@ -13,8 +12,6 @@ export declare class CheckboxValidator extends BaseDataValidator {
13
12
  title: string;
14
13
  operators: DataValidationOperator[];
15
14
  scopes: string | string[];
16
- formulaInput: string;
17
- canvasRender: CheckboxRender;
18
15
  private _formulaService;
19
16
  skipDefaultFontRender: (rule: ISheetDataValidationRule, cellValue: Nullable<CellValue>, pos: {
20
17
  unitId: string;
@@ -5,7 +5,6 @@ export declare class CustomFormulaValidator extends BaseDataValidator {
5
5
  title: string;
6
6
  operators: DataValidationOperator[];
7
7
  scopes: string | string[];
8
- formulaInput: string;
9
8
  private _customFormulaService;
10
9
  validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
11
10
  parseFormula(_rule: IDataValidationRule, _unitId: string, _subUnitId: string): Promise<IFormulaResult>;
@@ -1,13 +1,10 @@
1
- import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
2
- import { BaseDataValidator, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
1
+ import { CellValue, IDataValidationRule, IDataValidationRuleBase, DataValidationOperator } from '@univerjs/core';
2
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
3
  export declare class DateValidator extends BaseDataValidator<number> {
4
4
  id: string;
5
5
  title: string;
6
6
  operators: DataValidationOperator[];
7
7
  scopes: string | string[];
8
- formulaInput: string;
9
- optionsInput: string;
10
- dropdown: string;
11
8
  private _formulaService;
12
9
  parseFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): Promise<IFormulaResult<number | undefined>>;
13
10
  parseFormulaSync(rule: IDataValidationRule, unitId: string, subUnitId: string): {
@@ -1,4 +1,4 @@
1
- import { DataValidationOperator, CellValue, IDataValidationRule, Nullable } from '@univerjs/core';
1
+ import { CellValue, IDataValidationRule, Nullable, DataValidationOperator } from '@univerjs/core';
2
2
  import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
3
  export declare function getCellValueNumber(cellValue: CellValue): number;
4
4
  export declare class DecimalValidator extends BaseDataValidator<number> {
@@ -7,8 +7,6 @@ export declare class DecimalValidator extends BaseDataValidator<number> {
7
7
  title: string;
8
8
  operators: DataValidationOperator[];
9
9
  scopes: string | string[];
10
- formulaInput: string;
11
- dropDownInput?: string;
12
10
  private _isFormulaOrNumber;
13
11
  isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
14
12
  transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {
@@ -1,8 +1,6 @@
1
- import { DropdownMultipleWidget } from '../widgets/dropdown-multiple-widget';
2
1
  import { ListValidator } from './list-validator';
3
2
  export declare class ListMultipleValidator extends ListValidator {
4
3
  id: string;
5
4
  title: string;
6
- canvasRender: DropdownMultipleWidget;
7
5
  skipDefaultFontRender: () => boolean;
8
6
  }
@@ -1,6 +1,6 @@
1
- import { BaseDataValidator, IBaseDataValidationWidget, IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
2
- import { LexerTreeBuilder } from '@univerjs/engine-formula';
3
1
  import { CellValue, DataValidationOperator, ICellData, IDataValidationRule, ISheetDataValidationRule, IStyleData, Nullable } from '@univerjs/core';
2
+ import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
+ import { LexerTreeBuilder } from '@univerjs/engine-formula';
4
4
  import { DataValidationFormulaService } from '../services/dv-formula.service';
5
5
  export declare function getRuleFormulaResultSet(result: Nullable<Nullable<ICellData>[][]>): string[];
6
6
  export declare function isValidListFormula(formula: string, lexer: LexerTreeBuilder): boolean | undefined;
@@ -12,10 +12,6 @@ export declare class ListValidator extends BaseDataValidator {
12
12
  title: string;
13
13
  operators: DataValidationOperator[];
14
14
  scopes: string | string[];
15
- formulaInput: string;
16
- canvasRender: Nullable<IBaseDataValidationWidget>;
17
- dropdown: string | undefined;
18
- optionsInput: string | undefined;
19
15
  skipDefaultFontRender: (rule: ISheetDataValidationRule) => boolean;
20
16
  validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
21
17
  getExtraStyle(rule: IDataValidationRule, value: Nullable<CellValue>, { style: defaultStyle }: {
@@ -1,11 +1,10 @@
1
- import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
1
+ import { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable, DataValidationOperator } from '@univerjs/core';
2
2
  import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
3
  export declare class TextLengthValidator extends BaseDataValidator<number> {
4
4
  id: string;
5
5
  title: string;
6
6
  operators: DataValidationOperator[];
7
7
  scopes: string | string[];
8
- formulaInput: string;
9
8
  private _formulaService;
10
9
  private _isFormulaOrInt;
11
10
  validatorFormula(rule: IDataValidationRule, unitId: string, subUnitId: string): IFormulaValidResult;
@@ -1,4 +1,4 @@
1
- import { DataValidationOperator, CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable } from '@univerjs/core';
1
+ import { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable, DataValidationOperator } from '@univerjs/core';
2
2
  import { IFormulaResult, IFormulaValidResult, IValidatorCellInfo, BaseDataValidator } from '@univerjs/data-validation';
3
3
  export declare class WholeValidator extends BaseDataValidator<number> {
4
4
  private _formulaService;
@@ -6,8 +6,6 @@ export declare class WholeValidator extends BaseDataValidator<number> {
6
6
  title: string;
7
7
  operators: DataValidationOperator[];
8
8
  scopes: string | string[];
9
- formulaInput: string;
10
- dropDownInput?: string;
11
9
  private _isFormulaOrInt;
12
10
  isValidType(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): Promise<boolean>;
13
11
  transform(cellInfo: IValidatorCellInfo<CellValue>, formula: IFormulaResult, rule: IDataValidationRule): {