@univerjs/sheets-conditional-formatting 0.6.2 → 0.6.3

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.
@@ -0,0 +1,22 @@
1
+ import { CFNumberOperator, CFTimePeriodOperator } from '@univerjs/sheets-conditional-formatting';
2
+ /**
3
+ * @ignore
4
+ */
5
+ export interface IFSheetsConditionalFormattingEnum {
6
+ /**
7
+ * Conditional formatting number operator
8
+ */
9
+ ConditionFormatNumberOperatorEnum: typeof CFNumberOperator;
10
+ /**
11
+ * Conditional formatting time period operator
12
+ */
13
+ ConditionFormatTimePeriodOperatorEnum: typeof CFTimePeriodOperator;
14
+ }
15
+ export declare class FSheetsConditionalFormattingEnum implements IFSheetsConditionalFormattingEnum {
16
+ get ConditionFormatNumberOperatorEnum(): typeof CFNumberOperator;
17
+ get ConditionFormatTimePeriodOperatorEnum(): typeof CFTimePeriodOperator;
18
+ }
19
+ declare module '@univerjs/core/facade' {
20
+ interface FEnum extends IFSheetsConditionalFormattingEnum {
21
+ }
22
+ }
@@ -1,17 +1,19 @@
1
1
  import { IAnchor, IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';
2
2
  import { FRange } from '@univerjs/sheets/facade';
3
- import { FConditionalFormattingBuilder } from './conditional-formatting-builder';
3
+ import { FConditionalFormattingBuilder } from './f-conditional-formatting-builder';
4
4
  /**
5
5
  * @ignore
6
6
  */
7
7
  export interface IFRangeConditionalFormattingMixin {
8
8
  /**
9
- * Gets all the conditional formatting for the current range
10
- * @returns {IConditionFormattingRule[]} conditional formatting rules for the current range
9
+ * Gets all the conditional formatting for the current range.
10
+ * @returns {IConditionFormattingRule[]} conditional formatting rules for the current range.
11
11
  * @example
12
12
  * ```ts
13
13
  * const fWorkbook = univerAPI.getActiveWorkbook();
14
14
  * const fWorksheet = fWorkbook.getActiveSheet();
15
+ *
16
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:T100.
15
17
  * const fRange = fWorksheet.getRange('A1:T100');
16
18
  * const rule = fWorksheet.newConditionalFormattingRule()
17
19
  * .whenCellNotEmpty()
@@ -22,6 +24,7 @@ export interface IFRangeConditionalFormattingMixin {
22
24
  * .build();
23
25
  * fWorksheet.addConditionalFormattingRule(rule);
24
26
  *
27
+ * // Get all the conditional formatting rules for the range F6:H8.
25
28
  * const targetRange = fWorksheet.getRange('F6:H8');
26
29
  * const rules = targetRange.getConditionalFormattingRules();
27
30
  * console.log(rules);
@@ -35,6 +38,8 @@ export interface IFRangeConditionalFormattingMixin {
35
38
  * ```ts
36
39
  * const fWorkbook = univerAPI.getActiveWorkbook();
37
40
  * const fWorksheet = fWorkbook.getActiveSheet();
41
+ *
42
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:T100.
38
43
  * const fRange = fWorksheet.getRange('A1:T100');
39
44
  * const rule = fRange.createConditionalFormattingRule()
40
45
  * .whenCellNotEmpty()
@@ -49,6 +54,7 @@ export interface IFRangeConditionalFormattingMixin {
49
54
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
50
55
  /**
51
56
  * Add a new conditional format
57
+ * @deprecated use same API in FWorkSheet.
52
58
  * @param {IConditionFormattingRule} rule
53
59
  * @returns {FRange} Returns the current range instance for method chaining
54
60
  * @memberof IFRangeConditionalFormattingMixin
@@ -56,56 +62,45 @@ export interface IFRangeConditionalFormattingMixin {
56
62
  addConditionalFormattingRule(rule: IConditionFormattingRule): FRange;
57
63
  /**
58
64
  * Delete conditional format according to `cfId`
65
+ * @deprecated use same API in FWorkSheet.
59
66
  * @param {string} cfId
60
67
  * @returns {FRange} Returns the current range instance for method chaining
61
68
  * @memberof IFRangeConditionalFormattingMixin
62
- * @example
63
- * ```ts
64
- * const workbook = univerAPI.getActiveWorkbook();
65
- * const worksheet = workbook?.getActiveSheet();
66
- * const rules = worksheet?.getConditionalFormattingRules();
67
- * worksheet?.deleteConditionalFormattingRule(rules![0].cfId);
68
- * ```
69
69
  */
70
70
  deleteConditionalFormattingRule(cfId: string): FRange;
71
71
  /**
72
72
  * Modify the priority of the conditional format
73
+ * @deprecated use same API in FWorkSheet.
73
74
  * @param {string} cfId Rules that need to be moved
74
75
  * @param {string} toCfId Target rule
75
76
  * @param {IAnchor['type']} [type] After the default move to the destination rule, if type = before moves to the front, the default value is after
76
77
  * @returns {FRange} Returns the current range instance for method chaining
77
78
  * @memberof FRangeConditionalFormattingMixin
78
- * @example
79
- * ```ts
80
- * const workbook = univerAPI.getActiveWorkbook();
81
- * const worksheet = workbook?.getActiveSheet();
82
- * const rules = worksheet?.getConditionalFormattingRules()!;
83
- * const rule = rules[2];
84
- * const targetRule = rules[0];
85
- * worksheet?.moveConditionalFormattingRule(rule.cfId, targetRule.cfId, 'before');
86
- * ```
87
79
  */
88
80
  moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FRange;
89
81
  /**
90
82
  * Set the conditional format according to `cfId`
83
+ * @deprecated use same API in FWorkSheet.
91
84
  * @param {string} cfId
92
85
  * @param {IConditionFormattingRule} rule
93
86
  * @returns {FRange} Returns the current range instance for method chaining
94
87
  * @memberof IFRangeConditionalFormattingMixin
95
- * @example
96
- * ```ts
97
- * const workbook = univerAPI.getActiveWorkbook();
98
- * const worksheet = workbook?.getActiveSheet();
99
- * const rules = worksheet?.getConditionalFormattingRules()!;
100
- * const rule = rules[0];
101
- * worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });
102
- * ```
103
88
  */
104
89
  setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FRange;
105
90
  /**
106
91
  * Clear the conditional rules for the range.
107
92
  * @returns {FRange} Returns the current range instance for method chaining
108
93
  * @memberof IFRangeConditionalFormattingMixin
94
+ * @example
95
+ * ```ts
96
+ * const fWorkbook = univerAPI.getActiveWorkbook();
97
+ * const fWorksheet = fWorkbook.getActiveSheet();
98
+ * const fRange = fWorksheet.getRange('A1:T100');
99
+ *
100
+ * // Clear all conditional format rules for the range
101
+ * fRange.clearConditionalFormatRules();
102
+ * console.log(fRange.getConditionalFormattingRules()); // []
103
+ * ```
109
104
  */
110
105
  clearConditionalFormatRules(): FRange;
111
106
  }
@@ -1,6 +1,6 @@
1
1
  import { IAnchor, IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';
2
2
  import { FWorksheet } from '@univerjs/sheets/facade';
3
- import { FConditionalFormattingBuilder } from './conditional-formatting-builder';
3
+ import { FConditionalFormattingBuilder } from './f-conditional-formatting-builder';
4
4
  /**
5
5
  * @ignore
6
6
  */
@@ -23,20 +23,6 @@ export interface IFWorksheetConditionalFormattingMixin {
23
23
  * Creates a constructor for conditional formatting
24
24
  * @returns {FConditionalFormattingBuilder} The conditional formatting builder
25
25
  * @memberof IFWorksheetConditionalFormattingMixin
26
- * @example
27
- * ```ts
28
- * const fWorkbook = univerAPI.getActiveWorkbook();
29
- * const fWorksheet = fWorkbook.getActiveSheet();
30
- * const fRange = fWorksheet.getRange('A1:T100');
31
- * const rule = fWorksheet.createConditionalFormattingRule()
32
- * .whenCellNotEmpty()
33
- * .setRanges([fRange.getRange()])
34
- * .setItalic(true)
35
- * .setBackground('red')
36
- * .setFontColor('green')
37
- * .build();
38
- * fWorksheet.addConditionalFormattingRule(rule);
39
- * ```
40
26
  */
41
27
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
42
28
  /**
@@ -47,6 +33,8 @@ export interface IFWorksheetConditionalFormattingMixin {
47
33
  * ```ts
48
34
  * const fWorkbook = univerAPI.getActiveWorkbook();
49
35
  * const fWorksheet = fWorkbook.getActiveSheet();
36
+ *
37
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:T100.
50
38
  * const fRange = fWorksheet.getRange('A1:T100');
51
39
  * const rule = fWorksheet.newConditionalFormattingRule()
52
40
  * .whenCellNotEmpty()
@@ -68,6 +56,8 @@ export interface IFWorksheetConditionalFormattingMixin {
68
56
  * ```ts
69
57
  * const fWorkbook = univerAPI.getActiveWorkbook();
70
58
  * const fWorksheet = fWorkbook.getActiveSheet();
59
+ *
60
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:T100.
71
61
  * const fRange = fWorksheet.getRange('A1:T100');
72
62
  * const rule = fWorksheet.newConditionalFormattingRule()
73
63
  * .whenCellNotEmpty()
@@ -90,6 +80,8 @@ export interface IFWorksheetConditionalFormattingMixin {
90
80
  * const fWorkbook = univerAPI.getActiveWorkbook();
91
81
  * const fWorksheet = fWorkbook.getActiveSheet();
92
82
  * const rules = fWorksheet.getConditionalFormattingRules();
83
+ *
84
+ * // Delete the first rule
93
85
  * fWorksheet.deleteConditionalFormattingRule(rules[0]?.cfId);
94
86
  * ```
95
87
  */
@@ -106,6 +98,8 @@ export interface IFWorksheetConditionalFormattingMixin {
106
98
  * const fWorkbook = univerAPI.getActiveWorkbook();
107
99
  * const fWorksheet = fWorkbook.getActiveSheet();
108
100
  * const rules = fWorksheet.getConditionalFormattingRules();
101
+ *
102
+ * // Move the third rule before the first rule
109
103
  * const rule = rules[2];
110
104
  * const targetRule = rules[0];
111
105
  * fWorksheet.moveConditionalFormattingRule(rule?.cfId, targetRule?.cfId, 'before');
@@ -132,6 +126,7 @@ export interface IFWorksheetConditionalFormattingMixin {
132
126
  * .build();
133
127
  * fWorksheet.addConditionalFormattingRule(rule);
134
128
  *
129
+ * // Modify the first rule to apply to a new range
135
130
  * const rules = fWorksheet.getConditionalFormattingRules();
136
131
  * const newRuleRange = fWorksheet.getRange('A1:D10');
137
132
  * fWorksheet.setConditionalFormattingRule(rules[0]?.cfId, { ...rules[0], ranges: [newRuleRange.getRange()] });
@@ -147,7 +142,7 @@ export interface IFWorksheetConditionalFormattingMixin {
147
142
  * const fWorkbook = univerAPI.getActiveWorkbook();
148
143
  * const fWorksheet = fWorkbook.getActiveSheet();
149
144
  * fWorksheet.clearConditionalFormatRules();
150
- * console.log(fWorksheet.getConditionalFormattingRules());
145
+ * console.log(fWorksheet.getConditionalFormattingRules()); // []
151
146
  * ```
152
147
  */
153
148
  clearConditionalFormatRules(): FWorksheet;
@@ -16,7 +16,8 @@
16
16
  import './f-range';
17
17
  import './f-workbook';
18
18
  import './f-worksheet';
19
- export { FConditionalFormattingBuilder } from './conditional-formatting-builder';
19
+ import './f-enum';
20
+ export { FConditionalFormattingBuilder } from './f-conditional-formatting-builder';
20
21
  export type { IFRangeConditionalFormattingMixin } from './f-range';
21
22
  export type { FWorkbookConditionalFormattingMixin } from './f-workbook';
22
23
  export type { IFWorksheetConditionalFormattingMixin } from './f-worksheet';
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets/facade"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.UniverSheetsConditionalFormattingFacade={},l.UniverCore,l.UniverSheetsConditionalFormatting,l.UniverSheetsFacade))})(this,function(l,u,r,C){"use strict";var w=Object.defineProperty;var R=(l,u,r)=>u in l?w(l,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[u]=r;var _=(l,u,r)=>R(l,typeof u!="symbol"?u+"":u,r);class o{constructor(e={}){_(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=r.CFRuleType.highlightCell){switch(e){case r.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new u.ColorKit("").toRgbString(),value:{type:r.CFValueType.min}},{index:0,color:new u.ColorKit("green").toRgbString(),value:{type:r.CFValueType.max}}]};case r.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:r.CFValueType.min},max:{type:r.CFValueType.max},positiveColor:new u.ColorKit("green").toRgbString(),nativeColor:new u.ColorKit("").toRgbString(),isGradient:!1}};case r.CFRuleType.highlightCell:return{type:e,subType:r.CFSubRuleType.text,operator:r.CFTextOperator.containsText,value:"abc",style:{}};case r.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:r.CFNumberOperator.greaterThanOrEqual,value:{type:r.CFValueType.min},iconType:r.EMPTY_ICON_TYPE,iconId:""},{operator:r.CFNumberOperator.greaterThanOrEqual,value:{type:r.CFValueType.percentile,value:.5},iconType:r.EMPTY_ICON_TYPE,iconId:""},{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.max},iconType:r.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((i,s)=>(i[s]||(i[s]={}),i[s]),e),e}build(){var i;this._rule.cfId||(this._rule.cfId=r.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(i=this._rule.rule)!=null&&i.type||(this._rule.rule.type=r.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){return new o(u.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return r.iconMap}createCfId(){return r.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class n extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new n(u.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.duplicateValues,this}setRank(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const i=new u.ColorKit(e);this._ruleConfig.style.bg.rgb=i.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell)if(e){const i=new u.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=i.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.text,e.value="",e.operator=r.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.text,e.value="",e.operator=r.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const i=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=r.CFRuleType.highlightCell,h.subType=r.CFSubRuleType.number,h.value=[i,s],h.operator=r.CFNumberOperator.between,this}whenNumberEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){const i=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=r.CFRuleType.highlightCell,h.subType=r.CFSubRuleType.number,h.value=[i,s],h.operator=r.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.notEqual,this}whenTextContains(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.endsWith,this}whenTextEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.equal,this}whenTextStartsWith(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.beginsWith,this}}class a extends o{copy(){return new a(u.Tools.deepClone(this._rule))}setDataBar(e){const t=this._ruleConfig;return t.type=r.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}}class g extends o{copy(){return new g(u.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=r.CFRuleType.colorScale,t.config=e,this}}class y extends o{copy(){return new y(u.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=r.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class p{constructor(e={}){this._initConfig=e}build(){return new o(this._initConfig).build()}setAverage(e){return new n(this._initConfig).setAverage(e)}setUniqueValues(){return new n(this._initConfig).setUniqueValues()}setDuplicateValues(){return new n(this._initConfig).setDuplicateValues()}setRank(e){return new n(this._initConfig).setRank(e)}setIconSet(e){return new y(this._initConfig).setIconSet(e)}setColorScale(e){return new g(this._initConfig).setColorScale(e)}setDataBar(e){return new a(this._initConfig).setDataBar(e)}setBackground(e){return new n(this._initConfig).setBackground(e)}setBold(e){return new n(this._initConfig).setBold(e)}setFontColor(e){return new n(this._initConfig).setFontColor(e)}setItalic(e){return new n(this._initConfig).setItalic(e)}setStrikethrough(e){return new n(this._initConfig).setStrikethrough(e)}setUnderline(e){return new n(this._initConfig).setUnderline(e)}whenCellEmpty(){return new n(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new n(this._initConfig).whenCellNotEmpty()}whenDate(e){return new n(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new n(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new n(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new n(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new n(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new n(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new n(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new n(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new n(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new n(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new n(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new n(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new n(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new n(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new n(this._initConfig).whenTextStartsWith(e)}}class f extends C.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(r.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(i=>u.Rectangle.intersects(i,this._range)))}createConditionalFormattingRule(){return new p({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(r.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(r.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:i}};return this._commandService.syncExecuteCommand(r.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(r.SetConditionalRuleMutation.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(r.ClearRangeCfCommand.id,e),this}}C.FRange.extend(f);class c extends C.FWorkbook{newColor(){return new u.ColorBuilder}}C.FWorkbook.extend(c);class b extends C.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(r.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new p}newConditionalFormattingRule(){return new p}addConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(r.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(r.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:i}};return this._commandService.syncExecuteCommand(r.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,t){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(r.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(r.ClearWorksheetCfCommand.id,e),this}}C.FWorksheet.extend(b),l.FConditionalFormattingBuilder=p,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets/facade","@univerjs/core/facade"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.UniverSheetsConditionalFormattingFacade={},l.UniverCore,l.UniverSheetsConditionalFormatting,l.UniverSheetsFacade,l.UniverCoreFacade))})(this,function(l,u,t,C,y){"use strict";var R=Object.defineProperty;var m=(l,u,t)=>u in l?R(l,u,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[u]=t;var T=(l,u,t)=>m(l,typeof u!="symbol"?u+"":u,t);class o{constructor(e={}){T(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=t.CFRuleType.highlightCell){switch(e){case t.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new u.ColorKit("").toRgbString(),value:{type:t.CFValueType.min}},{index:0,color:new u.ColorKit("green").toRgbString(),value:{type:t.CFValueType.max}}]};case t.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:t.CFValueType.min},max:{type:t.CFValueType.max},positiveColor:new u.ColorKit("green").toRgbString(),nativeColor:new u.ColorKit("").toRgbString(),isGradient:!1}};case t.CFRuleType.highlightCell:return{type:e,subType:t.CFSubRuleType.text,operator:t.CFTextOperator.containsText,value:"abc",style:{}};case t.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:t.CFNumberOperator.greaterThanOrEqual,value:{type:t.CFValueType.min},iconType:t.EMPTY_ICON_TYPE,iconId:""},{operator:t.CFNumberOperator.greaterThanOrEqual,value:{type:t.CFValueType.percentile,value:.5},iconType:t.EMPTY_ICON_TYPE,iconId:""},{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.max},iconType:t.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,r){return r.reduce((i,s)=>(i[s]||(i[s]={}),i[s]),e),e}build(){var i;this._rule.cfId||(this._rule.cfId=t.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(i=this._rule.rule)!=null&&i.type||(this._rule.rule.type=t.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new o(e)}getRanges(){return this._rule.ranges||[]}getIconMap(){return t.iconMap}createCfId(){return t.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class n extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new n(e)}setAverage(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.average,r.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.duplicateValues,this}setRank(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.rank,r.isBottom=e.isBottom,r.isPercent=e.isPercent,r.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const i=new u.ColorKit(e);this._ruleConfig.style.bg.rgb=i.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell)if(e){const i=new u.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=i.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.text,e.value="",e.operator=t.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.text,e.value="",e.operator=t.CFTextOperator.notEqual,this}whenDate(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.timePeriod,r.operator=e,this}whenFormulaSatisfied(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.formula,r.value=e,this}whenNumberBetween(e,r){const i=Math.min(e,r),s=Math.max(e,r),h=this._ruleConfig;return h.type=t.CFRuleType.highlightCell,h.subType=t.CFSubRuleType.number,h.value=[i,s],h.operator=t.CFNumberOperator.between,this}whenNumberEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,r){const i=Math.min(e,r),s=Math.max(e,r),h=this._ruleConfig;return h.type=t.CFRuleType.highlightCell,h.subType=t.CFSubRuleType.number,h.value=[i,s],h.operator=t.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.notEqual,this}whenTextContains(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.endsWith,this}whenTextEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.equal,this}whenTextStartsWith(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.beginsWith,this}}class f extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new f(e)}setDataBar(e){const r=this._ruleConfig;return r.type=t.CFRuleType.dataBar,r.isShowValue=!!e.isShowValue,r.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}}class c extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new c(e)}setColorScale(e){const r=this._ruleConfig;return r.type=t.CFRuleType.colorScale,r.config=e,this}}class g extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new g(e)}setIconSet(e){const r=this._ruleConfig;return r.type=t.CFRuleType.iconSet,r.config=e.iconConfigs,r.isShowValue=e.isShowValue,this}}class p{constructor(e={}){this._initConfig=e}build(){return new o(this._initConfig).build()}setAverage(e){return new n(this._initConfig).setAverage(e)}setUniqueValues(){return new n(this._initConfig).setUniqueValues()}setDuplicateValues(){return new n(this._initConfig).setDuplicateValues()}setRank(e){return new n(this._initConfig).setRank(e)}getIconMap(){return t.iconMap}setIconSet(e){return new g(this._initConfig).setIconSet(e)}setColorScale(e){return new c(this._initConfig).setColorScale(e)}setDataBar(e){return new f(this._initConfig).setDataBar(e)}setBackground(e){return new n(this._initConfig).setBackground(e)}setBold(e){return new n(this._initConfig).setBold(e)}setFontColor(e){return new n(this._initConfig).setFontColor(e)}setItalic(e){return new n(this._initConfig).setItalic(e)}setStrikethrough(e){return new n(this._initConfig).setStrikethrough(e)}setUnderline(e){return new n(this._initConfig).setUnderline(e)}whenCellEmpty(){return new n(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new n(this._initConfig).whenCellNotEmpty()}whenDate(e){return new n(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new n(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,r){return new n(this._initConfig).whenNumberBetween(e,r)}whenNumberEqualTo(e){return new n(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new n(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new n(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new n(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new n(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,r){return new n(this._initConfig).whenNumberNotBetween(e,r)}whenNumberNotEqualTo(e){return new n(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new n(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new n(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new n(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new n(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new n(this._initConfig).whenTextStartsWith(e)}}class _ extends C.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(t.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(r=>r.ranges.some(i=>u.Rectangle.intersects(i,this._range)))}createConditionalFormattingRule(){return new p({ranges:[this._range]})}addConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(t.AddCfCommand.id,r),this}deleteConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(t.DeleteCfCommand.id,r),this}moveConditionalFormattingRule(e,r,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:i}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:r,cfId:e};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(t.ClearRangeCfCommand.id,e),this}}C.FRange.extend(_);class w extends C.FWorkbook{newColor(){return new u.ColorBuilder}}C.FWorkbook.extend(w);class b extends C.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(t.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new p}newConditionalFormattingRule(){return new p}addConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(t.AddCfCommand.id,r),this}deleteConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(t.DeleteCfCommand.id,r),this}moveConditionalFormattingRule(e,r,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:i}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:r};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(t.ClearWorksheetCfCommand.id,e),this}}C.FWorksheet.extend(b);class d{get ConditionFormatNumberOperatorEnum(){return t.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return t.CFTimePeriodOperator}}y.FEnum.extend(d),l.FConditionalFormattingBuilder=p,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,18 +53,18 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/core": "0.6.2",
57
- "@univerjs/engine-formula": "0.6.2",
58
- "@univerjs/engine-render": "0.6.2",
59
- "@univerjs/sheets": "0.6.2"
56
+ "@univerjs/core": "0.6.3",
57
+ "@univerjs/engine-formula": "0.6.3",
58
+ "@univerjs/engine-render": "0.6.3",
59
+ "@univerjs/sheets": "0.6.3"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@univerjs/icons-svg": "^0.2.20",
63
63
  "rxjs": "^7.8.1",
64
- "typescript": "^5.7.3",
64
+ "typescript": "^5.8.2",
65
65
  "vite": "^6.2.0",
66
66
  "vitest": "^3.0.7",
67
- "@univerjs-infra/shared": "0.6.2"
67
+ "@univerjs-infra/shared": "0.6.3"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",