@univerjs/sheets-data-validation 0.24.0 → 0.25.0-insiders.20260608-e4336f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +114 -128
- package/lib/cjs/index.js +185 -160
- package/lib/cjs/locale/ar-SA.js +139 -0
- package/lib/cjs/locale/ca-ES.js +139 -0
- package/lib/cjs/locale/de-DE.js +139 -0
- package/lib/cjs/locale/en-US.js +154 -0
- package/lib/cjs/locale/es-ES.js +139 -0
- package/lib/cjs/locale/fa-IR.js +139 -0
- package/lib/cjs/locale/fr-FR.js +139 -0
- package/lib/cjs/locale/id-ID.js +139 -0
- package/lib/cjs/locale/it-IT.js +139 -0
- package/lib/cjs/locale/ja-JP.js +139 -0
- package/lib/cjs/locale/ko-KR.js +139 -0
- package/lib/cjs/locale/pl-PL.js +139 -0
- package/lib/cjs/locale/pt-BR.js +139 -0
- package/lib/cjs/locale/ru-RU.js +139 -0
- package/lib/cjs/locale/sk-SK.js +139 -0
- package/lib/cjs/locale/vi-VN.js +139 -0
- package/lib/cjs/locale/zh-CN.js +139 -0
- package/lib/cjs/locale/zh-HK.js +139 -0
- package/lib/cjs/locale/zh-TW.js +139 -0
- package/lib/es/facade.js +115 -129
- package/lib/es/index.js +183 -156
- package/lib/es/locale/ar-SA.js +138 -0
- package/lib/es/locale/ca-ES.js +138 -0
- package/lib/es/locale/de-DE.js +138 -0
- package/lib/es/locale/en-US.js +153 -0
- package/lib/es/locale/es-ES.js +138 -0
- package/lib/es/locale/fa-IR.js +138 -0
- package/lib/es/locale/fr-FR.js +138 -0
- package/lib/es/locale/id-ID.js +138 -0
- package/lib/es/locale/it-IT.js +138 -0
- package/lib/es/locale/ja-JP.js +138 -0
- package/lib/es/locale/ko-KR.js +138 -0
- package/lib/es/locale/pl-PL.js +138 -0
- package/lib/es/locale/pt-BR.js +138 -0
- package/lib/es/locale/ru-RU.js +138 -0
- package/lib/es/locale/sk-SK.js +138 -0
- package/lib/es/locale/vi-VN.js +138 -0
- package/lib/es/locale/zh-CN.js +138 -0
- package/lib/es/locale/zh-HK.js +138 -0
- package/lib/es/locale/zh-TW.js +138 -0
- package/lib/facade.js +115 -129
- package/lib/index.js +183 -156
- package/lib/locale/ar-SA.js +138 -0
- package/lib/locale/ca-ES.js +138 -0
- package/lib/locale/de-DE.js +138 -0
- package/lib/locale/en-US.js +153 -0
- package/lib/locale/es-ES.js +138 -0
- package/lib/locale/fa-IR.js +138 -0
- package/lib/locale/fr-FR.js +138 -0
- package/lib/locale/id-ID.js +138 -0
- package/lib/locale/it-IT.js +138 -0
- package/lib/locale/ja-JP.js +138 -0
- package/lib/locale/ko-KR.js +138 -0
- package/lib/locale/pl-PL.js +138 -0
- package/lib/locale/pt-BR.js +138 -0
- package/lib/locale/ru-RU.js +138 -0
- package/lib/locale/sk-SK.js +138 -0
- package/lib/locale/vi-VN.js +138 -0
- package/lib/locale/zh-CN.js +138 -0
- package/lib/locale/zh-HK.js +138 -0
- package/lib/locale/zh-TW.js +138 -0
- package/lib/types/facade/f-data-validation-builder.d.ts +50 -25
- package/lib/types/facade/f-data-validation.d.ts +26 -13
- package/lib/types/facade/f-range.d.ts +10 -5
- package/lib/types/facade/f-univer.d.ts +2 -1
- package/lib/types/facade/f-workbook.d.ts +1 -43
- package/lib/types/facade/f-worksheet.d.ts +8 -9
- package/lib/types/index.d.ts +5 -5
- package/lib/types/locale/ar-SA.d.ts +18 -0
- package/lib/types/locale/ca-ES.d.ts +18 -0
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +156 -0
- package/lib/types/locale/es-ES.d.ts +18 -0
- package/lib/types/locale/fa-IR.d.ts +18 -0
- package/lib/types/locale/fr-FR.d.ts +18 -0
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/ja-JP.d.ts +18 -0
- package/lib/types/locale/ko-KR.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/ru-RU.d.ts +18 -0
- package/lib/types/locale/sk-SK.d.ts +18 -0
- package/lib/types/locale/vi-VN.d.ts +18 -0
- package/lib/types/locale/zh-CN.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/locale/zh-TW.d.ts +18 -0
- package/lib/types/types/const/operator-text-map.d.ts +2 -1
- package/lib/types/validators/any-validator.d.ts +2 -2
- package/lib/types/validators/base-sheet-validator.d.ts +26 -0
- package/lib/types/validators/checkbox-validator.d.ts +2 -2
- package/lib/types/validators/custom-validator.d.ts +2 -2
- package/lib/types/validators/date-validator.d.ts +2 -2
- package/lib/types/validators/decimal-validator.d.ts +2 -2
- package/lib/types/validators/list-validator.d.ts +2 -2
- package/lib/types/validators/text-length-validator.d.ts +2 -2
- package/lib/types/validators/util.d.ts +0 -2
- package/lib/types/validators/whole-validator.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -0
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/es-ES.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -0
- package/lib/umd/locale/ko-KR.js +1 -0
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/sk-SK.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +14 -9
- package/LICENSE +0 -176
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type enUS from './en-US';
|
|
17
|
+
declare const locale: typeof enUS;
|
|
18
|
+
export default locale;
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DataValidationOperator } from '@univerjs/core';
|
|
17
17
|
export declare const OperatorTextMap: Record<DataValidationOperator, string>;
|
|
18
|
-
export declare const OperatorTitleMap: Record<DataValidationOperator, string>;
|
|
18
|
+
export declare const OperatorTitleMap: Record<DataValidationOperator | 'NONE', string>;
|
|
19
19
|
export declare const OperatorErrorTitleMap: Record<DataValidationOperator | 'NONE', string>;
|
|
20
|
+
export declare const TextLengthErrorTitleMap: Record<DataValidationOperator, string>;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
|
-
import {
|
|
19
|
-
export declare class AnyValidator extends
|
|
18
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
19
|
+
export declare class AnyValidator extends BaseSheetValidator {
|
|
20
20
|
id: string;
|
|
21
21
|
title: string;
|
|
22
22
|
operators: DataValidationOperator[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type { IDataValidationRuleBase } from '@univerjs/core';
|
|
17
|
+
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
18
|
+
import { BaseDataValidator } from '@univerjs/data-validation';
|
|
19
|
+
export declare const FORMULA1 = "{FORMULA1}";
|
|
20
|
+
export declare const FORMULA2 = "{FORMULA2}";
|
|
21
|
+
export declare const TYPE = "{TYPE}";
|
|
22
|
+
export declare abstract class BaseSheetValidator extends BaseDataValidator {
|
|
23
|
+
get operatorNames(): string[];
|
|
24
|
+
generateRuleName(rule: IDataValidationRuleBase): string;
|
|
25
|
+
generateRuleErrorMessage(rule: IDataValidationRuleBase, _position: ISheetLocationBase): string;
|
|
26
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase, ISheetDataValidationRule, Nullable } from '@univerjs/core';
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
18
|
import { WrapStrategy } from '@univerjs/core';
|
|
19
|
-
import {
|
|
19
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
20
20
|
export declare const CHECKBOX_FORMULA_1 = 1;
|
|
21
21
|
export declare const CHECKBOX_FORMULA_2 = 0;
|
|
22
22
|
interface ICheckboxFormulaResult extends IFormulaResult {
|
|
@@ -24,7 +24,7 @@ interface ICheckboxFormulaResult extends IFormulaResult {
|
|
|
24
24
|
originFormula2: Nullable<CellValue>;
|
|
25
25
|
}
|
|
26
26
|
export declare const transformCheckboxValue: (value: Nullable<CellValue>) => Nullable<CellValue>;
|
|
27
|
-
export declare class CheckboxValidator extends
|
|
27
|
+
export declare class CheckboxValidator extends BaseSheetValidator {
|
|
28
28
|
id: string;
|
|
29
29
|
title: string;
|
|
30
30
|
operators: DataValidationOperator[];
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { CellValue, DataValidationOperator, IDataValidationRule, IDataValidationRuleBase } from '@univerjs/core';
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
|
-
import {
|
|
19
|
-
export declare class CustomFormulaValidator extends
|
|
18
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
19
|
+
export declare class CustomFormulaValidator extends BaseSheetValidator {
|
|
20
20
|
id: string;
|
|
21
21
|
title: string;
|
|
22
22
|
operators: DataValidationOperator[];
|
|
@@ -17,8 +17,8 @@ import type { CellValue, IDataValidationRule, IDataValidationRuleBase } from '@u
|
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
18
|
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
19
19
|
import { DataValidationOperator } from '@univerjs/core';
|
|
20
|
-
import {
|
|
21
|
-
export declare class DateValidator extends
|
|
20
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
21
|
+
export declare class DateValidator extends BaseSheetValidator {
|
|
22
22
|
id: string;
|
|
23
23
|
title: string;
|
|
24
24
|
order: number;
|
|
@@ -17,9 +17,9 @@ import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable
|
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
18
|
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
19
19
|
import { DataValidationOperator } from '@univerjs/core';
|
|
20
|
-
import {
|
|
20
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
21
21
|
export declare function getCellValueNumber(cellValue: CellValue): number;
|
|
22
|
-
export declare class DecimalValidator extends
|
|
22
|
+
export declare class DecimalValidator extends BaseSheetValidator {
|
|
23
23
|
private readonly _customFormulaService;
|
|
24
24
|
id: string;
|
|
25
25
|
private readonly _lexerTreeBuilder;
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { CellValue, DataValidationOperator, ICellData, IDataValidationRule, ISheetDataValidationRule, IStyleData, Nullable } from '@univerjs/core';
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
|
-
import { BaseDataValidator } from '@univerjs/data-validation';
|
|
19
18
|
import { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
20
19
|
import { DataValidationFormulaService } from '../services/dv-formula.service';
|
|
20
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
21
21
|
export declare function getRuleFormulaResultSet(result: Nullable<Nullable<ICellData>[][]>): string[];
|
|
22
22
|
export declare function isValidListFormula(formula: string, lexer: LexerTreeBuilder): boolean | undefined;
|
|
23
|
-
export declare class ListValidator extends
|
|
23
|
+
export declare class ListValidator extends BaseSheetValidator {
|
|
24
24
|
protected formulaService: DataValidationFormulaService;
|
|
25
25
|
private _lexer;
|
|
26
26
|
private _univerInstanceService;
|
|
@@ -17,8 +17,8 @@ import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable
|
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
18
|
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
19
19
|
import { DataValidationOperator } from '@univerjs/core';
|
|
20
|
-
import {
|
|
21
|
-
export declare class TextLengthValidator extends
|
|
20
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
21
|
+
export declare class TextLengthValidator extends BaseSheetValidator {
|
|
22
22
|
id: string;
|
|
23
23
|
title: string;
|
|
24
24
|
private readonly _lexerTreeBuilder;
|
|
@@ -17,8 +17,6 @@ import type { ICellData, ISheetDataValidationRule, IUnitRangeName, IUniverInstan
|
|
|
17
17
|
import type { LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
18
18
|
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
19
19
|
export declare function getSheetRangeValueSet(grid: IUnitRangeName, univerInstanceService: IUniverInstanceService, currUnitId: string, currSubUnitId: string): string[];
|
|
20
|
-
export declare function serializeListOptions(options: string[]): string;
|
|
21
|
-
export declare function deserializeListOptions(optionsStr: string): string[];
|
|
22
20
|
export declare function getDataValidationCellValue(cellData: Nullable<ICellData>): string;
|
|
23
21
|
export declare function getTransformedFormula(lexerTreeBuilder: LexerTreeBuilder, rule: ISheetDataValidationRule, position: ISheetLocationBase): {
|
|
24
22
|
transformedFormula1: string | undefined;
|
|
@@ -17,8 +17,8 @@ import type { CellValue, IDataValidationRule, IDataValidationRuleBase, Nullable
|
|
|
17
17
|
import type { IFormulaResult, IFormulaValidResult, IValidatorCellInfo } from '@univerjs/data-validation';
|
|
18
18
|
import type { ISheetLocationBase } from '@univerjs/sheets';
|
|
19
19
|
import { DataValidationOperator } from '@univerjs/core';
|
|
20
|
-
import {
|
|
21
|
-
export declare class WholeValidator extends
|
|
20
|
+
import { BaseSheetValidator } from './base-sheet-validator';
|
|
21
|
+
export declare class WholeValidator extends BaseSheetValidator {
|
|
22
22
|
private readonly _customFormulaService;
|
|
23
23
|
private readonly _lexerTreeBuilder;
|
|
24
24
|
id: string;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets-data-validation`),require(`@univerjs/sheets/facade`),require(`@univerjs/data-validation`),require(`@univerjs/engine-formula`),require(`@univerjs/core/facade`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-data-validation`,`@univerjs/sheets/facade`,`@univerjs/data-validation`,`@univerjs/engine-formula`,`@univerjs/core/facade`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationFacade={},e.UniverCore,e.UniverSheetsDataValidation,e.UniverSheetsFacade,e.UniverDataValidation,e.UniverEngineFormula,e.UniverCoreFacade,e.rxjs))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=class e{constructor(e){d(this,`_rule`,void 0),this._rule=e==null?{uid:(0,t.generateRandomId)(),ranges:void 0,type:t.DataValidationType.CUSTOM}:e}build(){return new p(this._rule)}copy(){return new e({...this._rule,uid:(0,t.generateRandomId)()})}getAllowInvalid(){return this._rule.errorStyle!==t.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(e,n){return this._rule.type=t.DataValidationType.CHECKBOX,this._rule.formula1=e,this._rule.formula2=n,this}requireDateAfter(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.GREATER_THAN,this}requireDateBefore(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN,this}requireDateBetween(e,n){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=n.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.BETWEEN,this}requireDateEqualTo(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.EQUAL,this}requireDateNotBetween(e,n){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=n.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(e){return this._rule.type=t.DataValidationType.CUSTOM,this._rule.formula1=e,this._rule.formula2=void 0,this}requireNumberBetween(e,n,r){return this._rule.formula1=`${e}`,this._rule.formula2=`${n}`,this._rule.operator=t.DataValidationOperator.BETWEEN,this._rule.type=r?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberGreaterThan(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberLessThan(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberNotBetween(e,n,r){return this._rule.formula1=`${e}`,this._rule.formula2=`${n}`,this._rule.operator=t.DataValidationOperator.NOT_BETWEEN,this._rule.type=r?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.NOT_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireValueInList(e,n,r){return this._rule.type=n?t.DataValidationType.LIST_MULTIPLE:t.DataValidationType.LIST,this._rule.formula1=e.join(`,`),this._rule.formula2=void 0,this._rule.showDropDown=r==null?!0:r,this}requireValueInRange(e,n,r){return this._rule.type=n?t.DataValidationType.LIST_MULTIPLE:t.DataValidationType.LIST,this._rule.formula1=`=${(0,a.serializeRangeToRefString)({unitId:e.getUnitId(),sheetName:e.getSheetName(),range:e.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=r==null?!0:r,this}setAllowInvalid(e){return this._rule.errorStyle=e?t.DataValidationErrorStyle.WARNING:t.DataValidationErrorStyle.STOP,this}setAllowBlank(e){return this._rule.allowBlank=e,this}setOptions(e){return Object.assign(this._rule,e),this}},p=class{constructor(e,t,n){d(this,`rule`,void 0),d(this,`_worksheet`,void 0),d(this,`_injector`,void 0),this._injector=n,this.rule=e,this._worksheet=t}getAllowInvalid(){return this.rule.errorStyle!==t.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new f(this.rule)}getApplied(){if(!this._worksheet)return!1;let e=this._injector.get(i.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];let e=this._injector.get(t.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(t=>this._injector.createInstance(r.FRange,e,this._worksheet,t))}getUnitId(){var e;return(e=this._worksheet)==null?void 0:e.getUnitId()}getSheetId(){var e;return(e=this._worksheet)==null?void 0:e.getSheetId()}setCriteria(e,r,i=!0){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:r[0],formula1:r[1],formula2:r[2],type:this.rule.type,allowBlank:i}}))throw Error(`setCriteria failed`);return this.rule.operator=r[0],this.rule.formula1=r[1],this.rule.formula2=r[2],this.rule.type=e,this.rule.allowBlank=i,this}setOptions(e){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...(0,i.getRuleOptions)(this.rule),...e}}))throw Error(`setOptions failed`);return Object.assign(this.rule,e),this}setRanges(e){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:e.map(e=>e.getRange())}))throw Error(`setRanges failed`);return this.rule.ranges=e.map(e=>e.getRange()),this}delete(){return this.getApplied()?this._injector.get(t.ICommandService).syncExecuteCommand(n.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}},m=class extends r.FRange{setDataValidation(e){if(!e)return this._commandService.syncExecuteCommand(n.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...e.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(n.AddSheetDataValidationCommand.id,t),this}getDataValidation(){let e=this._injector.get(n.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new p(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(n.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new p(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}async getDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._collectValidationErrorsForRange(e,t,[this._range])}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._worksheet,s=o.getName(),c=[];for(let l of i){let i=[];for(let u=l.startRow;u<=l.endRow;u++)for(let d=l.startColumn;d<=l.endColumn;d++)i.push((async()=>{try{if(await a.validatorCell(e,r,u,d)!==t.DataValidationStatus.VALID){let t=this._injector.get(n.SheetDataValidationModel).getRuleByLocation(e,r,u,d);if(t){var i;let e=((i=o.getCell(u,d))==null?void 0:i.v)||null,n=this._createDataValidationError(s,u,d,t,e);c.push(n)}}}catch(e){console.warn(`Failed to validate cell [${u}, ${d}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}};r.FRange.extend(m);var h=class extends o.FUniver{static newDataValidation(){return new f}newDataValidation(){return new f}_initialize(e){let r=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetDataValidationChanged,()=>e.has(n.SheetDataValidationModel)?e.get(n.SheetDataValidationModel).ruleChange$.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r,oldRule:i,type:a}=e,o=this.getSheetTarget(t,n);if(!o)return;let{workbook:s,worksheet:c}=o,l={origin:e,worksheet:c,workbook:s,changeType:a,oldRule:i,rule:new p(r,c.getSheet(),this._injector)};this.fireEvent(this.Event.SheetDataValidationChanged,l)}):{dispose:()=>{}})),this.disposeWithMe(this.registerEventHandler(this.Event.SheetDataValidatorStatusChanged,()=>e.has(n.SheetDataValidationModel)?e.get(n.SheetDataValidationModel).validStatusChange$.subscribe(e=>{let{unitId:t,subUnitId:n,ruleId:r,status:i,row:a,col:o}=e,s=this.getSheetTarget(t,n);if(!s)return;let{workbook:c,worksheet:l}=s,u=l.getDataValidation(r);if(!u)return;let d={workbook:c,worksheet:l,row:a,column:o,rule:u,status:i};this.fireEvent(this.Event.SheetDataValidatorStatusChanged,d)}):{dispose:()=>{}})),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationAdd,()=>r.beforeCommandExecuted(e=>{if(e.id===n.AddSheetDataValidationCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o={worksheet:a,workbook:i,rule:n.rule};if(this.fireEvent(this.Event.BeforeSheetDataValidationAdd,o),o.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationCriteriaUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationSettingCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o=a.getDataValidation(n.ruleId);if(!o)return;let s={worksheet:a,workbook:i,rule:o,ruleId:n.ruleId,newCriteria:n.setting};if(this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,s),s.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationRangeUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationRangeCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o=a.getDataValidation(n.ruleId);if(!o)return;let s={worksheet:a,workbook:i,rule:o,ruleId:n.ruleId,newRanges:n.ranges};if(this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,s),s.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationOptionsUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationOptionsCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o=a.getDataValidation(n.ruleId);if(!o)return;let s={worksheet:a,workbook:i,rule:o,ruleId:n.ruleId,newOptions:n.options};if(this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,s),s.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationDelete,()=>r.beforeCommandExecuted(e=>{if(e.id===n.RemoveSheetDataValidationCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o=a.getDataValidation(n.ruleId);if(!o)return;let s={worksheet:a,workbook:i,rule:o,ruleId:n.ruleId};if(this.fireEvent(this.Event.BeforeSheetDataValidationDelete,s),s.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationDeleteAll,()=>r.beforeCommandExecuted(e=>{if(e.id===n.RemoveSheetAllDataValidationCommand.id){let n=e.params,r=this.getSheetTarget(n.unitId,n.subUnitId);if(!r)return;let{workbook:i,worksheet:a}=r,o={worksheet:a,workbook:i,rules:a.getDataValidations()};if(this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,o),o.cancel)throw new t.CanceledError}})))}};o.FUniver.extend(h);var g=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,`_dataValidationModel`,{get(){return this._injector.get(n.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}async getAllDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._dataValidationModel.getSubUnitIds(e),n=[];for(let r of t){let t=await this._collectValidationErrorsForSheet(e,r);n.push(...t)}return n}async _collectValidationErrorsForSheet(e,t){let n=this._dataValidationModel.getRules(e,t);if(!n.length)return[];let r=n.flatMap(e=>e.ranges);return this._collectValidationErrorsForRange(e,t,r)}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._workbook.getSheetBySheetId(r);if(!o)throw Error(`Cannot find worksheet with sheetId: ${r}`);let s=o.getName(),c=[];for(let n of i){let i=[];for(let l=n.startRow;l<=n.endRow;l++)for(let u=n.startColumn;u<=n.endColumn;u++)i.push((async()=>{try{if(await a.validatorCell(e,r,l,u)!==t.DataValidationStatus.VALID){let t=this._dataValidationModel.getRuleByLocation(e,r,l,u);if(t){var n;let e=((n=o.getCell(l,u))==null?void 0:n.v)||null,r=this._createDataValidationError(s,l,u,t,e);c.push(r)}}}catch(e){console.warn(`Failed to validate cell [${l}, ${u}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}onDataValidationChange(e){return(0,t.toDisposable)(this._dataValidationModel.ruleChange$.pipe((0,s.filter)(e=>e.unitId===this._workbook.getUnitId())).subscribe(e))}onDataValidationStatusChange(e){return(0,t.toDisposable)(this._dataValidationModel.validStatusChange$.pipe((0,s.filter)(e=>e.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddDataValidation(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.AddSheetDataValidationCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeAddDataValidation`)}}))}onBeforeUpdateDataValidationCriteria(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.UpdateSheetDataValidationSettingCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateDataValidationCriteria`)}}))}onBeforeUpdateDataValidationRange(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.UpdateSheetDataValidationRangeCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateDataValidationRange`)}}))}onBeforeUpdateDataValidationOptions(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.UpdateSheetDataValidationOptionsCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateDataValidationOptions`)}}))}onBeforeDeleteDataValidation(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.RemoveSheetDataValidationCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeDeleteDataValidation`)}}))}onBeforeDeleteAllDataValidation(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,r)=>{let i=t.params;if(t.id===n.RemoveSheetAllDataValidationCommand.id){if(i.unitId!==this._workbook.getUnitId())return;if(e(i,r)===!1)throw Error(`Command is stopped by the hook onBeforeDeleteAllDataValidation`)}}))}};r.FWorkbook.extend(g);var _=class extends r.FWorksheet{getDataValidations(){return this._injector.get(i.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new p(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}getValidatorStatusAsync(){return this.getValidatorStatus()}getDataValidation(e){let t=this._injector.get(i.DataValidationModel).getRuleById(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);return t?new p(t,this._worksheet,this._injector):null}async getAllDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._collectValidationErrorsForSheet(e,t)}async _collectValidationErrorsForSheet(e,t){let n=this._injector.get(i.DataValidationModel).getRules(e,t);if(!n.length)return[];let r=n.flatMap(e=>e.ranges);return this._collectValidationErrorsForRange(e,t,r)}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._worksheet,s=o.getName(),c=[];for(let l of i){let i=[];for(let u=l.startRow;u<=l.endRow;u++)for(let d=l.startColumn;d<=l.endColumn;d++)i.push((async()=>{try{if(await a.validatorCell(e,r,u,d)!==t.DataValidationStatus.VALID){let t=this._injector.get(n.SheetDataValidationModel).getRuleByLocation(e,r,u,d);if(t){var i;let e=((i=o.getCell(u,d))==null?void 0:i.v)||null,n=this._createDataValidationError(s,u,d,t,e);c.push(n)}}}catch(e){console.warn(`Failed to validate cell [${u}, ${d}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}};r.FWorksheet.extend(_);var v=class extends o.FEventName{get SheetDataValidationChanged(){return`SheetDataValidationChanged`}get SheetDataValidatorStatusChanged(){return`SheetDataValidatorStatusChanged`}get BeforeSheetDataValidationAdd(){return`BeforeSheetDataValidationAdd`}get BeforeSheetDataValidationDelete(){return`BeforeSheetDataValidationDelete`}get BeforeSheetDataValidationDeleteAll(){return`BeforeSheetDataValidationDeleteAll`}get BeforeSheetDataValidationCriteriaUpdate(){return`BeforeSheetDataValidationCriteriaUpdate`}get BeforeSheetDataValidationRangeUpdate(){return`BeforeSheetDataValidationRangeUpdate`}get BeforeSheetDataValidationOptionsUpdate(){return`BeforeSheetDataValidationOptionsUpdate`}};o.FEventName.extend(v),e.FDataValidation=p,e.FDataValidationBuilder=f});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-data-validation"),require("@univerjs/sheets/facade"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-data-validation`,`@univerjs/sheets/facade`,`@univerjs/data-validation`,`@univerjs/engine-formula`,`@univerjs/sheets`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationFacade={},e.UniverCore,e.UniverSheetsDataValidation,e.UniverSheetsFacade,e.UniverDataValidation,e.UniverEngineFormula,e.UniverSheets,e.UniverCoreFacade))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=class e{constructor(e){d(this,`_rule`,void 0),this._rule=e==null?{uid:(0,t.generateRandomId)(),ranges:void 0,type:t.DataValidationType.CUSTOM}:e}build(){return new p(this._rule)}copy(){return new e({...this._rule,uid:(0,t.generateRandomId)()})}getAllowInvalid(){return this._rule.errorStyle!==t.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(e,n){return this._rule.type=t.DataValidationType.CHECKBOX,this._rule.formula1=e,this._rule.formula2=n,this}requireDateAfter(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.GREATER_THAN,this}requireDateBefore(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN,this}requireDateBetween(e,n){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=n.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.BETWEEN,this}requireDateEqualTo(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.EQUAL,this}requireDateNotBetween(e,n){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=n.toLocaleDateString(),this._rule.operator=t.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(e){return this._rule.type=t.DataValidationType.DATE,this._rule.formula1=e.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(e){return this._rule.type=t.DataValidationType.CUSTOM,this._rule.formula1=e,this._rule.formula2=void 0,this}requireNumberBetween(e,n,r){return this._rule.formula1=`${e}`,this._rule.formula2=`${n}`,this._rule.operator=t.DataValidationOperator.BETWEEN,this._rule.type=r?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberGreaterThan(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberLessThan(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberNotBetween(e,n,r){return this._rule.formula1=`${e}`,this._rule.formula2=`${n}`,this._rule.operator=t.DataValidationOperator.NOT_BETWEEN,this._rule.type=r?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(e,n){return this._rule.formula1=`${e}`,this._rule.formula2=void 0,this._rule.operator=t.DataValidationOperator.NOT_EQUAL,this._rule.type=n?t.DataValidationType.WHOLE:t.DataValidationType.DECIMAL,this}requireValueInList(e,n,r){return this._rule.type=n?t.DataValidationType.LIST_MULTIPLE:t.DataValidationType.LIST,this._rule.formula1=(0,o.serializeListOptions)(e),this._rule.formula2=void 0,this._rule.showDropDown=r==null?!0:r,this}requireValueInRange(e,n,r){return this._rule.type=n?t.DataValidationType.LIST_MULTIPLE:t.DataValidationType.LIST,this._rule.formula1=`=${(0,a.serializeRangeToRefString)({unitId:e.getUnitId(),sheetName:e.getSheetName(),range:e.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=r==null?!0:r,this}setAllowInvalid(e){return this._rule.errorStyle=e?t.DataValidationErrorStyle.WARNING:t.DataValidationErrorStyle.STOP,this}setAllowBlank(e){return this._rule.allowBlank=e,this}setOptions(e){return Object.assign(this._rule,e),this}},p=class{constructor(e,t,n){d(this,`rule`,void 0),d(this,`_worksheet`,void 0),d(this,`_injector`,void 0),this._injector=n,this.rule=e,this._worksheet=t}getAllowInvalid(){return this.rule.errorStyle!==t.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new f(this.rule)}getApplied(){if(!this._worksheet)return!1;let e=this._injector.get(i.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];let e=this._injector.get(t.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(t=>this._injector.createInstance(r.FRange,e,this._worksheet,t))}getUnitId(){var e;return(e=this._worksheet)==null?void 0:e.getUnitId()}getSheetId(){var e;return(e=this._worksheet)==null?void 0:e.getSheetId()}setCriteria(e,r,i=!0){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:r[0],formula1:r[1],formula2:r[2],type:this.rule.type,allowBlank:i}}))throw Error(`setCriteria failed`);return this.rule.operator=r[0],this.rule.formula1=r[1],this.rule.formula2=r[2],this.rule.type=e,this.rule.allowBlank=i,this}setOptions(e){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...(0,i.getRuleOptions)(this.rule),...e}}))throw Error(`setOptions failed`);return Object.assign(this.rule,e),this}setRanges(e){if(this.getApplied()&&!this._injector.get(t.ICommandService).syncExecuteCommand(n.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:e.map(e=>e.getRange())}))throw Error(`setRanges failed`);return this.rule.ranges=e.map(e=>e.getRange()),this}delete(){return this.getApplied()?this._injector.get(t.ICommandService).syncExecuteCommand(n.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}},m=class extends r.FRange{setDataValidation(e){if(!e)return this._commandService.syncExecuteCommand(n.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...e.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(n.AddSheetDataValidationCommand.id,t),this}getDataValidation(){let e=this._injector.get(n.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new p(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(n.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new p(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}async getDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._collectValidationErrorsForRange(e,t,[this._range])}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._worksheet,s=o.getName(),c=[];for(let l of i){let i=[];for(let u=l.startRow;u<=l.endRow;u++)for(let d=l.startColumn;d<=l.endColumn;d++)i.push((async()=>{try{if(await a.validatorCell(e,r,u,d)!==t.DataValidationStatus.VALID){let t=this._injector.get(n.SheetDataValidationModel).getRuleByLocation(e,r,u,d);if(t){var i;let e=((i=o.getCell(u,d))==null?void 0:i.v)||null,n=this._createDataValidationError(s,u,d,t,e);c.push(n)}}}catch(e){console.warn(`Failed to validate cell [${u}, ${d}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}};r.FRange.extend(m);var h=class extends s.FUniver{static newDataValidation(){return new f}newDataValidation(){return new f}_initialize(e){let r=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetDataValidationChanged,()=>e.has(n.SheetDataValidationModel)?e.get(n.SheetDataValidationModel).ruleChange$.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r,oldRule:i,type:a}=e,o=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!o)return;let{workbook:s,worksheet:c}=o,l={origin:e,worksheet:c,workbook:s,changeType:a,oldRule:i,rule:new p(r,c.getSheet(),this._injector)};this.fireEvent(this.Event.SheetDataValidationChanged,l)}):{dispose:()=>{}})),this.disposeWithMe(this.registerEventHandler(this.Event.SheetDataValidatorStatusChanged,()=>e.has(n.SheetDataValidationModel)?e.get(n.SheetDataValidationModel).validStatusChange$.subscribe(e=>{let{unitId:t,subUnitId:n,ruleId:r,status:i,row:a,col:o}=e,s=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!s)return;let{workbook:c,worksheet:l}=s,u=l.getDataValidation(r);if(!u)return;let d={workbook:c,worksheet:l,row:a,column:o,rule:u,status:i};this.fireEvent(this.Event.SheetDataValidatorStatusChanged,d)}):{dispose:()=>{}})),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationAdd,()=>r.beforeCommandExecuted(e=>{if(e.id===n.AddSheetDataValidationCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,{rule:o}=n,s={worksheet:a,workbook:i,rule:o};if(this.fireEvent(this.Event.BeforeSheetDataValidationAdd,s),s.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationCriteriaUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationSettingCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,{ruleId:o,setting:s}=n,c=a.getDataValidation(o);if(!c)return;let l={worksheet:a,workbook:i,rule:c,ruleId:o,newCriteria:s};if(this.fireEvent(this.Event.BeforeSheetDataValidationCriteriaUpdate,l),l.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationRangeUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationRangeCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,{ruleId:o,ranges:s}=n,c=a.getDataValidation(o);if(!c)return;let l={worksheet:a,workbook:i,rule:c,ruleId:o,newRanges:s};if(this.fireEvent(this.Event.BeforeSheetDataValidationRangeUpdate,l),l.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationOptionsUpdate,()=>r.beforeCommandExecuted(e=>{if(e.id===n.UpdateSheetDataValidationOptionsCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,{ruleId:o,options:s}=n,c=a.getDataValidation(o);if(!c)return;let l={worksheet:a,workbook:i,rule:c,ruleId:o,newOptions:s};if(this.fireEvent(this.Event.BeforeSheetDataValidationOptionsUpdate,l),l.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationDelete,()=>r.beforeCommandExecuted(e=>{if(e.id===n.RemoveSheetDataValidationCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,{ruleId:o}=n,s=a.getDataValidation(o);if(!s)return;let c={worksheet:a,workbook:i,rule:s,ruleId:o};if(this.fireEvent(this.Event.BeforeSheetDataValidationDelete,c),c.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDataValidationDeleteAll,()=>r.beforeCommandExecuted(e=>{if(e.id===n.RemoveSheetAllDataValidationCommand.id){let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:i,worksheet:a}=r,o={worksheet:a,workbook:i,rules:a.getDataValidations()};if(this.fireEvent(this.Event.BeforeSheetDataValidationDeleteAll,o),o.cancel)throw new t.CanceledError}})))}};s.FUniver.extend(h);var g=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(n.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}async getAllDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._dataValidationModel.getSubUnitIds(e),n=[];for(let r of t){let t=await this._collectValidationErrorsForSheet(e,r);n.push(...t)}return n}async _collectValidationErrorsForSheet(e,t){let n=this._dataValidationModel.getRules(e,t);if(!n.length)return[];let r=n.flatMap(e=>e.ranges);return this._collectValidationErrorsForRange(e,t,r)}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._workbook.getSheetBySheetId(r);if(!o)throw Error(`Cannot find worksheet with sheetId: ${r}`);let s=o.getName(),c=[];for(let n of i){let i=[];for(let l=n.startRow;l<=n.endRow;l++)for(let u=n.startColumn;u<=n.endColumn;u++)i.push((async()=>{try{if(await a.validatorCell(e,r,l,u)!==t.DataValidationStatus.VALID){let t=this._dataValidationModel.getRuleByLocation(e,r,l,u);if(t){var n;let e=((n=o.getCell(l,u))==null?void 0:n.v)||null,r=this._createDataValidationError(s,l,u,t,e);c.push(r)}}}catch(e){console.warn(`Failed to validate cell [${l}, ${u}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}};r.FWorkbook.extend(g);var _=class extends r.FWorksheet{getDataValidations(){return this._injector.get(i.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new p(e,this._worksheet,this._injector))}getValidatorStatusAsync(){return this._injector.get(n.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}getDataValidation(e){let t=this._injector.get(i.DataValidationModel).getRuleById(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);return t?new p(t,this._worksheet,this._injector):null}async getAllDataValidationErrorAsync(){let e=this._workbook.getUnitId(),t=this._worksheet.getSheetId();return this._collectValidationErrorsForSheet(e,t)}async _collectValidationErrorsForSheet(e,t){let n=this._injector.get(i.DataValidationModel).getRules(e,t);if(!n.length)return[];let r=n.flatMap(e=>e.ranges);return this._collectValidationErrorsForRange(e,t,r)}async _collectValidationErrorsForRange(e,r,i){if(!i.length)return[];let a=this._injector.get(n.SheetsDataValidationValidatorService),o=this._worksheet,s=o.getName(),c=[];for(let l of i){let i=[];for(let u=l.startRow;u<=l.endRow;u++)for(let d=l.startColumn;d<=l.endColumn;d++)i.push((async()=>{try{if(await a.validatorCell(e,r,u,d)!==t.DataValidationStatus.VALID){let t=this._injector.get(n.SheetDataValidationModel).getRuleByLocation(e,r,u,d);if(t){var i;let e=((i=o.getCell(u,d))==null?void 0:i.v)||null,n=this._createDataValidationError(s,u,d,t,e);c.push(n)}}}catch(e){console.warn(`Failed to validate cell [${u}, ${d}]:`,e)}})());await Promise.all(i)}return c}_createDataValidationError(e,t,n,r,i){return{sheetName:e,row:t,column:n,ruleId:r.uid,inputValue:i,rule:r}}};r.FWorksheet.extend(_);var v=class extends s.FEventName{get SheetDataValidationChanged(){return`SheetDataValidationChanged`}get SheetDataValidatorStatusChanged(){return`SheetDataValidatorStatusChanged`}get BeforeSheetDataValidationAdd(){return`BeforeSheetDataValidationAdd`}get BeforeSheetDataValidationDelete(){return`BeforeSheetDataValidationDelete`}get BeforeSheetDataValidationDeleteAll(){return`BeforeSheetDataValidationDeleteAll`}get BeforeSheetDataValidationCriteriaUpdate(){return`BeforeSheetDataValidationCriteriaUpdate`}get BeforeSheetDataValidationRangeUpdate(){return`BeforeSheetDataValidationRangeUpdate`}get BeforeSheetDataValidationOptionsUpdate(){return`BeforeSheetDataValidationOptionsUpdate`}};s.FEventName.extend(v),e.FDataValidation=p,e.FDataValidationBuilder=f});
|