@univerjs/sheets 1.0.0 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "description": "Core spreadsheet model and business logic for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -67,15 +67,15 @@
67
67
  "rxjs": ">=7.0.0"
68
68
  },
69
69
  "dependencies": {
70
- "@univerjs/core": "1.0.0",
71
- "@univerjs/engine-formula": "1.0.0",
72
- "@univerjs/engine-render": "1.0.0",
73
- "@univerjs/protocol": "1.0.0",
74
- "@univerjs/rpc": "1.0.0"
70
+ "@univerjs/core": "1.0.2",
71
+ "@univerjs/engine-formula": "1.0.2",
72
+ "@univerjs/engine-render": "1.0.2",
73
+ "@univerjs/protocol": "1.0.2",
74
+ "@univerjs/rpc": "1.0.2"
75
75
  },
76
76
  "devDependencies": {
77
- "@univerjs-infra/shared": "1.0.0",
78
- "@univerjs/network": "1.0.0",
77
+ "@univerjs-infra/shared": "1.0.2",
78
+ "@univerjs/network": "1.0.2",
79
79
  "rxjs": "^7.8.2",
80
80
  "typescript": "^6.0.3",
81
81
  "vitest": "^5.0.0"
@@ -1,24 +0,0 @@
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 { Injector } from '@univerjs/core';
17
- import { FBase } from '@univerjs/core/facade';
18
- /**
19
- * @hideconstructor
20
- */
21
- export declare class FSheetHooks extends FBase {
22
- protected readonly _injector: Injector;
23
- constructor(_injector: Injector);
24
- }
@@ -1,33 +0,0 @@
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
- import type { UnitAction } from '@univerjs/protocol';
18
- import { IPermissionService } from '@univerjs/core';
19
- import { RangeProtectionRuleModel } from './range-protection-rule.model';
20
- export type ICellPermission = Record<UnitAction, boolean> & {
21
- ruleId?: string;
22
- ranges?: IRange[];
23
- };
24
- export declare class RangeProtectionRenderModel {
25
- private _selectionProtectionRuleModel;
26
- private _permissionService;
27
- private _cache;
28
- constructor(_selectionProtectionRuleModel: RangeProtectionRuleModel, _permissionService: IPermissionService);
29
- private _init;
30
- private _createKey;
31
- getCellInfo(unitId: string, subUnitId: string, row: number, col: number): ICellPermission[];
32
- clear(): void;
33
- }
@@ -1,75 +0,0 @@
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 { IDisposable, IRange } from '@univerjs/core';
17
- import type { UnitObject } from '@univerjs/protocol';
18
- export declare enum ViewStateEnum {
19
- OthersCanView = "othersCanView",
20
- NoOneElseCanView = "noOneElseCanView"
21
- }
22
- export declare enum EditStateEnum {
23
- DesignedUserCanEdit = "designedUserCanEdit",
24
- OnlyMe = "onlyMe"
25
- }
26
- export interface IRangeProtectionRule {
27
- ranges: IRange[];
28
- permissionId: string;
29
- id: string;
30
- description?: string;
31
- unitType: UnitObject;
32
- unitId: string;
33
- subUnitId: string;
34
- viewState: ViewStateEnum;
35
- editState: EditStateEnum;
36
- }
37
- export type IObjectModel = Record<string, Record<string, IRangeProtectionRule[]>>;
38
- export type IModel = Map<string, Map<string, Map<string, IRangeProtectionRule>>>;
39
- export interface IRuleChange {
40
- unitId: string;
41
- subUnitId: string;
42
- rule: IRangeProtectionRule;
43
- oldRule?: IRangeProtectionRule;
44
- type: IRuleChangeType;
45
- }
46
- type IRuleChangeType = 'add' | 'set' | 'delete';
47
- export declare class RangeProtectionRuleModel implements IDisposable {
48
- /**
49
- * Map<unitId, Map<subUnitId, Map<ruleId, IRangeProtectionRule>>>
50
- */
51
- private _model;
52
- private readonly _ruleChange$;
53
- readonly ruleChange$: import("rxjs").Observable<IRuleChange>;
54
- private _ruleRefresh$;
55
- ruleRefresh$: import("rxjs").Observable<string>;
56
- dispose(): void;
57
- ruleRefresh(id: string): void;
58
- private _rangeRuleInitStateChange;
59
- rangeRuleInitStateChange$: import("rxjs").Observable<boolean>;
60
- getRangeRuleInitState(): boolean;
61
- changeRuleInitState(state: boolean): void;
62
- addRule(unitId: string, subUnitId: string, rule: IRangeProtectionRule): void;
63
- deleteRule(unitId: string, subUnitId: string, id: string): void;
64
- setRule(unitId: string, subUnitId: string, id: string, rule: IRangeProtectionRule): void;
65
- getRule(unitId: string, subUnitId: string, id: string): IRangeProtectionRule | undefined;
66
- getSubunitRuleList(unitId: string, subUnitId: string): IRangeProtectionRule[];
67
- getSubunitRuleListLength(unitId: string, subUnitId: string): number;
68
- private _ensureRuleMap;
69
- toObject(): IObjectModel;
70
- fromObject(obj: IObjectModel): void;
71
- deleteUnitModel(unitId: string): void;
72
- createRuleId(unitId: string, subUnitId: string): string;
73
- getTargetByPermissionId(unitId: string, permissionId: string): string[] | null;
74
- }
75
- export {};
@@ -1,55 +0,0 @@
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
- import { Disposable, IPermissionService, IUniverInstanceService } from '@univerjs/core';
18
- import { UnitAction } from '@univerjs/protocol';
19
- import { RangeProtectionRuleModel } from './range-protection-rule.model';
20
- export declare class RangeProtectionCache extends Disposable {
21
- private readonly _ruleModel;
22
- private readonly _permissionService;
23
- private readonly _univerInstanceService;
24
- private readonly _cellRuleCache;
25
- private readonly _permissionIdCache;
26
- private readonly _cellInfoCache;
27
- private readonly _rowInfoCache;
28
- private readonly _colInfoCache;
29
- constructor(_ruleModel: RangeProtectionRuleModel, _permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService);
30
- private _initCache;
31
- private _initUpdateCellInfoCache;
32
- private _initUpdateCellRuleCache;
33
- private _ensureRuleMap;
34
- private _ensureCellInfoMap;
35
- private _ensureRowColInfoMap;
36
- private _addCellRuleCache;
37
- private _deleteCellRuleCache;
38
- private _getSelectionActions;
39
- reBuildCache(unitId: string, subUnitId: string): void;
40
- getRowPermissionInfo(unitId: string, subUnitId: string, row: number, types: UnitAction[]): boolean;
41
- getColPermissionInfo(unitId: string, subUnitId: string, col: number, types: UnitAction[]): boolean;
42
- private _initUpdateRowColInfoCache;
43
- getCellInfo(unitId: string, subUnitId: string, row: number, col: number): (Partial<Record<UnitAction, boolean>> & {
44
- ruleId?: string;
45
- ranges?: IRange[];
46
- }) | {
47
- ruleId: string;
48
- ranges: IRange[];
49
- 1: boolean;
50
- 0: boolean;
51
- 2: boolean;
52
- 42: boolean;
53
- } | undefined;
54
- deleteUnit(unitId: string): void;
55
- }
@@ -1,102 +0,0 @@
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, Nullable } from '@univerjs/core';
17
- import type { IRangeThemeStyleItem, IRangeThemeStyleJSON } from './range-theme-util';
18
- import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
19
- import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';
20
- import { RangeThemeStyle } from './range-theme-util';
21
- export interface IRangeThemeRangeInfo {
22
- range: IRange;
23
- unitId: string;
24
- subUnitId: string;
25
- }
26
- export interface IRangeThemeStyleRule {
27
- rangeInfo: IRangeThemeRangeInfo;
28
- themeName: string;
29
- }
30
- interface ISheetRangeThemeModelJSON {
31
- rangeThemeStyleRuleMap: Record<string, IRangeThemeStyleRule>;
32
- rangeThemeStyleMapJson: Record<string, IRangeThemeStyleJSON>;
33
- }
34
- export declare class SheetRangeThemeModel extends Disposable {
35
- private _sheetInterceptorService;
36
- private _resourceManagerService;
37
- private readonly _univerInstanceService;
38
- private _rangeThemeStyleMap;
39
- private _rangeThemeStyleRuleMap;
40
- private _rTreeCollection;
41
- private _defaultRangeThemeMap;
42
- /**
43
- * This map is used to cache zebra crossing toggle ranges for each unitId and subUnitId, IRangeThemeStyleRule id
44
- */
45
- private _zebraCrossingCacheMap;
46
- private _rowVisibleFuncSet;
47
- private _rangeThemeMapChanged$;
48
- rangeThemeMapChange$: import("rxjs").Observable<{
49
- type: "add" | "remove";
50
- styleName: string;
51
- }>;
52
- constructor(_sheetInterceptorService: SheetInterceptorService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
53
- private _initDefaultTheme;
54
- private _ensureRangeThemeStyleMap;
55
- private _ensureRangeThemeStyleRuleMap;
56
- private _ensureRTreeCollection;
57
- getDefaultRangeThemeStyle(name: string): RangeThemeStyle;
58
- getCustomRangeThemeStyle(unitId: string, name: string): RangeThemeStyle | undefined;
59
- private _getSheetRowVisibleFuncSet;
60
- private _getSheetRowVisibleHasInit;
61
- refreshSheetRowVisibleFuncSet(unitId: string, subUnitId: string): void;
62
- private _ensureZebraCrossingCache;
63
- /**
64
- * Register range theme styles
65
- * @param {string} themeName
66
- * @param {IRangeThemeRangeInfo} rangeInfo
67
- */
68
- registerRangeThemeRule(themeName: string, rangeInfo: IRangeThemeRangeInfo): void;
69
- getRegisteredRangeThemeStyle(rangeInfo: IRangeThemeRangeInfo): string | undefined;
70
- refreshZebraCrossingCacheBySheet(unitId: string, subUnitId: string): void;
71
- removeRangeThemeRule(themeName: string, rangeInfo: IRangeThemeRangeInfo): void;
72
- registerDefaultRangeTheme(rangeThemeStyle: RangeThemeStyle): void;
73
- unRegisterDefaultRangeTheme(themeName: string): void;
74
- getRegisteredRangeThemes(): string[];
75
- /**
76
- * Register custom range theme style.
77
- * @param {string} unitId The unit id.
78
- * @param {RangeThemeStyle} rangeThemeStyle The range theme style.
79
- */
80
- registerRangeThemeStyle(unitId: string, rangeThemeStyle: RangeThemeStyle): void;
81
- /**
82
- * Unregister custom range theme style.
83
- * @param {string} unitId The unit id.
84
- * @param {string} name The name of the range theme style.
85
- */
86
- unregisterRangeThemeStyle(unitId: string, name: string): void;
87
- /**
88
- * Gets all custom register themes
89
- * @param {string} unitId Which unit to register the range theme style.
90
- * @return {string[]} The array of all custom registered themes.
91
- */
92
- getALLRegisteredTheme(unitId: string): string[];
93
- getRangeThemeStyle(unitId: string, name: string): RangeThemeStyle;
94
- getCellStyle(unitId: string, subUnitId: string, row: number, col: number): Nullable<IRangeThemeStyleItem>;
95
- private _registerIntercept;
96
- toJson(unitId: string): string;
97
- fromJSON(unitId: string, json: ISheetRangeThemeModelJSON): void;
98
- deleteUnitId(unitId: string): void;
99
- private _initSnapshot;
100
- dispose(): void;
101
- }
102
- export {};
@@ -1,113 +0,0 @@
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
- }
@@ -1,20 +0,0 @@
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[];
@@ -1,18 +0,0 @@
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;
@@ -1,57 +0,0 @@
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 {};