@univerjs/sheets-conditional-formatting 0.1.5

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 (78) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +30 -0
  3. package/lib/cjs/index.js +11 -0
  4. package/lib/es/index.js +9334 -0
  5. package/lib/index.css +1 -0
  6. package/lib/types/assets/icon-map.json.d.ts +82 -0
  7. package/lib/types/base/const.d.ts +66 -0
  8. package/lib/types/commands/commands/add-average-cf.command.d.ts +11 -0
  9. package/lib/types/commands/commands/add-cf.command.d.ts +10 -0
  10. package/lib/types/commands/commands/add-color-scale-cf.command.d.ts +10 -0
  11. package/lib/types/commands/commands/add-data-bar-cf.command.d.ts +14 -0
  12. package/lib/types/commands/commands/add-duplicate-values-cf.command.d.ts +10 -0
  13. package/lib/types/commands/commands/add-number-cf.command.d.ts +12 -0
  14. package/lib/types/commands/commands/add-rank-cf.command.d.ts +13 -0
  15. package/lib/types/commands/commands/add-text-cf.command.d.ts +12 -0
  16. package/lib/types/commands/commands/add-time-period-cf.command.d.ts +11 -0
  17. package/lib/types/commands/commands/add-unique-values-cf.command.d.ts +10 -0
  18. package/lib/types/commands/commands/clear-range-cf.command.d.ts +8 -0
  19. package/lib/types/commands/commands/clear-worksheet-cf.command.d.ts +7 -0
  20. package/lib/types/commands/commands/delete-cf.command.d.ts +8 -0
  21. package/lib/types/commands/commands/move-cf.command.d.ts +9 -0
  22. package/lib/types/commands/commands/set-cf.command.d.ts +9 -0
  23. package/lib/types/commands/mutations/add-conditional-rule.mutation.d.ts +15 -0
  24. package/lib/types/commands/mutations/delete-conditional-rule.mutation.d.ts +10 -0
  25. package/lib/types/commands/mutations/formula-mark-dirty.mutation.d.ts +10 -0
  26. package/lib/types/commands/mutations/move-conditional-rule.mutation.d.ts +14 -0
  27. package/lib/types/commands/mutations/set-conditional-rule.mutation.d.ts +14 -0
  28. package/lib/types/commands/operations/open-conditional-formatting-panel.d.ts +15 -0
  29. package/lib/types/components/color-picker/index.d.ts +12 -0
  30. package/lib/types/components/conditional-style-editor/index.d.ts +10 -0
  31. package/lib/types/components/panel/index.d.ts +8 -0
  32. package/lib/types/components/panel/rule-edit/colorScale.d.ts +4 -0
  33. package/lib/types/components/panel/rule-edit/dataBar.d.ts +4 -0
  34. package/lib/types/components/panel/rule-edit/formula.d.ts +4 -0
  35. package/lib/types/components/panel/rule-edit/highlightCell.d.ts +5 -0
  36. package/lib/types/components/panel/rule-edit/iconSet.d.ts +5 -0
  37. package/lib/types/components/panel/rule-edit/index.d.ts +9 -0
  38. package/lib/types/components/panel/rule-edit/rank.d.ts +4 -0
  39. package/lib/types/components/panel/rule-edit/type.d.ts +13 -0
  40. package/lib/types/components/panel/rule-list/index.d.ts +9 -0
  41. package/lib/types/components/preview/index.d.ts +6 -0
  42. package/lib/types/controllers/cf.auto-fill.controller.d.ts +15 -0
  43. package/lib/types/controllers/cf.clear.controller.d.ts +14 -0
  44. package/lib/types/controllers/cf.copy-paste.controller.d.ts +18 -0
  45. package/lib/types/controllers/cf.editor.controller.d.ts +15 -0
  46. package/lib/types/controllers/cf.i18n.controller.d.ts +10 -0
  47. package/lib/types/controllers/cf.menu.controller.d.ts +16 -0
  48. package/lib/types/controllers/cf.ref-range.controller.d.ts +15 -0
  49. package/lib/types/controllers/cf.render.controller.d.ts +21 -0
  50. package/lib/types/index.d.ts +17 -0
  51. package/lib/types/locale/en-US.d.ts +4 -0
  52. package/lib/types/locale/index.d.ts +17 -0
  53. package/lib/types/locale/zh-CN.d.ts +169 -0
  54. package/lib/types/menu/manage-rule.d.ts +4 -0
  55. package/lib/types/models/conditional-formatting-rule-model.d.ts +32 -0
  56. package/lib/types/models/conditional-formatting-view-model.d.ts +29 -0
  57. package/lib/types/models/icon-map.d.ts +26 -0
  58. package/lib/types/models/type.d.ts +91 -0
  59. package/lib/types/plugin.d.ts +13 -0
  60. package/lib/types/render/data-bar.render.d.ts +13 -0
  61. package/lib/types/render/icon.render.d.ts +18 -0
  62. package/lib/types/render/type.d.ts +22 -0
  63. package/lib/types/services/__test__/cf.service.spec.d.ts +16 -0
  64. package/lib/types/services/__test__/test.util.d.ts +24 -0
  65. package/lib/types/services/calculate-unit/color-scale.d.ts +3 -0
  66. package/lib/types/services/calculate-unit/data-bar.d.ts +3 -0
  67. package/lib/types/services/calculate-unit/highlight-cell.d.ts +3 -0
  68. package/lib/types/services/calculate-unit/icon-set.d.ts +3 -0
  69. package/lib/types/services/calculate-unit/type.d.ts +17 -0
  70. package/lib/types/services/calculate-unit/utils.d.ts +33 -0
  71. package/lib/types/services/conditional-formatting-formula.service.d.ts +57 -0
  72. package/lib/types/services/conditional-formatting.service.d.ts +49 -0
  73. package/lib/types/utils/getStringFromDataStream.d.ts +3 -0
  74. package/lib/types/utils/isRangesEqual.d.ts +3 -0
  75. package/lib/types/utils/removeUndefinedAttr.d.ts +16 -0
  76. package/lib/types/utils/type.d.ts +18 -0
  77. package/lib/umd/index.js +11 -0
  78. package/package.json +108 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ declare const locale: {
17
+ sheet: {
18
+ cf: {
19
+ title: string;
20
+ menu: {
21
+ manageConditionalFormatting: string;
22
+ createConditionalFormatting: string;
23
+ clearRangeRules: string;
24
+ clearWorkSheetRules: string;
25
+ };
26
+ form: {
27
+ lessThan: string;
28
+ lessThanOrEqual: string;
29
+ greaterThan: string;
30
+ greaterThanOrEqual: string;
31
+ rangeSelector: string;
32
+ };
33
+ iconSet: {
34
+ direction: string;
35
+ shape: string;
36
+ mark: string;
37
+ rank: string;
38
+ rule: string;
39
+ icon: string;
40
+ type: string;
41
+ value: string;
42
+ reverseIconOrder: string;
43
+ and: string;
44
+ when: string;
45
+ onlyShowIcon: string;
46
+ };
47
+ symbol: {
48
+ greaterThan: string;
49
+ greaterThanOrEqual: string;
50
+ lessThan: string;
51
+ lessThanOrEqual: string;
52
+ };
53
+ panel: {
54
+ createRule: string;
55
+ clear: string;
56
+ range: string;
57
+ styleType: string;
58
+ submit: string;
59
+ cancel: string;
60
+ rankAndAverage: string;
61
+ styleRule: string;
62
+ isNotBottom: string;
63
+ isBottom: string;
64
+ greaterThanAverage: string;
65
+ lessThanAverage: string;
66
+ medianValue: string;
67
+ fillType: string;
68
+ pureColor: string;
69
+ gradient: string;
70
+ colorSet: string;
71
+ positive: string;
72
+ native: string;
73
+ workSheet: string;
74
+ selectedRange: string;
75
+ managerRuleSelect: string;
76
+ };
77
+ preview: {
78
+ describe: {
79
+ beginsWith: string;
80
+ endsWith: string;
81
+ containsText: string;
82
+ notContainsText: string;
83
+ equal: string;
84
+ notEqual: string;
85
+ containsBlanks: string;
86
+ notContainsBlanks: string;
87
+ containsErrors: string;
88
+ notContainsErrors: string;
89
+ greaterThan: string;
90
+ greaterThanOrEqual: string;
91
+ lessThan: string;
92
+ lessThanOrEqual: string;
93
+ notBetween: string;
94
+ between: string;
95
+ yesterday: string;
96
+ tomorrow: string;
97
+ last7Days: string;
98
+ thisMonth: string;
99
+ lastMonth: string;
100
+ nextMonth: string;
101
+ thisWeek: string;
102
+ lastWeek: string;
103
+ nextWeek: string;
104
+ today: string;
105
+ topN: string;
106
+ bottomN: string;
107
+ topNPercent: string;
108
+ bottomNPercent: string;
109
+ };
110
+ };
111
+ operator: {
112
+ beginsWith: string;
113
+ endsWith: string;
114
+ containsText: string;
115
+ notContainsText: string;
116
+ equal: string;
117
+ notEqual: string;
118
+ containsBlanks: string;
119
+ notContainsBlanks: string;
120
+ containsErrors: string;
121
+ notContainsErrors: string;
122
+ greaterThan: string;
123
+ greaterThanOrEqual: string;
124
+ lessThan: string;
125
+ lessThanOrEqual: string;
126
+ notBetween: string;
127
+ between: string;
128
+ yesterday: string;
129
+ tomorrow: string;
130
+ last7Days: string;
131
+ thisMonth: string;
132
+ lastMonth: string;
133
+ nextMonth: string;
134
+ thisWeek: string;
135
+ lastWeek: string;
136
+ nextWeek: string;
137
+ today: string;
138
+ };
139
+ ruleType: {
140
+ highlightCell: string;
141
+ dataBar: string;
142
+ colorScale: string;
143
+ formula: string;
144
+ iconSet: string;
145
+ duplicateValues: string;
146
+ uniqueValues: string;
147
+ };
148
+ subRuleType: {
149
+ uniqueValues: string;
150
+ duplicateValues: string;
151
+ rank: string;
152
+ text: string;
153
+ timePeriod: string;
154
+ number: string;
155
+ average: string;
156
+ };
157
+ valueType: {
158
+ num: string;
159
+ min: string;
160
+ max: string;
161
+ percent: string;
162
+ percentile: string;
163
+ formula: string;
164
+ none: string;
165
+ };
166
+ };
167
+ };
168
+ };
169
+ export default locale;
@@ -0,0 +1,4 @@
1
+ import { IAccessor } from '@wendellhu/redi';
2
+ import { ComponentManager, IMenuSelectorItem } from '@univerjs/ui';
3
+
4
+ export declare const FactoryManageConditionalFormattingRule: (componentManager: ComponentManager) => (_accessor: IAccessor) => IMenuSelectorItem<import('@univerjs/ui/services/menu/menu.js').MenuItemDefaultValueType, undefined>;
@@ -0,0 +1,32 @@
1
+ import { ConditionalFormattingViewModel } from './conditional-formatting-view-model';
2
+ import { IConditionFormattingRule } from './type';
3
+ import { Injector } from '@wendellhu/redi';
4
+
5
+ type RuleOperatorType = 'delete' | 'set' | 'add' | 'sort';
6
+ export declare class ConditionalFormattingRuleModel {
7
+ private _conditionalFormattingViewModel;
8
+ private _injector;
9
+ private _model;
10
+ private _ruleChange$;
11
+ $ruleChange: import('rxjs').Observable<{
12
+ rule: IConditionFormattingRule;
13
+ unitId: string;
14
+ subUnitId: string;
15
+ type: RuleOperatorType;
16
+ }>;
17
+ constructor(_conditionalFormattingViewModel: ConditionalFormattingViewModel, _injector: Injector);
18
+ private _ensureList;
19
+ getRule(unitId: string, subUnitId: string, cfId?: string): IConditionFormattingRule<import('./type').IConditionalFormattingRuleConfig> | null | undefined;
20
+ getUnitRules(unitId: string): Map<string, IConditionFormattingRule<import('./type').IConditionalFormattingRuleConfig>[]> | null;
21
+ getSubunitRules(unitId: string, subUnitId: string): IConditionFormattingRule<import('./type').IConditionalFormattingRuleConfig>[] | null;
22
+ deleteRule(unitId: string, subUnitId: string, cfId: string): void;
23
+ setRule(unitId: string, subUnitId: string, rule: IConditionFormattingRule): void;
24
+ addRule(unitId: string, subUnitId: string, rule: IConditionFormattingRule): void;
25
+ /**
26
+ * example [1,2,3,4,5,6],if you move behind 5 to 2, then cfId=5,targetId=2.
27
+ * if targetId does not exist, it defaults to top
28
+ */
29
+ moveRulePriority(unitId: string, subUnitId: string, cfId: string, targetCfId: string): void;
30
+ createCfId(unitId: string, subUnitId: string): string;
31
+ }
32
+ export {};
@@ -0,0 +1,29 @@
1
+ import { IConditionFormattingRule, IHighlightCell } from './type';
2
+ import { IDataBarRenderParams } from '../render/type';
3
+ import { ObjectMatrix } from '@univerjs/core';
4
+
5
+ interface ICellItem {
6
+ cfList: {
7
+ cfId: string;
8
+ ruleCache?: IHighlightCell['style'] | IDataBarRenderParams;
9
+ isDirty: boolean;
10
+ }[];
11
+ }
12
+ export declare class ConditionalFormattingViewModel {
13
+ private _model;
14
+ private _markDirty$;
15
+ markDirty$: import('rxjs').Observable<{
16
+ rule: IConditionFormattingRule;
17
+ unitId: string;
18
+ subUnitId: string;
19
+ }>;
20
+ private _ensureMatrix;
21
+ getMatrix(unitId: string, subUnitId: string): ObjectMatrix<ICellItem> | undefined;
22
+ getCellCf(unitId: string, subUnitId: string, row: number, col: number, matrix?: ObjectMatrix<ICellItem>): ICellItem | null;
23
+ setCellCfRuleCache(unitId: string, subUnitId: string, row: number, col: number, cfId: string, value: any): void;
24
+ deleteCellCf(unitId: string, subUnitId: string, row: number, col: number, cfId: string, matrix?: ObjectMatrix<ICellItem>): void;
25
+ pushCellCf(unitId: string, subUnitId: string, row: number, col: number, cfId: string): void;
26
+ sortCellCf(unitId: string, subUnitId: string, row: number, col: number, cfPriorityMap: Map<string, number>): void;
27
+ markRuleDirty(unitId: string, subUnitId: string, rule: IConditionFormattingRule, row?: number, col?: number): void;
28
+ }
29
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type IIconItem = string;
17
+ export declare const iconGroup: {
18
+ title: string;
19
+ group: {
20
+ name: string;
21
+ list: string[];
22
+ }[];
23
+ }[];
24
+ export declare const iconMap: Record<string, string[]>;
25
+ export type IIconType = keyof typeof iconMap;
26
+ export declare const EMPTY_ICON_TYPE = "EMPTY_ICON_TYPE";
@@ -0,0 +1,91 @@
1
+ import { IIconType } from './icon-map';
2
+ import { CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType } from '../base/const';
3
+ import { IRange, IStyleBase } from '@univerjs/core';
4
+
5
+ export interface IBaseCfRule {
6
+ type: string;
7
+ }
8
+ export interface IHighlightCell extends IBaseCfRule {
9
+ style: IStyleBase;
10
+ type: CFRuleType.highlightCell;
11
+ subType: CFSubRuleType;
12
+ }
13
+ export interface IValueConfig {
14
+ type: CFValueType;
15
+ value?: number | string;
16
+ }
17
+ export interface IUniqueValuesHighlightCell extends IHighlightCell {
18
+ subType: CFSubRuleType.uniqueValues;
19
+ }
20
+ export interface IDuplicateValuesHighlightCell extends IHighlightCell {
21
+ subType: CFSubRuleType.duplicateValues;
22
+ }
23
+ export interface IRankHighlightCell extends IHighlightCell {
24
+ subType: CFSubRuleType.rank;
25
+ isBottom: boolean;
26
+ isPercent: boolean;
27
+ value: number;
28
+ }
29
+ export interface ITextHighlightCell extends IHighlightCell {
30
+ subType: CFSubRuleType.text;
31
+ operator: CFTextOperator;
32
+ value?: string;
33
+ }
34
+ export interface ITimePeriodHighlightCell extends IHighlightCell {
35
+ subType: CFSubRuleType.timePeriod;
36
+ operator: CFTimePeriodOperator;
37
+ }
38
+ export interface IFormulaHighlightCell extends IHighlightCell {
39
+ subType: CFSubRuleType.formula;
40
+ value: string;
41
+ }
42
+ export type INumberHighlightCell = ({
43
+ subType: CFSubRuleType.number;
44
+ operator: CFNumberOperator.between | CFNumberOperator.notBetween;
45
+ value: [number, number];
46
+ } & IHighlightCell) | ({
47
+ subType: CFSubRuleType.number;
48
+ operator: CFNumberOperator.equal | CFNumberOperator.notEqual | CFNumberOperator.greaterThan | CFNumberOperator.greaterThanOrEqual | CFNumberOperator.lessThanOrEqual | CFNumberOperator.lessThan;
49
+ value?: number;
50
+ } & IHighlightCell);
51
+ export interface IAverageHighlightCell extends IHighlightCell {
52
+ subType: CFSubRuleType.average;
53
+ operator: CFNumberOperator.greaterThan | CFNumberOperator.greaterThanOrEqual | CFNumberOperator.lessThan | CFNumberOperator.lessThanOrEqual | CFNumberOperator.equal | CFNumberOperator.notEqual;
54
+ }
55
+ export interface IDataBar extends IBaseCfRule {
56
+ type: CFRuleType.dataBar;
57
+ config: {
58
+ min: IValueConfig;
59
+ max: IValueConfig;
60
+ isGradient: boolean;
61
+ positiveColor: string;
62
+ nativeColor: string;
63
+ };
64
+ }
65
+ export interface IColorScale extends IBaseCfRule {
66
+ type: CFRuleType.colorScale;
67
+ config: {
68
+ index: number;
69
+ color: string;
70
+ value: IValueConfig;
71
+ }[];
72
+ }
73
+ export interface IIconSet extends IBaseCfRule {
74
+ type: CFRuleType.iconSet;
75
+ isShowValue: boolean;
76
+ config: {
77
+ operator: CFNumberOperator;
78
+ value: IValueConfig;
79
+ iconType: IIconType;
80
+ iconId: string;
81
+ }[];
82
+ }
83
+ export type IConditionalFormattingRuleConfig = IColorScale | IDataBar | IUniqueValuesHighlightCell | IDuplicateValuesHighlightCell | IRankHighlightCell | ITextHighlightCell | ITimePeriodHighlightCell | INumberHighlightCell | IAverageHighlightCell | IFormulaHighlightCell | IIconSet;
84
+ export interface IConditionFormattingRule<C = IConditionalFormattingRuleConfig> {
85
+ ranges: IRange[];
86
+ cfId: string;
87
+ stopIfTrue: boolean;
88
+ rule: C;
89
+ }
90
+ export type IRuleModel = Map<string, Map<string, IConditionFormattingRule[]>>;
91
+ export type IRuleModelJson = Record<string, Record<string, IConditionFormattingRule[]>>;
@@ -0,0 +1,13 @@
1
+ import { Injector } from '@wendellhu/redi';
2
+ import { ICommandService, Plugin, PluginType } from '@univerjs/core';
3
+
4
+ export declare class SheetsConditionalFormattingPlugin extends Plugin {
5
+ readonly _injector: Injector;
6
+ private _commandService;
7
+ static type: PluginType;
8
+ static commandList: import('@univerjs/core').ICommand<object, boolean>[];
9
+ static mutationList: (import('@univerjs/core').IMutation<import("./commands/mutations/add-conditional-rule.mutation").IAddConditionalRuleMutationParams, boolean> | import('@univerjs/core').IMutation<import("./commands/mutations/delete-conditional-rule.mutation").IDeleteConditionalRuleMutationParams, boolean> | import('@univerjs/core').IMutation<import("./commands/mutations/formula-mark-dirty.mutation").IConditionalFormattingFormulaMarkDirtyParams, boolean>)[];
10
+ constructor(_config: unknown, _injector: Injector, _commandService: ICommandService);
11
+ onStarting(): void;
12
+ _initCommand(): void;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { SpreadsheetSkeleton, UniverRenderingContext, SheetExtension } from '@univerjs/engine-render';
2
+ import { IRange, IScale } from '@univerjs/core';
3
+
4
+ export declare const dataBarUKey = "sheet-conditional-rule-data-bar";
5
+ export declare class DataBar extends SheetExtension {
6
+ private _paddingRightAndLeft;
7
+ private _paddingTopAndBottom;
8
+ uKey: string;
9
+ Z_INDEX: number;
10
+ _radius: number;
11
+ draw(ctx: UniverRenderingContext, parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges?: IRange[]): false | undefined;
12
+ private _drawRectWithRoundedCorner;
13
+ }
@@ -0,0 +1,18 @@
1
+ import { SpreadsheetSkeleton, UniverRenderingContext, SheetExtension } from '@univerjs/engine-render';
2
+ import { IRange, IScale } from '@univerjs/core';
3
+
4
+ export declare const IconUKey = "sheet-conditional-rule-icon";
5
+ export declare const DEFAULT_WIDTH = 15;
6
+ export declare const DEFAULT_PADDING = 2;
7
+ export declare class ConditionalFormattingIcon extends SheetExtension {
8
+ private _paddingRightAndLeft;
9
+ private _width;
10
+ private _imageMap;
11
+ uKey: string;
12
+ Z_INDEX: number;
13
+ _radius: number;
14
+ constructor();
15
+ draw(ctx: UniverRenderingContext, parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges?: IRange[]): false | undefined;
16
+ private _init;
17
+ private _createKey;
18
+ }
@@ -0,0 +1,22 @@
1
+ import { IIconType } from '../models/icon-map';
2
+ import { ICellData } from '@univerjs/core';
3
+
4
+ export interface IDataBarRenderParams {
5
+ color: string;
6
+ value: number;
7
+ startPoint: number;
8
+ isGradient: boolean;
9
+ }
10
+ export interface IDataBarCellData extends ICellData {
11
+ dataBar?: IDataBarRenderParams;
12
+ }
13
+ export interface IIconSetRenderParams {
14
+ iconId: string;
15
+ iconType: IIconType;
16
+ isShowValue: boolean;
17
+ }
18
+ export interface IIconSetCellData extends ICellData {
19
+ iconSet?: IIconSetRenderParams;
20
+ _originV?: ICellData['v'];
21
+ }
22
+ export type IConditionalFormattingCellData = IDataBarCellData & IIconSetCellData;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
@@ -0,0 +1,24 @@
1
+ import { ConditionalFormattingViewModel } from '../../models/conditional-formatting-view-model';
2
+ import { ConditionalFormattingRuleModel } from '../../models/conditional-formatting-rule-model';
3
+ import { ConditionalFormattingService } from '../conditional-formatting.service';
4
+ import { Dependency } from '@wendellhu/redi';
5
+ import { ICommandService, Univer } from '@univerjs/core';
6
+
7
+ export declare const createTestBed: (dependencies?: Dependency[]) => {
8
+ univer: Univer;
9
+ get: {
10
+ <T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp | undefined): T;
11
+ <T_1>(id: import('@wendellhu/redi').DependencyIdentifier<T_1>, quantity: import("@wendellhu/redi").Quantity.MANY, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_1[];
12
+ <T_2>(id: import('@wendellhu/redi').DependencyIdentifier<T_2>, quantity: import("@wendellhu/redi").Quantity.OPTIONAL, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_2 | null;
13
+ <T_3>(id: import('@wendellhu/redi').DependencyIdentifier<T_3>, quantity: import("@wendellhu/redi").Quantity.REQUIRED, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_3;
14
+ <T_4>(id: import('@wendellhu/redi').DependencyIdentifier<T_4>, quantity?: import('@wendellhu/redi').Quantity | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_4 | T_4[] | null;
15
+ <T_5>(id: import('@wendellhu/redi').DependencyIdentifier<T_5>, quantityOrLookup?: import('@wendellhu/redi').Quantity | import('@wendellhu/redi').LookUp | undefined, lookUp?: import('@wendellhu/redi').LookUp | undefined): T_5 | T_5[] | null;
16
+ };
17
+ workbook: import('@univerjs/core').Workbook;
18
+ unitId: string;
19
+ subUnitId: string;
20
+ commandService: ICommandService;
21
+ getConditionalFormattingRuleModel: () => ConditionalFormattingRuleModel;
22
+ getConditionalFormattingViewModel: () => ConditionalFormattingViewModel;
23
+ getConditionalFormattingService: () => ConditionalFormattingService;
24
+ };
@@ -0,0 +1,3 @@
1
+ import { ICalculateUnit } from './type';
2
+
3
+ export declare const colorScaleCellCalculateUnit: ICalculateUnit;
@@ -0,0 +1,3 @@
1
+ import { ICalculateUnit } from './type';
2
+
3
+ export declare const dataBarCellCalculateUnit: ICalculateUnit;
@@ -0,0 +1,3 @@
1
+ import { ICalculateUnit } from './type';
2
+
3
+ export declare const highlightCellCalculateUnit: ICalculateUnit;
@@ -0,0 +1,3 @@
1
+ import { ICalculateUnit } from './type';
2
+
3
+ export declare const iconSetCalculateUnit: ICalculateUnit;
@@ -0,0 +1,17 @@
1
+ import { IConditionFormattingRule } from '../../models/type';
2
+ import { CFRuleType } from '../../base/const';
3
+ import { ObjectMatrix, Workbook, Worksheet } from '@univerjs/core';
4
+ import { IAccessor } from '@wendellhu/redi';
5
+
6
+ export interface IContext {
7
+ accessor: IAccessor;
8
+ unitId: string;
9
+ subUnitId: string;
10
+ workbook: Workbook;
11
+ worksheet: Worksheet;
12
+ }
13
+ export interface ICalculateUnit<R = any> {
14
+ type: CFRuleType;
15
+ handle: (rule: IConditionFormattingRule, context: IContext) => Promise<ObjectMatrix<R>>;
16
+ }
17
+ export declare const EMPTY_STYLE: unknown;
@@ -0,0 +1,33 @@
1
+ import { IContext } from './type';
2
+ import { FormulaResultStatus } from '../conditional-formatting-formula.service';
3
+ import { CFNumberOperator } from '../../base/const';
4
+ import { IConditionFormattingRule, IValueConfig } from '../../models/type';
5
+ import { ICellData, ColorKit, ObjectMatrix } from '@univerjs/core';
6
+
7
+ export declare function isFloatsEqual(a: number, b: number): boolean;
8
+ export declare const isNullable: (v: any) => boolean;
9
+ export declare const getCellValue: (cell?: ICellData) => import('@univerjs/core').Nullable<import("@univerjs/core").CellValue>;
10
+ export declare function toYMD_1900(ord: number, leap1900?: boolean): number[];
11
+ export declare const serialTimeToTimestamp: (value: number) => number;
12
+ export declare const getValueByType: (value: IValueConfig, matrix: ObjectMatrix<number>, context: IContext & {
13
+ cfId: string;
14
+ }) => {
15
+ status: FormulaResultStatus;
16
+ result?: undefined;
17
+ } | {
18
+ result: string | number | boolean | undefined;
19
+ status: FormulaResultStatus;
20
+ };
21
+ export declare const getCacheStyleMatrix: <S = any>(unitId: string, subUnitId: string, rule: IConditionFormattingRule, context: IContext) => ObjectMatrix<S>;
22
+ export declare const compareWithNumber: (config: {
23
+ operator: CFNumberOperator;
24
+ value: number | [
25
+ number,
26
+ number
27
+ ];
28
+ }, v: number) => boolean | undefined;
29
+ export declare const getOppositeOperator: (operator: CFNumberOperator) => CFNumberOperator;
30
+ export declare const getColorScaleFromValue: (colorList: {
31
+ color: ColorKit;
32
+ value: number;
33
+ }[], value: number) => string | undefined;
@@ -0,0 +1,57 @@
1
+ import { ConditionalFormattingRuleModel } from '../models/conditional-formatting-rule-model';
2
+ import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model';
3
+ import { IActiveDirtyManagerService } from '@univerjs/engine-formula';
4
+ import { Injector } from '@wendellhu/redi';
5
+ import { ObjectMatrix, Disposable, ICommandService, RefAlias } from '@univerjs/core';
6
+
7
+ type IFormulaItem = {
8
+ formulaText: string;
9
+ cfId: string;
10
+ result?: boolean | number | string;
11
+ status: FormulaResultStatus;
12
+ count: number;
13
+ formulaId: string;
14
+ };
15
+ export declare enum FormulaResultStatus {
16
+ NOT_REGISTER = 1,
17
+ SUCCESS = 2,
18
+ WAIT = 3,
19
+ ERROR = 4
20
+ }
21
+ export declare class ConditionalFormattingFormulaService extends Disposable {
22
+ private _commandService;
23
+ private _injector;
24
+ private _activeDirtyManagerService;
25
+ private _conditionalFormattingViewModel;
26
+ private _conditionalFormattingRuleModel;
27
+ private _formulaMap;
28
+ private _cache;
29
+ private _formulaChange$;
30
+ formulaChange$: import('rxjs').Observable<{
31
+ unitId: string;
32
+ subUnitId: string;
33
+ cfId: string;
34
+ formulaText: string;
35
+ formulaId: string;
36
+ }>;
37
+ constructor(_commandService: ICommandService, _injector: Injector, _activeDirtyManagerService: IActiveDirtyManagerService, _conditionalFormattingViewModel: ConditionalFormattingViewModel, _conditionalFormattingRuleModel: ConditionalFormattingRuleModel);
38
+ private _initCache;
39
+ private _initRuleChange;
40
+ private _initFormulaCalculationResultChange;
41
+ private _ensureSubunitFormulaMap;
42
+ private _ensureCacheMap;
43
+ private _deleteCache;
44
+ getCache(unitId: string, subUnitId: string, cfId: string): ObjectMatrix<unknown> | undefined;
45
+ getSubUnitFormulaMap(unitId: string, subUnitId: string): RefAlias<IFormulaItem, "formulaId" | "formulaText"> | undefined;
46
+ registerFormula(unitId: string, subUnitId: string, cfId: string, formulaText: string): void;
47
+ private _removeFormulaByCfId;
48
+ getFormulaResult(unitId: string, subUnitId: string, formulaText: string): {
49
+ status: FormulaResultStatus;
50
+ result?: undefined;
51
+ } | {
52
+ result: string | number | boolean | undefined;
53
+ status: FormulaResultStatus;
54
+ };
55
+ _createFormulaId(unitId: string, subUnitId: string): string;
56
+ }
57
+ export {};
@@ -0,0 +1,49 @@
1
+ import { IDataBarCellData, IIconSetCellData } from '../render/type';
2
+ import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model';
3
+ import { ConditionalFormattingRuleModel } from '../models/conditional-formatting-rule-model';
4
+ import { Injector } from '@wendellhu/redi';
5
+ import { SheetInterceptorService } from '@univerjs/sheets';
6
+ import { Disposable, ICommandService, InterceptorManager, IResourceManagerService, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
7
+
8
+ type ComputeStatus = 'computing' | 'end' | 'error';
9
+ export declare class ConditionalFormattingService extends Disposable {
10
+ private _conditionalFormattingRuleModel;
11
+ private _injector;
12
+ private _conditionalFormattingViewModel;
13
+ private _univerInstanceService;
14
+ private _resourceManagerService;
15
+ private _sheetInterceptorService;
16
+ private _commandService;
17
+ private _ruleCacheMap;
18
+ private _ruleComputeStatus$;
19
+ ruleComputeStatus$: import('rxjs').Observable<{
20
+ status: ComputeStatus;
21
+ result?: ObjectMatrix<any> | undefined;
22
+ unitId: string;
23
+ subUnitId: string;
24
+ cfId: string;
25
+ }>;
26
+ interceptorManager: InterceptorManager<{
27
+ beforeUpdateRuleResult: import('@univerjs/core').IInterceptor<{
28
+ subUnitId: string;
29
+ unitId: string;
30
+ cfId: string;
31
+ }, any>;
32
+ }>;
33
+ private _calculationUnitMap;
34
+ constructor(_conditionalFormattingRuleModel: ConditionalFormattingRuleModel, _injector: Injector, _conditionalFormattingViewModel: ConditionalFormattingViewModel, _univerInstanceService: IUniverInstanceService, _resourceManagerService: IResourceManagerService, _sheetInterceptorService: SheetInterceptorService, _commandService: ICommandService);
35
+ composeStyle(unitId: string, subUnitId: string, row: number, col: number): ({
36
+ style?: import('@univerjs/core').IStyleBase | undefined;
37
+ } & IDataBarCellData & IIconSetCellData) | null;
38
+ private _initSnapshot;
39
+ private _initSheetChange;
40
+ private _registerCalculationUnit;
41
+ private _getComputedCache;
42
+ private _setComputedCache;
43
+ private _deleteComputeCache;
44
+ private _initCacheManager;
45
+ private _initCellChange;
46
+ private _initRemoteCalculate;
47
+ private _handleCalculateUnit;
48
+ }
49
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IDocumentData } from '@univerjs/core';
2
+
3
+ export declare const getStringFromDataStream: (data: IDocumentData) => string;
@@ -0,0 +1,3 @@
1
+ import { IRange } from '@univerjs/core';
2
+
3
+ export declare const isRangesEqual: (oldRanges: IRange[], ranges: IRange[]) => boolean;