@univerjs/sheets 1.0.0-rc.0 → 1.0.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 (54) hide show
  1. package/lib/cjs/facade.js +211 -110
  2. package/lib/cjs/index.js +350 -246
  3. package/lib/cjs/locale/ar-SA.js +0 -1
  4. package/lib/cjs/locale/ca-ES.js +0 -1
  5. package/lib/cjs/locale/de-DE.js +0 -1
  6. package/lib/cjs/locale/en-US.js +0 -1
  7. package/lib/cjs/locale/es-ES.js +0 -1
  8. package/lib/cjs/locale/fa-IR.js +0 -1
  9. package/lib/cjs/locale/fr-FR.js +0 -1
  10. package/lib/cjs/locale/id-ID.js +0 -1
  11. package/lib/cjs/locale/it-IT.js +0 -1
  12. package/lib/cjs/locale/ja-JP.js +0 -1
  13. package/lib/cjs/locale/ko-KR.js +0 -1
  14. package/lib/cjs/locale/pl-PL.js +0 -1
  15. package/lib/cjs/locale/pt-BR.js +0 -1
  16. package/lib/cjs/locale/ru-RU.js +0 -1
  17. package/lib/cjs/locale/sk-SK.js +0 -1
  18. package/lib/cjs/locale/vi-VN.js +0 -1
  19. package/lib/cjs/locale/zh-CN.js +0 -1
  20. package/lib/cjs/locale/zh-HK.js +0 -1
  21. package/lib/cjs/locale/zh-TW.js +0 -1
  22. package/lib/es/facade.js +212 -111
  23. package/lib/es/index.js +351 -248
  24. package/lib/facade.js +212 -111
  25. package/lib/index.js +351 -248
  26. package/lib/types/commands/commands/set-worksheet-hide.command.d.ts +4 -0
  27. package/lib/types/commands/mutations/set-range-values.mutation.d.ts +12 -1
  28. package/lib/types/commands/mutations/set-worksheet-hide.mutation.d.ts +2 -1
  29. package/lib/types/controllers/calculate-result-apply.controller.d.ts +1 -1
  30. package/lib/types/facade/f-defined-name.d.ts +2 -2
  31. package/lib/types/facade/f-range.d.ts +118 -45
  32. package/lib/types/facade/f-selection.d.ts +1 -1
  33. package/lib/types/facade/f-sheet-hooks.d.ts +24 -0
  34. package/lib/types/facade/f-univer.d.ts +4 -5
  35. package/lib/types/facade/f-workbook.d.ts +8 -13
  36. package/lib/types/facade/f-worksheet.d.ts +43 -28
  37. package/lib/types/facade/permission/f-range-permission.d.ts +1 -1
  38. package/lib/types/facade/permission/f-range-protection-rule.d.ts +2 -2
  39. package/lib/types/facade/permission/f-workbook-permission.d.ts +3 -3
  40. package/lib/types/facade/permission/f-worksheet-permission.d.ts +5 -4
  41. package/lib/types/facade/utils.d.ts +1 -0
  42. package/lib/types/index.d.ts +1 -1
  43. package/lib/types/model/range-protection-render.model.d.ts +33 -0
  44. package/lib/types/model/range-protection-rule.model.d.ts +75 -0
  45. package/lib/types/model/range-protection.cache.d.ts +55 -0
  46. package/lib/types/model/range-theme-model.d.ts +102 -0
  47. package/lib/types/model/range-theme-util.d.ts +113 -0
  48. package/lib/types/model/range-themes/build-in-theme.factory.d.ts +20 -0
  49. package/lib/types/model/range-themes/default.d.ts +18 -0
  50. package/lib/types/model/zebra-crossing-cache.d.ts +57 -0
  51. package/lib/types/services/auto-fill/tools.d.ts +2 -0
  52. package/lib/umd/facade.js +1 -1
  53. package/lib/umd/index.js +2 -2
  54. package/package.json +9 -9
@@ -0,0 +1,113 @@
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 { IStyleData, Nullable } from '@univerjs/core';
17
+ export type IRangeThemeStyleItem = Pick<IStyleData, 'bg' | 'ol' | 'bd' | 'cl' | 'ht' | 'vt' | 'bl'>;
18
+ export interface IRangeThemeStyleJSON {
19
+ name: string;
20
+ wholeStyle?: IRangeThemeStyleItem;
21
+ headerRowStyle?: IRangeThemeStyleItem;
22
+ headerColumnStyle?: IRangeThemeStyleItem;
23
+ firstRowStyle?: IRangeThemeStyleItem;
24
+ secondRowStyle?: IRangeThemeStyleItem;
25
+ lastRowStyle?: IRangeThemeStyleItem;
26
+ firstColumnStyle?: IRangeThemeStyleItem;
27
+ secondColumnStyle?: IRangeThemeStyleItem;
28
+ lastColumnStyle?: IRangeThemeStyleItem;
29
+ }
30
+ export declare function composeStyles(styles: IStyleData[]): IRangeThemeStyleItem;
31
+ /**
32
+ * Range theme style
33
+ * @description The range theme style is used to set the style of the range.This class is used to create a build-in theme style or a custom theme style.
34
+ */
35
+ export declare class RangeThemeStyle {
36
+ private _name;
37
+ /**
38
+ * @property {Nullable<IRangeThemeStyleItem>} wholeStyle effect for the whole range.
39
+ */
40
+ wholeStyle: Nullable<IRangeThemeStyleItem>;
41
+ /**
42
+ * @property {Nullable<IRangeThemeStyleItem>} headerRowStyle effect for the header row.
43
+ */
44
+ headerRowStyle: Nullable<IRangeThemeStyleItem>;
45
+ /**
46
+ * @property {Nullable<IRangeThemeStyleItem>} headerColumnStyle effect for the header column.
47
+ */
48
+ headerColumnStyle: Nullable<IRangeThemeStyleItem>;
49
+ /**
50
+ * @property {Nullable<IRangeThemeStyleItem>} firstRowStyle effect for the first row.
51
+ */
52
+ firstRowStyle: Nullable<IRangeThemeStyleItem>;
53
+ /**
54
+ * @property {Nullable<IRangeThemeStyleItem>} secondRowStyle effect for the second row.
55
+ */
56
+ secondRowStyle: Nullable<IRangeThemeStyleItem>;
57
+ /**
58
+ * @property {Nullable<IRangeThemeStyleItem>} lastRowStyle effect for the last row.
59
+ */
60
+ lastRowStyle: Nullable<IRangeThemeStyleItem>;
61
+ /**
62
+ * @property {Nullable<IRangeThemeStyleItem>} firstColumnStyle effect for the first column.
63
+ */
64
+ firstColumnStyle: Nullable<IRangeThemeStyleItem>;
65
+ /**
66
+ * @property {Nullable<IRangeThemeStyleItem>} secondColumnStyle effect for the second column.
67
+ */
68
+ secondColumnStyle: Nullable<IRangeThemeStyleItem>;
69
+ /**
70
+ * @property {Nullable<IRangeThemeStyleItem>} lastColumnStyle effect for the last column.
71
+ */
72
+ lastColumnStyle: Nullable<IRangeThemeStyleItem>;
73
+ /**
74
+ * @property {Nullable<IRangeThemeStyleItem>} quickly get merge style
75
+ */
76
+ private _mergeCacheMap;
77
+ /**
78
+ * @constructor
79
+ * @param {string} name The name of the range theme style, it used to identify the range theme style.
80
+ * @param {IRangeThemeStyleJSON} [options] The options to initialize the range theme style.
81
+ */
82
+ constructor(name: string, options?: Omit<IRangeThemeStyleJSON, 'name'>);
83
+ /**
84
+ * Gets the name of the range theme style.The name is read only, and use to identifier the range theme style.
85
+ * @returns {string} The name of the range theme style.
86
+ */
87
+ getName(): string;
88
+ getWholeStyle(): Nullable<IRangeThemeStyleItem>;
89
+ setWholeStyle(style: Nullable<IRangeThemeStyleItem>): void;
90
+ getFirstRowStyle(): Nullable<IRangeThemeStyleItem>;
91
+ setFirstRowStyle(style: Nullable<IRangeThemeStyleItem>): void;
92
+ getSecondRowStyle(): Nullable<IRangeThemeStyleItem>;
93
+ setSecondRowStyle(style: Nullable<IRangeThemeStyleItem>): void;
94
+ getLastRowStyle(): Nullable<IRangeThemeStyleItem>;
95
+ setLastRowStyle(style: Nullable<IRangeThemeStyleItem>): void;
96
+ getFirstColumnStyle(): Nullable<IRangeThemeStyleItem>;
97
+ setFirstColumnStyle(style: Nullable<IRangeThemeStyleItem>): void;
98
+ getSecondColumnStyle(): Nullable<IRangeThemeStyleItem>;
99
+ setSecondColumnStyle(style: Nullable<IRangeThemeStyleItem>): void;
100
+ getLastColumnStyle(): Nullable<IRangeThemeStyleItem>;
101
+ setLastColumnStyle(style: Nullable<IRangeThemeStyleItem>): void;
102
+ getHeaderRowStyle(): Nullable<IRangeThemeStyleItem>;
103
+ setHeaderRowStyle(style: Nullable<IRangeThemeStyleItem>): void;
104
+ getHeaderColumnStyle(): Nullable<IRangeThemeStyleItem>;
105
+ setHeaderColumnStyle(style: Nullable<IRangeThemeStyleItem>): void;
106
+ getStyle(offsetRow: number, offsetCol: number, isLastRow: boolean, isLastCol: boolean, isToggled: boolean): IRangeThemeStyleItem | null;
107
+ private _getMergeStyle;
108
+ private _mergeStyle;
109
+ private _resetStyleCache;
110
+ toJson(): IRangeThemeStyleJSON;
111
+ fromJson(json: IRangeThemeStyleJSON): void;
112
+ dispose(): void;
113
+ }
@@ -0,0 +1,20 @@
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 { RangeThemeStyle } from '../range-theme-util';
17
+ export declare const lightRangeThemeBuilder: (baseName: string, header: string, color: string) => RangeThemeStyle;
18
+ export declare const middleRangeThemeBuilder: (baseName: string, rowHeader: string, colHeader: string) => RangeThemeStyle;
19
+ export declare const darkRangeThemeBuilder: (baseName: string, rowHeader: string, firstRow: string, secondRow: string) => RangeThemeStyle;
20
+ export declare const buildInThemes: RangeThemeStyle[];
@@ -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 { RangeThemeStyle } from '../range-theme-util';
17
+ export declare const defaultRangeThemeStyle: RangeThemeStyle;
18
+ export declare const defaultRangeThemeStyleJSONWithLastRowStyle: RangeThemeStyle;
@@ -0,0 +1,57 @@
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 { IRange } from '@univerjs/core';
17
+ type IVisibleFunc = (row: number) => boolean;
18
+ type IToggleRange = [number, number];
19
+ /**
20
+ * This class is used for caching zebra crossing toggle ranges.
21
+ * `toggleRanges` represents the ranges within the visible area where the original odd/even row state is reversed due to hidden rows.
22
+ * Based on the following rules:
23
+ * 1. If there is an odd number of hidden rows before a certain row, the odd/even state of that row will be reversed.
24
+ * 2. If there is an even number of hidden rows before a certain row, the odd/even state of that row will not be reversed.
25
+ * 3. If there are no hidden rows before a certain row, the odd/even state of that row will not be reversed.
26
+ *
27
+ * Example:
28
+ * Given rows 1 to 10, where rows 3 and 7 are hidden:
29
+ * - Rows 1 and 2 remain in their original odd/even state.
30
+ * - Row 4's state is reversed because there is 1 hidden row (odd) before it.
31
+ * - Row 8's state is reversed because there are 2 hidden rows (even) before it.
32
+ * - Rows 9 and 10 remain in their original odd/even state.
33
+ */
34
+ export declare class ZebraCrossingCache {
35
+ private _toggleRanges;
36
+ /**
37
+ * Refresh the cache based on the given range and visibility function.
38
+ * This method calculates toggle ranges for rows that are visible within the specified range.
39
+ * Hidden rows are excluded from the toggle calculation.
40
+ * @param range The range of rows to refresh (startRow and endRow are required).
41
+ * @param visibleFunc A function to determine if a row is visible.
42
+ */
43
+ refresh(range: IRange, visibleFunc: IVisibleFunc): void;
44
+ /**
45
+ * This function returns the toggle ranges. Only for testing purposes. In production, you should use `getIsToggled` to check if a row is toggled.
46
+ * @returns [IToggleRange[]] The toggle ranges calculated by the last refresh.
47
+ */
48
+ getToggleRanges(): IToggleRange[];
49
+ /**
50
+ * Check if the given row is toggled (odd/even state).
51
+ * This method uses binary search to efficiently determine if the row is within a toggle range.
52
+ * @param row The row to check.
53
+ * @returns True if the row is toggled (odd), false otherwise (even or hidden).
54
+ */
55
+ getIsToggled(row: number): boolean;
56
+ }
57
+ export {};
@@ -45,6 +45,8 @@ declare function fillCopy(data: Array<Nullable<ICellData>>, len: number): {
45
45
  v: import("@univerjs/core").CellValue | null;
46
46
  t: CellValueType | null;
47
47
  f: string | null;
48
+ ft?: Nullable<import("@univerjs/core").FormulaType>;
49
+ fd?: Nullable<import("@univerjs/core").BooleanNumber>;
48
50
  ref?: Nullable<string>;
49
51
  xf?: Nullable<string>;
50
52
  si: string | null;