@cool-office/sheets-conditional-formatting 0.0.0-stage → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +49 -2
  3. package/lib/cjs/facade.js +2237 -0
  4. package/lib/cjs/index.js +3211 -0
  5. package/lib/cjs/locale/ar-SA.js +10 -0
  6. package/lib/cjs/locale/ca-ES.js +10 -0
  7. package/lib/cjs/locale/de-DE.js +10 -0
  8. package/lib/cjs/locale/en-US.js +25 -0
  9. package/lib/cjs/locale/es-ES.js +10 -0
  10. package/lib/cjs/locale/fa-IR.js +10 -0
  11. package/lib/cjs/locale/fr-FR.js +10 -0
  12. package/lib/cjs/locale/id-ID.js +10 -0
  13. package/lib/cjs/locale/it-IT.js +10 -0
  14. package/lib/cjs/locale/ja-JP.js +10 -0
  15. package/lib/cjs/locale/ko-KR.js +10 -0
  16. package/lib/cjs/locale/pl-PL.js +10 -0
  17. package/lib/cjs/locale/pt-BR.js +10 -0
  18. package/lib/cjs/locale/ru-RU.js +10 -0
  19. package/lib/cjs/locale/sk-SK.js +10 -0
  20. package/lib/cjs/locale/vi-VN.js +10 -0
  21. package/lib/cjs/locale/zh-CN.js +10 -0
  22. package/lib/cjs/locale/zh-HK.js +10 -0
  23. package/lib/cjs/locale/zh-TW.js +10 -0
  24. package/lib/es/facade.js +2236 -0
  25. package/lib/es/index.js +3116 -0
  26. package/lib/es/locale/ar-SA.js +10 -0
  27. package/lib/es/locale/ca-ES.js +10 -0
  28. package/lib/es/locale/de-DE.js +10 -0
  29. package/lib/es/locale/en-US.js +25 -0
  30. package/lib/es/locale/es-ES.js +10 -0
  31. package/lib/es/locale/fa-IR.js +10 -0
  32. package/lib/es/locale/fr-FR.js +10 -0
  33. package/lib/es/locale/id-ID.js +10 -0
  34. package/lib/es/locale/it-IT.js +10 -0
  35. package/lib/es/locale/ja-JP.js +10 -0
  36. package/lib/es/locale/ko-KR.js +10 -0
  37. package/lib/es/locale/pl-PL.js +10 -0
  38. package/lib/es/locale/pt-BR.js +10 -0
  39. package/lib/es/locale/ru-RU.js +10 -0
  40. package/lib/es/locale/sk-SK.js +10 -0
  41. package/lib/es/locale/vi-VN.js +10 -0
  42. package/lib/es/locale/zh-CN.js +10 -0
  43. package/lib/es/locale/zh-HK.js +10 -0
  44. package/lib/es/locale/zh-TW.js +10 -0
  45. package/lib/facade.js +2236 -0
  46. package/lib/index.js +3116 -0
  47. package/lib/locale/ar-SA.js +10 -0
  48. package/lib/locale/ca-ES.js +10 -0
  49. package/lib/locale/de-DE.js +10 -0
  50. package/lib/locale/en-US.js +25 -0
  51. package/lib/locale/es-ES.js +10 -0
  52. package/lib/locale/fa-IR.js +10 -0
  53. package/lib/locale/fr-FR.js +10 -0
  54. package/lib/locale/id-ID.js +10 -0
  55. package/lib/locale/it-IT.js +10 -0
  56. package/lib/locale/ja-JP.js +10 -0
  57. package/lib/locale/ko-KR.js +10 -0
  58. package/lib/locale/pl-PL.js +10 -0
  59. package/lib/locale/pt-BR.js +10 -0
  60. package/lib/locale/ru-RU.js +10 -0
  61. package/lib/locale/sk-SK.js +10 -0
  62. package/lib/locale/vi-VN.js +10 -0
  63. package/lib/locale/zh-CN.js +10 -0
  64. package/lib/locale/zh-HK.js +10 -0
  65. package/lib/locale/zh-TW.js +10 -0
  66. package/lib/types/assets/icon-map.d.ts +79 -0
  67. package/lib/types/base/const.d.ts +80 -0
  68. package/lib/types/commands/commands/add-cf.command.d.ts +24 -0
  69. package/lib/types/commands/commands/clear-range-cf.command.d.ts +24 -0
  70. package/lib/types/commands/commands/clear-worksheet-cf.command.d.ts +21 -0
  71. package/lib/types/commands/commands/delete-cf.command.d.ts +22 -0
  72. package/lib/types/commands/commands/move-cf.command.d.ts +24 -0
  73. package/lib/types/commands/commands/set-cf.command.d.ts +24 -0
  74. package/lib/types/commands/mutations/add-conditional-rule.mutation.d.ts +28 -0
  75. package/lib/types/commands/mutations/delete-conditional-rule.mutation.d.ts +23 -0
  76. package/lib/types/commands/mutations/formula-mark-dirty.mutation.d.ts +24 -0
  77. package/lib/types/commands/mutations/move-conditional-rule.mutation.d.ts +28 -0
  78. package/lib/types/commands/mutations/set-conditional-rule.mutation.d.ts +28 -0
  79. package/lib/types/config/config.d.ts +20 -0
  80. package/lib/types/facade/f-conditional-formatting-builder.d.ts +1709 -0
  81. package/lib/types/facade/f-enum.d.ts +48 -0
  82. package/lib/types/facade/f-range.d.ts +99 -0
  83. package/lib/types/facade/f-worksheet.d.ts +180 -0
  84. package/lib/types/facade/index.d.ts +21 -0
  85. package/lib/types/index.d.ts +55 -0
  86. package/lib/types/locale/ar-SA.d.ts +18 -0
  87. package/lib/types/locale/ca-ES.d.ts +18 -0
  88. package/lib/types/locale/de-DE.d.ts +18 -0
  89. package/lib/types/locale/en-US.d.ts +26 -0
  90. package/lib/types/locale/es-ES.d.ts +18 -0
  91. package/lib/types/locale/fa-IR.d.ts +18 -0
  92. package/lib/types/locale/fr-FR.d.ts +18 -0
  93. package/lib/types/locale/id-ID.d.ts +18 -0
  94. package/lib/types/locale/it-IT.d.ts +18 -0
  95. package/lib/types/locale/ja-JP.d.ts +18 -0
  96. package/lib/types/locale/ko-KR.d.ts +18 -0
  97. package/lib/types/locale/pl-PL.d.ts +18 -0
  98. package/lib/types/locale/pt-BR.d.ts +18 -0
  99. package/lib/types/locale/ru-RU.d.ts +18 -0
  100. package/lib/types/locale/sk-SK.d.ts +18 -0
  101. package/lib/types/locale/types.d.ts +18 -0
  102. package/lib/types/locale/vi-VN.d.ts +18 -0
  103. package/lib/types/locale/zh-CN.d.ts +18 -0
  104. package/lib/types/locale/zh-HK.d.ts +18 -0
  105. package/lib/types/locale/zh-TW.d.ts +18 -0
  106. package/lib/types/models/calculate-unit-v2/base-calculate-unit.d.ts +68 -0
  107. package/lib/types/models/calculate-unit-v2/color-scale-calculate-unit.d.ts +27 -0
  108. package/lib/types/models/calculate-unit-v2/data-bar-calculate-unit.d.ts +33 -0
  109. package/lib/types/models/calculate-unit-v2/highlight-cell-calculate-unit.d.ts +28 -0
  110. package/lib/types/models/calculate-unit-v2/icon-set-calculate-unit.d.ts +34 -0
  111. package/lib/types/models/calculate-unit-v2/utils.d.ts +46 -0
  112. package/lib/types/models/conditional-formatting-range-index-model.d.ts +32 -0
  113. package/lib/types/models/conditional-formatting-rule-model.d.ts +45 -0
  114. package/lib/types/models/conditional-formatting-view-model.d.ts +78 -0
  115. package/lib/types/models/icon-map.d.ts +48 -0
  116. package/lib/types/models/type.d.ts +106 -0
  117. package/lib/types/plugin.d.ts +29 -0
  118. package/lib/types/render/data-bar.render.d.ts +35 -0
  119. package/lib/types/render/icon.render.d.ts +37 -0
  120. package/lib/types/render/type.d.ts +38 -0
  121. package/lib/types/services/conditional-formatting-formula.service.d.ts +73 -0
  122. package/lib/types/services/conditional-formatting-range-transform.service.d.ts +27 -0
  123. package/lib/types/services/conditional-formatting-style-composer.service.d.ts +35 -0
  124. package/lib/types/services/conditional-formatting.service.d.ts +41 -0
  125. package/lib/types/utils/anchor.d.ts +34 -0
  126. package/lib/types/utils/create-cf-id.d.ts +16 -0
  127. package/lib/types/utils/range.d.ts +18 -0
  128. package/lib/types/utils/remove-undefined-attr.d.ts +16 -0
  129. package/lib/types/utils/type.d.ts +18 -0
  130. package/lib/umd/facade.js +1 -0
  131. package/lib/umd/index.js +1 -0
  132. package/lib/umd/locale/ar-SA.js +1 -0
  133. package/lib/umd/locale/ca-ES.js +1 -0
  134. package/lib/umd/locale/de-DE.js +1 -0
  135. package/lib/umd/locale/en-US.js +1 -0
  136. package/lib/umd/locale/es-ES.js +1 -0
  137. package/lib/umd/locale/fa-IR.js +1 -0
  138. package/lib/umd/locale/fr-FR.js +1 -0
  139. package/lib/umd/locale/id-ID.js +1 -0
  140. package/lib/umd/locale/it-IT.js +1 -0
  141. package/lib/umd/locale/ja-JP.js +1 -0
  142. package/lib/umd/locale/ko-KR.js +1 -0
  143. package/lib/umd/locale/pl-PL.js +1 -0
  144. package/lib/umd/locale/pt-BR.js +1 -0
  145. package/lib/umd/locale/ru-RU.js +1 -0
  146. package/lib/umd/locale/sk-SK.js +1 -0
  147. package/lib/umd/locale/vi-VN.js +1 -0
  148. package/lib/umd/locale/zh-CN.js +1 -0
  149. package/lib/umd/locale/zh-HK.js +1 -0
  150. package/lib/umd/locale/zh-TW.js +1 -0
  151. package/package.json +90 -3
@@ -0,0 +1,2237 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _cool_office_core = require("@cool-office/core");
3
+ let _cool_office_sheets_conditional_formatting = require("@cool-office/sheets-conditional-formatting");
4
+ let _cool_office_sheets_facade = require("@cool-office/sheets/facade");
5
+ let _cool_office_core_facade = require("@cool-office/core/facade");
6
+
7
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
8
+ function _typeof(o) {
9
+ "@babel/helpers - typeof";
10
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
11
+ return typeof o;
12
+ } : function(o) {
13
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
14
+ }, _typeof(o);
15
+ }
16
+
17
+ //#endregion
18
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
19
+ function toPrimitive(t, r) {
20
+ if ("object" != _typeof(t) || !t) return t;
21
+ var e = t[Symbol.toPrimitive];
22
+ if (void 0 !== e) {
23
+ var i = e.call(t, r || "default");
24
+ if ("object" != _typeof(i)) return i;
25
+ throw new TypeError("@@toPrimitive must return a primitive value.");
26
+ }
27
+ return ("string" === r ? String : Number)(t);
28
+ }
29
+
30
+ //#endregion
31
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
32
+ function toPropertyKey(t) {
33
+ var i = toPrimitive(t, "string");
34
+ return "symbol" == _typeof(i) ? i : i + "";
35
+ }
36
+
37
+ //#endregion
38
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
39
+ function _defineProperty(e, r, t) {
40
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
+ value: t,
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0
45
+ }) : e[r] = t, e;
46
+ }
47
+
48
+ //#endregion
49
+ //#region src/facade/f-conditional-formatting-builder.ts
50
+ /**
51
+ * @ignore
52
+ * @hideconstructor
53
+ */
54
+ var ConditionalFormatRuleBaseBuilder = class ConditionalFormatRuleBaseBuilder {
55
+ get _ruleConfig() {
56
+ return this._rule.rule || null;
57
+ }
58
+ _getDefaultConfig(type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
59
+ switch (type) {
60
+ case _cool_office_sheets_conditional_formatting.CFRuleType.colorScale: return {
61
+ type,
62
+ config: [{
63
+ index: 0,
64
+ color: new _cool_office_core.ColorKit("").toRgbString(),
65
+ value: { type: _cool_office_sheets_conditional_formatting.CFValueType.min }
66
+ }, {
67
+ index: 0,
68
+ color: new _cool_office_core.ColorKit("green").toRgbString(),
69
+ value: { type: _cool_office_sheets_conditional_formatting.CFValueType.max }
70
+ }]
71
+ };
72
+ case _cool_office_sheets_conditional_formatting.CFRuleType.dataBar: return {
73
+ type,
74
+ isShowValue: true,
75
+ config: {
76
+ min: { type: _cool_office_sheets_conditional_formatting.CFValueType.min },
77
+ max: { type: _cool_office_sheets_conditional_formatting.CFValueType.max },
78
+ positiveColor: new _cool_office_core.ColorKit("green").toRgbString(),
79
+ nativeColor: new _cool_office_core.ColorKit("").toRgbString(),
80
+ isGradient: false
81
+ }
82
+ };
83
+ case _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell: return {
84
+ type,
85
+ subType: _cool_office_sheets_conditional_formatting.CFSubRuleType.text,
86
+ operator: _cool_office_sheets_conditional_formatting.CFTextOperator.containsText,
87
+ value: "abc",
88
+ style: {}
89
+ };
90
+ case _cool_office_sheets_conditional_formatting.CFRuleType.iconSet: return {
91
+ type,
92
+ isShowValue: true,
93
+ config: [
94
+ {
95
+ operator: _cool_office_sheets_conditional_formatting.CFNumberOperator.greaterThanOrEqual,
96
+ value: { type: _cool_office_sheets_conditional_formatting.CFValueType.min },
97
+ iconType: _cool_office_sheets_conditional_formatting.IIconSetType.empty,
98
+ iconId: ""
99
+ },
100
+ {
101
+ operator: _cool_office_sheets_conditional_formatting.CFNumberOperator.greaterThanOrEqual,
102
+ value: {
103
+ type: _cool_office_sheets_conditional_formatting.CFValueType.percentile,
104
+ value: .5
105
+ },
106
+ iconType: _cool_office_sheets_conditional_formatting.IIconSetType.empty,
107
+ iconId: ""
108
+ },
109
+ {
110
+ operator: _cool_office_sheets_conditional_formatting.CFNumberOperator.lessThanOrEqual,
111
+ value: { type: _cool_office_sheets_conditional_formatting.CFValueType.max },
112
+ iconType: _cool_office_sheets_conditional_formatting.IIconSetType.empty,
113
+ iconId: ""
114
+ }
115
+ ]
116
+ };
117
+ }
118
+ }
119
+ constructor(initRule = {}) {
120
+ _defineProperty(this, "_rule", {});
121
+ this._rule = initRule;
122
+ this._ensureAttr(this._rule, ["rule"]);
123
+ }
124
+ _ensureAttr(obj, keys) {
125
+ keys.reduce((pre, cur) => {
126
+ if (!pre[cur]) pre[cur] = {};
127
+ return pre[cur];
128
+ }, obj);
129
+ return obj;
130
+ }
131
+ /**
132
+ * Constructs a conditional format rule from the settings applied to the builder.
133
+ * @returns {IConditionFormattingRule} The conditional format rule.
134
+ * @example
135
+ * ```typescript
136
+ * const fWorkbook = univerAPI.getActiveWorkbook();
137
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
138
+ * if (!fWorksheet) return;
139
+ *
140
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
141
+ * const fRange = fWorksheet.getRange('A1:D10');
142
+ * const rule = fWorksheet.newConditionalFormattingRule()
143
+ * .whenCellEmpty()
144
+ * .setBackground('#FF0000')
145
+ * .setRanges([fRange.getRange()])
146
+ * .build();
147
+ * fWorksheet.addConditionalFormattingRule(rule);
148
+ * ```
149
+ */
150
+ build() {
151
+ var _this$_rule$rule;
152
+ if (!this._rule.cfId) this._rule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
153
+ if (!this._rule.ranges) this._rule.ranges = [];
154
+ if (this._rule.stopIfTrue === void 0) this._rule.stopIfTrue = false;
155
+ if (!((_this$_rule$rule = this._rule.rule) === null || _this$_rule$rule === void 0 ? void 0 : _this$_rule$rule.type)) {
156
+ this._rule.rule.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
157
+ this._ensureAttr(this._rule, ["rule", "style"]);
158
+ }
159
+ const defaultConfig = this._getDefaultConfig(this._rule.rule.type);
160
+ return {
161
+ ...this._rule,
162
+ rule: {
163
+ ...defaultConfig,
164
+ ...this._rule.rule
165
+ }
166
+ };
167
+ }
168
+ /**
169
+ * Deep clone a current builder.
170
+ * @returns {ConditionalFormatRuleBaseBuilder} A new builder with the same settings as the original.
171
+ * @example
172
+ * ```typescript
173
+ * const fWorkbook = univerAPI.getActiveWorkbook();
174
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
175
+ * if (!fWorksheet) return;
176
+ *
177
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
178
+ * const fRange = fWorksheet.getRange('A1:D10');
179
+ * const builder = fWorksheet.newConditionalFormattingRule()
180
+ * .whenCellEmpty()
181
+ * .setBackground('#FF0000')
182
+ * .setRanges([fRange.getRange()]);
183
+ * fWorksheet.addConditionalFormattingRule(builder.build());
184
+ *
185
+ * // Copy the rule and change the background color to green for the range A1:B2.
186
+ * const newRange = fWorksheet.getRange('A1:B2');
187
+ * const newBuilder = builder.copy()
188
+ * .setBackground('#00FF00')
189
+ * .setRanges([newRange.getRange()]);
190
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
191
+ * ```
192
+ */
193
+ copy() {
194
+ const newRule = _cool_office_core.Tools.deepClone(this._rule);
195
+ if (newRule.cfId) newRule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
196
+ return new ConditionalFormatRuleBaseBuilder(newRule);
197
+ }
198
+ /**
199
+ * Gets the scope of the current conditional format.
200
+ * @returns {IRange[]} The ranges to which the conditional format applies.
201
+ */
202
+ getRanges() {
203
+ return this._rule.ranges || [];
204
+ }
205
+ /**
206
+ * Get the icon set mapping dictionary.
207
+ * @returns {Record<string, string[]>} The icon set mapping dictionary.
208
+ */
209
+ getIconMap() {
210
+ return _cool_office_sheets_conditional_formatting.iconMap;
211
+ }
212
+ /**
213
+ * Create a conditional format ID.
214
+ * @returns {string} The conditional format ID.
215
+ */
216
+ createCfId() {
217
+ return (0, _cool_office_sheets_conditional_formatting.createCfId)();
218
+ }
219
+ /**
220
+ * Sets the scope for conditional formatting.
221
+ * @param {IRange[]} ranges - The ranges to which the conditional format applies.
222
+ * @returns {ConditionalFormatRuleBaseBuilder} This builder for chaining.
223
+ * @example
224
+ * ```typescript
225
+ * const fWorkbook = univerAPI.getActiveWorkbook();
226
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
227
+ * if (!fWorksheet) return;
228
+ *
229
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
230
+ * const fRange = fWorksheet.getRange('A1:D10');
231
+ * const rule = fWorksheet.newConditionalFormattingRule()
232
+ * .whenCellEmpty()
233
+ * .setBackground('#FF0000')
234
+ * .setRanges([fRange.getRange()])
235
+ * .build();
236
+ * fWorksheet.addConditionalFormattingRule(rule);
237
+ * ```
238
+ */
239
+ setRanges(ranges) {
240
+ this._rule.ranges = ranges;
241
+ return this;
242
+ }
243
+ };
244
+ /**
245
+ * @hideconstructor
246
+ */
247
+ var ConditionalFormatHighlightRuleBuilder = class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRuleBaseBuilder {
248
+ constructor(initConfig = {}) {
249
+ super(initConfig);
250
+ this._ensureAttr(this._rule, ["rule", "style"]);
251
+ }
252
+ /**
253
+ * Deep clone a current builder.
254
+ * @returns {ConditionalFormatHighlightRuleBuilder} A new builder with the same settings as the original.
255
+ * @example
256
+ * ```typescript
257
+ * const fWorkbook = univerAPI.getActiveWorkbook();
258
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
259
+ * if (!fWorksheet) return;
260
+ *
261
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
262
+ * const fRange = fWorksheet.getRange('A1:D10');
263
+ * const builder = fWorksheet.newConditionalFormattingRule()
264
+ * .whenCellEmpty()
265
+ * .setBackground('#FF0000')
266
+ * .setRanges([fRange.getRange()]);
267
+ * fWorksheet.addConditionalFormattingRule(builder.build());
268
+ *
269
+ * // Copy the rule and change the background color to green for the range A1:B2.
270
+ * const newRange = fWorksheet.getRange('A1:B2');
271
+ * const newBuilder = builder.copy()
272
+ * .setBackground('#00FF00')
273
+ * .setRanges([newRange.getRange()]);
274
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
275
+ * ```
276
+ */
277
+ copy() {
278
+ const newRule = _cool_office_core.Tools.deepClone(this._rule);
279
+ if (newRule.cfId) newRule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
280
+ return new ConditionalFormatHighlightRuleBuilder(newRule);
281
+ }
282
+ /**
283
+ * Set average rule.
284
+ * @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
285
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
286
+ * @example
287
+ * ```typescript
288
+ * const fWorkbook = univerAPI.getActiveWorkbook();
289
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
290
+ * if (!fWorksheet) return;
291
+ *
292
+ * // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
293
+ * const fRange = fWorksheet.getRange('A1:D10');
294
+ * const rule = fWorksheet.newConditionalFormattingRule()
295
+ * .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
296
+ * .setBackground('#FF0000')
297
+ * .setRanges([fRange.getRange()])
298
+ * .build();
299
+ * fWorksheet.addConditionalFormattingRule(rule);
300
+ * ```
301
+ */
302
+ setAverage(operator) {
303
+ const ruleConfig = this._ruleConfig;
304
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
305
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.average;
306
+ ruleConfig.operator = operator;
307
+ return this;
308
+ }
309
+ /**
310
+ * Set unique values rule.
311
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
312
+ * @example
313
+ * ```typescript
314
+ * const fWorkbook = univerAPI.getActiveWorkbook();
315
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
316
+ * if (!fWorksheet) return;
317
+ *
318
+ * // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
319
+ * const fRange = fWorksheet.getRange('A1:D10');
320
+ * const rule = fWorksheet.newConditionalFormattingRule()
321
+ * .setUniqueValues()
322
+ * .setBackground('#FF0000')
323
+ * .setRanges([fRange.getRange()])
324
+ * .build();
325
+ * fWorksheet.addConditionalFormattingRule(rule);
326
+ * ```
327
+ */
328
+ setUniqueValues() {
329
+ const ruleConfig = this._ruleConfig;
330
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
331
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.uniqueValues;
332
+ return this;
333
+ }
334
+ /**
335
+ * Set duplicate values rule.
336
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
337
+ * @example
338
+ * ```typescript
339
+ * const fWorkbook = univerAPI.getActiveWorkbook();
340
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
341
+ * if (!fWorksheet) return;
342
+ *
343
+ * // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
344
+ * const fRange = fWorksheet.getRange('A1:D10');
345
+ * const rule = fWorksheet.newConditionalFormattingRule()
346
+ * .setDuplicateValues()
347
+ * .setBackground('#FF0000')
348
+ * .setRanges([fRange.getRange()])
349
+ * .build();
350
+ * fWorksheet.addConditionalFormattingRule(rule);
351
+ * ```
352
+ */
353
+ setDuplicateValues() {
354
+ const ruleConfig = this._ruleConfig;
355
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
356
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.duplicateValues;
357
+ return this;
358
+ }
359
+ /**
360
+ * Set rank rule.
361
+ * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
362
+ * @param {boolean} config.isBottom - Whether to highlight the bottom rank.
363
+ * @param {boolean} config.isPercent - Whether to use a percentage rank.
364
+ * @param {number} config.value - The rank value.
365
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
366
+ * @example
367
+ * ```typescript
368
+ * const fWorkbook = univerAPI.getActiveWorkbook();
369
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
370
+ * if (!fWorksheet) return;
371
+ *
372
+ * // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
373
+ * const fRange = fWorksheet.getRange('A1:D10');
374
+ * const rule = fWorksheet.newConditionalFormattingRule()
375
+ * .setRank({ isBottom: true, isPercent: true, value: 10 })
376
+ * .setBackground('#FF0000')
377
+ * .setRanges([fRange.getRange()])
378
+ * .build();
379
+ * fWorksheet.addConditionalFormattingRule(rule);
380
+ * ```
381
+ */
382
+ setRank(config) {
383
+ const ruleConfig = this._ruleConfig;
384
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
385
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.rank;
386
+ ruleConfig.isBottom = config.isBottom;
387
+ ruleConfig.isPercent = config.isPercent;
388
+ ruleConfig.value = config.value;
389
+ return this;
390
+ }
391
+ /**
392
+ * Sets the background color for the conditional format rule's format.
393
+ * @param {string} [color] - The background color to set. If not provided, the background color is removed.
394
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
395
+ * @example
396
+ * ```typescript
397
+ * const fWorkbook = univerAPI.getActiveWorkbook();
398
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
399
+ * if (!fWorksheet) return;
400
+ *
401
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
402
+ * const fRange = fWorksheet.getRange('A1:D10');
403
+ * const rule = fWorksheet.newConditionalFormattingRule()
404
+ * .whenCellEmpty()
405
+ * .setBackground('#FF0000')
406
+ * .setRanges([fRange.getRange()])
407
+ * .build();
408
+ * fWorksheet.addConditionalFormattingRule(rule);
409
+ * ```
410
+ */
411
+ setBackground(color) {
412
+ var _this$_ruleConfig;
413
+ if (((_this$_ruleConfig = this._ruleConfig) === null || _this$_ruleConfig === void 0 ? void 0 : _this$_ruleConfig.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
414
+ if (color) {
415
+ this._ensureAttr(this._ruleConfig, ["style", "bg"]);
416
+ const colorKit = new _cool_office_core.ColorKit(color);
417
+ this._ruleConfig.style.bg.rgb = colorKit.toRgbString();
418
+ } else delete this._ruleConfig.style.bg;
419
+ }
420
+ return this;
421
+ }
422
+ /**
423
+ * Sets text bolding for the conditional format rule's format.
424
+ * @param {boolean} isBold - Whether to bold the text.
425
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
426
+ * @example
427
+ * ```typescript
428
+ * const fWorkbook = univerAPI.getActiveWorkbook();
429
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
430
+ * if (!fWorksheet) return;
431
+ *
432
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
433
+ * const fRange = fWorksheet.getRange('A1:D10');
434
+ * const rule = fWorksheet.newConditionalFormattingRule()
435
+ * .whenCellNotEmpty()
436
+ * .setBold(true)
437
+ * .setRanges([fRange.getRange()])
438
+ * .build();
439
+ * fWorksheet.addConditionalFormattingRule(rule);
440
+ * ```
441
+ */
442
+ setBold(isBold) {
443
+ var _this$_ruleConfig2;
444
+ if (((_this$_ruleConfig2 = this._ruleConfig) === null || _this$_ruleConfig2 === void 0 ? void 0 : _this$_ruleConfig2.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
445
+ this._ensureAttr(this._ruleConfig, ["style"]);
446
+ this._ruleConfig.style.bl = isBold ? _cool_office_core.BooleanNumber.TRUE : _cool_office_core.BooleanNumber.FALSE;
447
+ }
448
+ return this;
449
+ }
450
+ /**
451
+ * Sets the font color for the conditional format rule's format.
452
+ * @param {string} [color] - The font color to set. If not provided, the font color is removed.
453
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
454
+ * @example
455
+ * ```typescript
456
+ * const fWorkbook = univerAPI.getActiveWorkbook();
457
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
458
+ * if (!fWorksheet) return;
459
+ *
460
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
461
+ * const fRange = fWorksheet.getRange('A1:D10');
462
+ * const rule = fWorksheet.newConditionalFormattingRule()
463
+ * .whenCellNotEmpty()
464
+ * .setFontColor('#FF0000')
465
+ * .setRanges([fRange.getRange()])
466
+ * .build();
467
+ * fWorksheet.addConditionalFormattingRule(rule);
468
+ * ```
469
+ */
470
+ setFontColor(color) {
471
+ var _this$_ruleConfig3;
472
+ if (((_this$_ruleConfig3 = this._ruleConfig) === null || _this$_ruleConfig3 === void 0 ? void 0 : _this$_ruleConfig3.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
473
+ if (color) {
474
+ const colorKit = new _cool_office_core.ColorKit(color);
475
+ this._ensureAttr(this._ruleConfig, ["style", "cl"]);
476
+ this._ruleConfig.style.cl.rgb = colorKit.toRgbString();
477
+ } else delete this._ruleConfig.style.cl;
478
+ }
479
+ return this;
480
+ }
481
+ /**
482
+ * Sets text italics for the conditional format rule's format.
483
+ * @param {boolean} isItalic - Whether to italicize the text.
484
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
485
+ * @example
486
+ * ```typescript
487
+ * const fWorkbook = univerAPI.getActiveWorkbook();
488
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
489
+ * if (!fWorksheet) return;
490
+ *
491
+ * // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
492
+ * const fRange = fWorksheet.getRange('A1:D10');
493
+ * const rule = fWorksheet.newConditionalFormattingRule()
494
+ * .whenCellNotEmpty()
495
+ * .setItalic(true)
496
+ * .setRanges([fRange.getRange()])
497
+ * .build();
498
+ * fWorksheet.addConditionalFormattingRule(rule);
499
+ * ```
500
+ */
501
+ setItalic(isItalic) {
502
+ var _this$_ruleConfig4;
503
+ if (((_this$_ruleConfig4 = this._ruleConfig) === null || _this$_ruleConfig4 === void 0 ? void 0 : _this$_ruleConfig4.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
504
+ this._ensureAttr(this._ruleConfig, ["style"]);
505
+ this._ruleConfig.style.it = isItalic ? _cool_office_core.BooleanNumber.TRUE : _cool_office_core.BooleanNumber.FALSE;
506
+ }
507
+ return this;
508
+ }
509
+ /**
510
+ * Sets text strikethrough for the conditional format rule's format.
511
+ * @param {boolean} isStrikethrough - Whether is strikethrough the text.
512
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
513
+ * @example
514
+ * ```typescript
515
+ * const fWorkbook = univerAPI.getActiveWorkbook();
516
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
517
+ * if (!fWorksheet) return;
518
+ *
519
+ * // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
520
+ * const fRange = fWorksheet.getRange('A1:D10');
521
+ * const rule = fWorksheet.newConditionalFormattingRule()
522
+ * .whenCellNotEmpty()
523
+ * .setStrikethrough(true)
524
+ * .setRanges([fRange.getRange()])
525
+ * .build();
526
+ * fWorksheet.addConditionalFormattingRule(rule);
527
+ * ```
528
+ */
529
+ setStrikethrough(isStrikethrough) {
530
+ var _this$_ruleConfig5;
531
+ if (((_this$_ruleConfig5 = this._ruleConfig) === null || _this$_ruleConfig5 === void 0 ? void 0 : _this$_ruleConfig5.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
532
+ this._ensureAttr(this._ruleConfig, ["style", "st"]);
533
+ this._ruleConfig.style.st.s = isStrikethrough ? _cool_office_core.BooleanNumber.TRUE : _cool_office_core.BooleanNumber.FALSE;
534
+ }
535
+ return this;
536
+ }
537
+ /**
538
+ * Sets text underlining for the conditional format rule's format.
539
+ * @param {boolean} isUnderline - Whether to underline the text.
540
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
541
+ * @example
542
+ * ```typescript
543
+ * const fWorkbook = univerAPI.getActiveWorkbook();
544
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
545
+ * if (!fWorksheet) return;
546
+ *
547
+ * // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
548
+ * const fRange = fWorksheet.getRange('A1:D10');
549
+ * const rule = fWorksheet.newConditionalFormattingRule()
550
+ * .whenCellNotEmpty()
551
+ * .setUnderline(true)
552
+ * .setRanges([fRange.getRange()])
553
+ * .build();
554
+ * fWorksheet.addConditionalFormattingRule(rule);
555
+ * ```
556
+ */
557
+ setUnderline(isUnderline) {
558
+ var _this$_ruleConfig6;
559
+ if (((_this$_ruleConfig6 = this._ruleConfig) === null || _this$_ruleConfig6 === void 0 ? void 0 : _this$_ruleConfig6.type) === _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell) {
560
+ this._ensureAttr(this._ruleConfig, ["style", "ul"]);
561
+ this._ruleConfig.style.ul.s = isUnderline ? _cool_office_core.BooleanNumber.TRUE : _cool_office_core.BooleanNumber.FALSE;
562
+ }
563
+ return this;
564
+ }
565
+ /**
566
+ * Sets the conditional format rule to trigger when the cell is empty.
567
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
568
+ * @example
569
+ * ```typescript
570
+ * const fWorkbook = univerAPI.getActiveWorkbook();
571
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
572
+ * if (!fWorksheet) return;
573
+ *
574
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
575
+ * const fRange = fWorksheet.getRange('A1:D10');
576
+ * const rule = fWorksheet.newConditionalFormattingRule()
577
+ * .whenCellEmpty()
578
+ * .setBackground('#FF0000')
579
+ * .setRanges([fRange.getRange()])
580
+ * .build();
581
+ * fWorksheet.addConditionalFormattingRule(rule);
582
+ * ```
583
+ */
584
+ whenCellEmpty() {
585
+ const ruleConfig = this._ruleConfig;
586
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
587
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
588
+ ruleConfig.value = "";
589
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.equal;
590
+ return this;
591
+ }
592
+ /**
593
+ * Sets the conditional format rule to trigger when the cell is not empty.
594
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
595
+ * @example
596
+ * ```typescript
597
+ * const fWorkbook = univerAPI.getActiveWorkbook();
598
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
599
+ * if (!fWorksheet) return;
600
+ *
601
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
602
+ * const fRange = fWorksheet.getRange('A1:D10');
603
+ * const rule = fWorksheet.newConditionalFormattingRule()
604
+ * .whenCellNotEmpty()
605
+ * .setFontColor('#FF0000')
606
+ * .setRanges([fRange.getRange()])
607
+ * .build();
608
+ * fWorksheet.addConditionalFormattingRule(rule);
609
+ * ```
610
+ */
611
+ whenCellNotEmpty() {
612
+ const ruleConfig = this._ruleConfig;
613
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
614
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
615
+ ruleConfig.value = "";
616
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.notEqual;
617
+ return this;
618
+ }
619
+ /**
620
+ * Sets the conditional format rule to trigger when a time period is met.
621
+ * @param {CFTimePeriodOperator} date - The time period to check for.
622
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
623
+ * @example
624
+ * ```typescript
625
+ * const fWorkbook = univerAPI.getActiveWorkbook();
626
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
627
+ * if (!fWorksheet) return;
628
+ *
629
+ * // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
630
+ * const fRange = fWorksheet.getRange('A1:D10');
631
+ * const rule = fWorksheet.newConditionalFormattingRule()
632
+ * .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
633
+ * .setBackground('#FF0000')
634
+ * .setRanges([fRange.getRange()])
635
+ * .build();
636
+ * fWorksheet.addConditionalFormattingRule(rule);
637
+ * ```
638
+ */
639
+ whenDate(date) {
640
+ const ruleConfig = this._ruleConfig;
641
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
642
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.timePeriod;
643
+ ruleConfig.operator = date;
644
+ return this;
645
+ }
646
+ /**
647
+ * Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
648
+ * @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
649
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
650
+ * @example
651
+ * ```typescript
652
+ * const fWorkbook = univerAPI.getActiveWorkbook();
653
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
654
+ * if (!fWorksheet) return;
655
+ *
656
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
657
+ * const fRange = fWorksheet.getRange('A1:D10');
658
+ * const rule = fWorksheet.newConditionalFormattingRule()
659
+ * .whenFormulaSatisfied('=A1>10')
660
+ * .setBackground('#FF0000')
661
+ * .setRanges([fRange.getRange()])
662
+ * .build();
663
+ * fWorksheet.addConditionalFormattingRule(rule);
664
+ * ```
665
+ */
666
+ whenFormulaSatisfied(formulaString) {
667
+ const ruleConfig = this._ruleConfig;
668
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
669
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.formula;
670
+ ruleConfig.value = formulaString;
671
+ return this;
672
+ }
673
+ /**
674
+ * Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
675
+ * @param {number} start - The lowest acceptable value.
676
+ * @param {number} end - The highest acceptable value.
677
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
678
+ * @example
679
+ * ```typescript
680
+ * const fWorkbook = univerAPI.getActiveWorkbook();
681
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
682
+ * if (!fWorksheet) return;
683
+ *
684
+ * // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
685
+ * const fRange = fWorksheet.getRange('A1:D10');
686
+ * const rule = fWorksheet.newConditionalFormattingRule()
687
+ * .whenNumberBetween(10, 20)
688
+ * .setBackground('#FF0000')
689
+ * .setRanges([fRange.getRange()])
690
+ * .build();
691
+ * fWorksheet.addConditionalFormattingRule(rule);
692
+ * ```
693
+ */
694
+ whenNumberBetween(start, end) {
695
+ const min = Math.min(start, end);
696
+ const max = Math.max(start, end);
697
+ const ruleConfig = this._ruleConfig;
698
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
699
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
700
+ ruleConfig.value = [min, max];
701
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.between;
702
+ return this;
703
+ }
704
+ /**
705
+ * Sets the conditional format rule to trigger when a number is equal to the given value.
706
+ * @param {number} value - The sole acceptable value.
707
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
708
+ * @example
709
+ * ```typescript
710
+ * const fWorkbook = univerAPI.getActiveWorkbook();
711
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
712
+ * if (!fWorksheet) return;
713
+ *
714
+ * // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
715
+ * const fRange = fWorksheet.getRange('A1:D10');
716
+ * const rule = fWorksheet.newConditionalFormattingRule()
717
+ * .whenNumberEqualTo(10)
718
+ * .setBackground('#FF0000')
719
+ * .setRanges([fRange.getRange()])
720
+ * .build();
721
+ * fWorksheet.addConditionalFormattingRule(rule);
722
+ * ```
723
+ */
724
+ whenNumberEqualTo(value) {
725
+ const ruleConfig = this._ruleConfig;
726
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
727
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
728
+ ruleConfig.value = value;
729
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.equal;
730
+ return this;
731
+ }
732
+ /**
733
+ * Sets the conditional format rule to trigger when a number is greater than the given value.
734
+ * @param {number} value - The highest unacceptable value.
735
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
736
+ * @example
737
+ * ```typescript
738
+ * const fWorkbook = univerAPI.getActiveWorkbook();
739
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
740
+ * if (!fWorksheet) return;
741
+ *
742
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
743
+ * const fRange = fWorksheet.getRange('A1:D10');
744
+ * const rule = fWorksheet.newConditionalFormattingRule()
745
+ * .whenNumberGreaterThan(10)
746
+ * .setBackground('#FF0000')
747
+ * .setRanges([fRange.getRange()])
748
+ * .build();
749
+ * fWorksheet.addConditionalFormattingRule(rule);
750
+ * ```
751
+ */
752
+ whenNumberGreaterThan(value) {
753
+ const ruleConfig = this._ruleConfig;
754
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
755
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
756
+ ruleConfig.value = value;
757
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.greaterThan;
758
+ return this;
759
+ }
760
+ /**
761
+ * Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
762
+ * @param {number} value - The lowest acceptable value.
763
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
764
+ * @example
765
+ * ```typescript
766
+ * const fWorkbook = univerAPI.getActiveWorkbook();
767
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
768
+ * if (!fWorksheet) return;
769
+ *
770
+ * // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
771
+ * const fRange = fWorksheet.getRange('A1:D10');
772
+ * const rule = fWorksheet.newConditionalFormattingRule()
773
+ * .whenNumberGreaterThanOrEqualTo(10)
774
+ * .setBackground('#FF0000')
775
+ * .setRanges([fRange.getRange()])
776
+ * .build();
777
+ * fWorksheet.addConditionalFormattingRule(rule);
778
+ * ```
779
+ */
780
+ whenNumberGreaterThanOrEqualTo(value) {
781
+ const ruleConfig = this._ruleConfig;
782
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
783
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
784
+ ruleConfig.value = value;
785
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.greaterThanOrEqual;
786
+ return this;
787
+ }
788
+ /**
789
+ * Sets the conditional conditional format rule to trigger when a number less than the given value.
790
+ * @param {number} value - The lowest unacceptable value.
791
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
792
+ * @example
793
+ * ```typescript
794
+ * const fWorkbook = univerAPI.getActiveWorkbook();
795
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
796
+ * if (!fWorksheet) return;
797
+ *
798
+ * // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
799
+ * const fRange = fWorksheet.getRange('A1:D10');
800
+ * const rule = fWorksheet.newConditionalFormattingRule()
801
+ * .whenNumberLessThan(10)
802
+ * .setBackground('#FF0000')
803
+ * .setRanges([fRange.getRange()])
804
+ * .build();
805
+ * fWorksheet.addConditionalFormattingRule(rule);
806
+ * ```
807
+ */
808
+ whenNumberLessThan(value) {
809
+ const ruleConfig = this._ruleConfig;
810
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
811
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
812
+ ruleConfig.value = value;
813
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.lessThan;
814
+ return this;
815
+ }
816
+ /**
817
+ * Sets the conditional format rule to trigger when a number less than or equal to the given value.
818
+ * @param {number} value - The highest acceptable value.
819
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
820
+ * @example
821
+ * ```typescript
822
+ * const fWorkbook = univerAPI.getActiveWorkbook();
823
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
824
+ * if (!fWorksheet) return;
825
+ *
826
+ * // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
827
+ * const fRange = fWorksheet.getRange('A1:D10');
828
+ * const rule = fWorksheet.newConditionalFormattingRule()
829
+ * .whenNumberLessThanOrEqualTo(10)
830
+ * .setBackground('#FF0000')
831
+ * .setRanges([fRange.getRange()])
832
+ * .build();
833
+ * fWorksheet.addConditionalFormattingRule(rule);
834
+ * ```
835
+ */
836
+ whenNumberLessThanOrEqualTo(value) {
837
+ const ruleConfig = this._ruleConfig;
838
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
839
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
840
+ ruleConfig.value = value;
841
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.lessThanOrEqual;
842
+ return this;
843
+ }
844
+ /**
845
+ * Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
846
+ * @param {number} start - The lowest unacceptable value.
847
+ * @param {number} end - The highest unacceptable value.
848
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
849
+ * @example
850
+ * ```typescript
851
+ * const fWorkbook = univerAPI.getActiveWorkbook();
852
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
853
+ * if (!fWorksheet) return;
854
+ *
855
+ * // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
856
+ * const fRange = fWorksheet.getRange('A1:D10');
857
+ * const rule = fWorksheet.newConditionalFormattingRule()
858
+ * .whenNumberNotBetween(10, 20)
859
+ * .setBackground('#FF0000')
860
+ * .setRanges([fRange.getRange()])
861
+ * .build();
862
+ * fWorksheet.addConditionalFormattingRule(rule);
863
+ * ```
864
+ */
865
+ whenNumberNotBetween(start, end) {
866
+ const min = Math.min(start, end);
867
+ const max = Math.max(start, end);
868
+ const ruleConfig = this._ruleConfig;
869
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
870
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
871
+ ruleConfig.value = [min, max];
872
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.notBetween;
873
+ return this;
874
+ }
875
+ /**
876
+ * Sets the conditional format rule to trigger when a number is not equal to the given value.
877
+ * @param {number} value - The sole unacceptable value.
878
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
879
+ * @example
880
+ * ```typescript
881
+ * const fWorkbook = univerAPI.getActiveWorkbook();
882
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
883
+ * if (!fWorksheet) return;
884
+ *
885
+ * // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
886
+ * const fRange = fWorksheet.getRange('A1:D10');
887
+ * const rule = fWorksheet.newConditionalFormattingRule()
888
+ * .whenNumberNotEqualTo(10)
889
+ * .setBackground('#FF0000')
890
+ * .setRanges([fRange.getRange()])
891
+ * .build();
892
+ * fWorksheet.addConditionalFormattingRule(rule);
893
+ * ```
894
+ */
895
+ whenNumberNotEqualTo(value) {
896
+ const ruleConfig = this._ruleConfig;
897
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
898
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.number;
899
+ ruleConfig.value = value;
900
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFNumberOperator.notEqual;
901
+ return this;
902
+ }
903
+ /**
904
+ * Sets the conditional format rule to trigger when that the input contains the given value.
905
+ * @param {string} text - The value that the input must contain.
906
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
907
+ * @example
908
+ * ```typescript
909
+ * const fWorkbook = univerAPI.getActiveWorkbook();
910
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
911
+ * if (!fWorksheet) return;
912
+ *
913
+ * // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
914
+ * const fRange = fWorksheet.getRange('A1:D10');
915
+ * const rule = fWorksheet.newConditionalFormattingRule()
916
+ * .whenTextContains('apple')
917
+ * .setBackground('#FF0000')
918
+ * .setRanges([fRange.getRange()])
919
+ * .build();
920
+ * fWorksheet.addConditionalFormattingRule(rule);
921
+ * ```
922
+ */
923
+ whenTextContains(text) {
924
+ const ruleConfig = this._ruleConfig;
925
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
926
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
927
+ ruleConfig.value = text;
928
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.containsText;
929
+ return this;
930
+ }
931
+ /**
932
+ * Sets the conditional format rule to trigger when that the input does not contain the given value.
933
+ * @param {string} text - The value that the input must not contain.
934
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
935
+ * @example
936
+ * ```typescript
937
+ * const fWorkbook = univerAPI.getActiveWorkbook();
938
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
939
+ * if (!fWorksheet) return;
940
+ *
941
+ * // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
942
+ * const fRange = fWorksheet.getRange('A1:D10');
943
+ * const rule = fWorksheet.newConditionalFormattingRule()
944
+ * .whenTextDoesNotContain('apple')
945
+ * .setBackground('#FF0000')
946
+ * .setRanges([fRange.getRange()])
947
+ * .build();
948
+ * fWorksheet.addConditionalFormattingRule(rule);
949
+ * ```
950
+ */
951
+ whenTextDoesNotContain(text) {
952
+ const ruleConfig = this._ruleConfig;
953
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
954
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
955
+ ruleConfig.value = text;
956
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.notContainsText;
957
+ return this;
958
+ }
959
+ /**
960
+ * Sets the conditional format rule to trigger when that the input ends with the given value.
961
+ * @param {string} text - Text to compare against the end of the string.
962
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
963
+ * @example
964
+ * ```typescript
965
+ * const fWorkbook = univerAPI.getActiveWorkbook();
966
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
967
+ * if (!fWorksheet) return;
968
+ *
969
+ * // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
970
+ * const fRange = fWorksheet.getRange('A1:D10');
971
+ * const rule = fWorksheet.newConditionalFormattingRule()
972
+ * .whenTextEndsWith('.ai')
973
+ * .setBackground('#FF0000')
974
+ * .setRanges([fRange.getRange()])
975
+ * .build();
976
+ * fWorksheet.addConditionalFormattingRule(rule);
977
+ * ```
978
+ */
979
+ whenTextEndsWith(text) {
980
+ const ruleConfig = this._ruleConfig;
981
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
982
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
983
+ ruleConfig.value = text;
984
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.endsWith;
985
+ return this;
986
+ }
987
+ /**
988
+ * Sets the conditional format rule to trigger when that the input is equal to the given value.
989
+ * @param {string} text - The sole acceptable value.
990
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
991
+ * @example
992
+ * ```typescript
993
+ * const fWorkbook = univerAPI.getActiveWorkbook();
994
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
995
+ * if (!fWorksheet) return;
996
+ *
997
+ * // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
998
+ * const fRange = fWorksheet.getRange('A1:D10');
999
+ * const rule = fWorksheet.newConditionalFormattingRule()
1000
+ * .whenTextEqualTo('apple')
1001
+ * .setBackground('#FF0000')
1002
+ * .setRanges([fRange.getRange()])
1003
+ * .build();
1004
+ * fWorksheet.addConditionalFormattingRule(rule);
1005
+ * ```
1006
+ */
1007
+ whenTextEqualTo(text) {
1008
+ const ruleConfig = this._ruleConfig;
1009
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
1010
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
1011
+ ruleConfig.value = text;
1012
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.equal;
1013
+ return this;
1014
+ }
1015
+ /**
1016
+ * Sets the conditional format rule to trigger when that the input starts with the given value.
1017
+ * @param {string} text - Text to compare against the beginning of the string.
1018
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
1019
+ * @example
1020
+ * ```typescript
1021
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1022
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1023
+ * if (!fWorksheet) return;
1024
+ *
1025
+ * // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
1026
+ * const fRange = fWorksheet.getRange('A1:D10');
1027
+ * const rule = fWorksheet.newConditionalFormattingRule()
1028
+ * .whenTextStartsWith('https://')
1029
+ * .setBackground('#FF0000')
1030
+ * .setRanges([fRange.getRange()])
1031
+ * .build();
1032
+ * fWorksheet.addConditionalFormattingRule(rule);
1033
+ * ```
1034
+ */
1035
+ whenTextStartsWith(text) {
1036
+ const ruleConfig = this._ruleConfig;
1037
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.highlightCell;
1038
+ ruleConfig.subType = _cool_office_sheets_conditional_formatting.CFSubRuleType.text;
1039
+ ruleConfig.value = text;
1040
+ ruleConfig.operator = _cool_office_sheets_conditional_formatting.CFTextOperator.beginsWith;
1041
+ return this;
1042
+ }
1043
+ };
1044
+ var ConditionalFormatDataBarRuleBuilder = class ConditionalFormatDataBarRuleBuilder extends ConditionalFormatRuleBaseBuilder {
1045
+ /**
1046
+ * Deep clone a current builder.
1047
+ * @returns {ConditionalFormatDataBarRuleBuilder} A new instance of the builder with the same settings as the original.
1048
+ * @example
1049
+ * ```typescript
1050
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1051
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1052
+ * if (!fWorksheet) return;
1053
+ *
1054
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
1055
+ * // positive values are green and negative values are red.
1056
+ * const fRange = fWorksheet.getRange('A1:D10');
1057
+ * const builder = fWorksheet.newConditionalFormattingRule()
1058
+ * .setDataBar({
1059
+ * min: { type: 'num', value: -100 },
1060
+ * max: { type: 'num', value: 100 },
1061
+ * positiveColor: '#00FF00',
1062
+ * nativeColor: '#FF0000',
1063
+ * isShowValue: true
1064
+ * })
1065
+ * .setRanges([fRange.getRange()]);
1066
+ * fWorksheet.addConditionalFormattingRule(builder.build());
1067
+ *
1068
+ * // Copy the rule and apply it to a new range.
1069
+ * const newRange = fWorksheet.getRange('F1:F10');
1070
+ * const newBuilder = builder.copy()
1071
+ * .setRanges([newRange.getRange()]);
1072
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
1073
+ * ```
1074
+ */
1075
+ copy() {
1076
+ const newRule = _cool_office_core.Tools.deepClone(this._rule);
1077
+ if (newRule.cfId) newRule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
1078
+ return new ConditionalFormatDataBarRuleBuilder(newRule);
1079
+ }
1080
+ /**
1081
+ * Set data bar rule.
1082
+ * @param {object} config - The data bar rule settings.
1083
+ * @param {IValueConfig} config.min - The minimum value for the data bar.
1084
+ * @param {IValueConfig} config.max - The maximum value for the data bar.
1085
+ * @param {boolean} [config.isGradient] - Whether the data bar is gradient.
1086
+ * @param {string} config.positiveColor - The color for positive values.
1087
+ * @param {string} config.nativeColor - The color for negative values.
1088
+ * @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
1089
+ * @returns {ConditionalFormatDataBarRuleBuilder} This builder for chaining.
1090
+ * @example
1091
+ * ```typescript
1092
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1093
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1094
+ * if (!fWorksheet) return;
1095
+ *
1096
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
1097
+ * // positive values are green and negative values are red.
1098
+ * const fRange = fWorksheet.getRange('A1:D10');
1099
+ * const rule = fWorksheet.newConditionalFormattingRule()
1100
+ * .setDataBar({
1101
+ * min: { type: 'num', value: -100 },
1102
+ * max: { type: 'num', value: 100 },
1103
+ * positiveColor: '#00FF00',
1104
+ * nativeColor: '#FF0000',
1105
+ * isShowValue: true
1106
+ * })
1107
+ * .setRanges([fRange.getRange()])
1108
+ * .build();
1109
+ * fWorksheet.addConditionalFormattingRule(rule);
1110
+ * ```
1111
+ */
1112
+ setDataBar(config) {
1113
+ const ruleConfig = this._ruleConfig;
1114
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.dataBar;
1115
+ ruleConfig.isShowValue = !!config.isShowValue;
1116
+ ruleConfig.config = {
1117
+ min: config.min,
1118
+ max: config.max,
1119
+ positiveColor: config.positiveColor,
1120
+ nativeColor: config.nativeColor,
1121
+ isGradient: !!config.isGradient
1122
+ };
1123
+ return this;
1124
+ }
1125
+ };
1126
+ var ConditionalFormatColorScaleRuleBuilder = class ConditionalFormatColorScaleRuleBuilder extends ConditionalFormatRuleBaseBuilder {
1127
+ /**
1128
+ * Deep clone a current builder.
1129
+ * @returns {ConditionalFormatColorScaleRuleBuilder} A new instance of the builder with the same settings as the original.
1130
+ * @example
1131
+ * ```typescript
1132
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1133
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1134
+ * if (!fWorksheet) return;
1135
+ *
1136
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
1137
+ * // The color scale is green for 0, yellow for 50, and red for 100.
1138
+ * const fRange = fWorksheet.getRange('A1:D10');
1139
+ * const builder = fWorksheet.newConditionalFormattingRule()
1140
+ * .setColorScale([
1141
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
1142
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
1143
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
1144
+ * ])
1145
+ * .setRanges([fRange.getRange()]);
1146
+ * fWorksheet.addConditionalFormattingRule(builder.build());
1147
+ *
1148
+ * // Copy the rule and apply it to a new range.
1149
+ * const newRange = fWorksheet.getRange('F1:F10');
1150
+ * const newBuilder = builder.copy()
1151
+ * .setRanges([newRange.getRange()]);
1152
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
1153
+ * ```
1154
+ */
1155
+ copy() {
1156
+ const newRule = _cool_office_core.Tools.deepClone(this._rule);
1157
+ if (newRule.cfId) newRule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
1158
+ return new ConditionalFormatColorScaleRuleBuilder(newRule);
1159
+ }
1160
+ /**
1161
+ * Set color scale rule.
1162
+ * @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
1163
+ * @param {number} config.index - The index of the color scale configuration.
1164
+ * @param {string} config.color - The color corresponding to the index of the color scale configuration.
1165
+ * @param {IValueConfig} config.value - The condition value corresponding to the index of the color scale configuration.
1166
+ * @returns {ConditionalFormatColorScaleRuleBuilder} This builder for chaining.
1167
+ * @example
1168
+ * ```typescript
1169
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1170
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1171
+ * if (!fWorksheet) return;
1172
+ *
1173
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
1174
+ * // The color scale is green for 0, yellow for 50, and red for 100.
1175
+ * const fRange = fWorksheet.getRange('A1:D10');
1176
+ * const rule = fWorksheet.newConditionalFormattingRule()
1177
+ * .setColorScale([
1178
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
1179
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
1180
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
1181
+ * ])
1182
+ * .setRanges([fRange.getRange()])
1183
+ * .build();
1184
+ * fWorksheet.addConditionalFormattingRule(rule);
1185
+ * ```
1186
+ */
1187
+ setColorScale(config) {
1188
+ const ruleConfig = this._ruleConfig;
1189
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.colorScale;
1190
+ ruleConfig.config = config;
1191
+ return this;
1192
+ }
1193
+ };
1194
+ var ConditionalFormatIconSetRuleBuilder = class ConditionalFormatIconSetRuleBuilder extends ConditionalFormatRuleBaseBuilder {
1195
+ /**
1196
+ * Deep clone a current builder.
1197
+ * @returns {ConditionalFormatIconSetRuleBuilder} A new instance of the builder with the same settings as the original.
1198
+ * @example
1199
+ * ```typescript
1200
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1201
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1202
+ * if (!fWorksheet) return;
1203
+ *
1204
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
1205
+ * // The first arrow is green for values greater than 20.
1206
+ * // The second arrow is yellow for values greater than 10.
1207
+ * // The third arrow is red for values less than or equal to 10.
1208
+ * const fRange = fWorksheet.getRange('A1:D10');
1209
+ * const builder = fWorksheet.newConditionalFormattingRule()
1210
+ * .setIconSet({
1211
+ * iconConfigs: [
1212
+ * {
1213
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1214
+ * iconId: '0',
1215
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1216
+ * value: {
1217
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1218
+ * value: 20
1219
+ * }
1220
+ * },
1221
+ * {
1222
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1223
+ * iconId: '1',
1224
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1225
+ * value: {
1226
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1227
+ * value: 10
1228
+ * }
1229
+ * },
1230
+ * {
1231
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1232
+ * iconId: '2',
1233
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,
1234
+ * value: {
1235
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1236
+ * value: 10
1237
+ * }
1238
+ * }
1239
+ * ],
1240
+ * isShowValue: true,
1241
+ * })
1242
+ * .setRanges([fRange.getRange()]);
1243
+ * fWorksheet.addConditionalFormattingRule(builder.build());
1244
+ *
1245
+ * // Copy the rule and apply it to a new range.
1246
+ * const newRange = fWorksheet.getRange('F1:F10');
1247
+ * const newBuilder = builder.copy()
1248
+ * .setRanges([newRange.getRange()]);
1249
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
1250
+ * ```
1251
+ */
1252
+ copy() {
1253
+ const newRule = _cool_office_core.Tools.deepClone(this._rule);
1254
+ if (newRule.cfId) newRule.cfId = (0, _cool_office_sheets_conditional_formatting.createCfId)();
1255
+ return new ConditionalFormatIconSetRuleBuilder(newRule);
1256
+ }
1257
+ /**
1258
+ * Set up icon set conditional formatting rule.
1259
+ * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
1260
+ * @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
1261
+ * @param {boolean} config.isShowValue - Whether to show the value in the cell.
1262
+ * @returns {ConditionalFormatIconSetRuleBuilder} This builder for chaining.
1263
+ * @example
1264
+ * ```typescript
1265
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1266
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1267
+ * if (!fWorksheet) return;
1268
+ *
1269
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
1270
+ * // The first arrow is green for values greater than 20.
1271
+ * // The second arrow is yellow for values greater than 10.
1272
+ * // The third arrow is red for values less than or equal to 10.
1273
+ * const fRange = fWorksheet.getRange('A1:D10');
1274
+ * const builder = fWorksheet.newConditionalFormattingRule();
1275
+ * console.log(builder.getIconMap()); // icons key-value map
1276
+ * const rule = builder.setIconSet({
1277
+ * iconConfigs: [
1278
+ * {
1279
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1280
+ * iconId: '0',
1281
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1282
+ * value: {
1283
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1284
+ * value: 20
1285
+ * }
1286
+ * },
1287
+ * {
1288
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1289
+ * iconId: '1',
1290
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1291
+ * value: {
1292
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1293
+ * value: 10
1294
+ * }
1295
+ * },
1296
+ * {
1297
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1298
+ * iconId: '2',
1299
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,
1300
+ * value: {
1301
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1302
+ * value: 10
1303
+ * }
1304
+ * }
1305
+ * ],
1306
+ * isShowValue: true,
1307
+ * })
1308
+ * .setRanges([fRange.getRange()])
1309
+ * .build();
1310
+ * fWorksheet.addConditionalFormattingRule(rule);
1311
+ * ```
1312
+ */
1313
+ setIconSet(config) {
1314
+ const ruleConfig = this._ruleConfig;
1315
+ ruleConfig.type = _cool_office_sheets_conditional_formatting.CFRuleType.iconSet;
1316
+ ruleConfig.config = config.iconConfigs;
1317
+ ruleConfig.isShowValue = config.isShowValue;
1318
+ return this;
1319
+ }
1320
+ };
1321
+ /**
1322
+ * @hideconstructor
1323
+ */
1324
+ var FConditionalFormattingBuilder = class {
1325
+ constructor(_initConfig = {}) {
1326
+ this._initConfig = _initConfig;
1327
+ }
1328
+ /**
1329
+ * Constructs a conditional format rule from the settings applied to the builder.
1330
+ * @returns {IConditionFormattingRule} The conditional format rule.
1331
+ * @example
1332
+ * ```typescript
1333
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1334
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1335
+ * if (!fWorksheet) return;
1336
+ *
1337
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1338
+ * const fRange = fWorksheet.getRange('A1:D10');
1339
+ * const rule = fWorksheet.newConditionalFormattingRule()
1340
+ * .whenNumberGreaterThan(10)
1341
+ * .setBackground('#FF0000')
1342
+ * .setRanges([fRange.getRange()])
1343
+ * .build();
1344
+ * fWorksheet.addConditionalFormattingRule(rule);
1345
+ * ```
1346
+ */
1347
+ build() {
1348
+ return new ConditionalFormatRuleBaseBuilder(this._initConfig).build();
1349
+ }
1350
+ /**
1351
+ * Set average rule.
1352
+ * @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
1353
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1354
+ * @example
1355
+ * ```typescript
1356
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1357
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1358
+ * if (!fWorksheet) return;
1359
+ *
1360
+ * // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
1361
+ * const fRange = fWorksheet.getRange('A1:D10');
1362
+ * const rule = fWorksheet.newConditionalFormattingRule()
1363
+ * .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
1364
+ * .setBackground('#FF0000')
1365
+ * .setRanges([fRange.getRange()])
1366
+ * .build();
1367
+ * fWorksheet.addConditionalFormattingRule(rule);
1368
+ * ```
1369
+ */
1370
+ setAverage(operator) {
1371
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setAverage(operator);
1372
+ }
1373
+ /**
1374
+ * Set unique values rule.
1375
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1376
+ * @example
1377
+ * ```typescript
1378
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1379
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1380
+ * if (!fWorksheet) return;
1381
+ *
1382
+ * // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
1383
+ * const fRange = fWorksheet.getRange('A1:D10');
1384
+ * const rule = fWorksheet.newConditionalFormattingRule()
1385
+ * .setUniqueValues()
1386
+ * .setBackground('#FF0000')
1387
+ * .setRanges([fRange.getRange()])
1388
+ * .build();
1389
+ * fWorksheet.addConditionalFormattingRule(rule);
1390
+ * ```
1391
+ */
1392
+ setUniqueValues() {
1393
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setUniqueValues();
1394
+ }
1395
+ /**
1396
+ * Set duplicate values rule.
1397
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1398
+ * @example
1399
+ * ```typescript
1400
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1401
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1402
+ * if (!fWorksheet) return;
1403
+ *
1404
+ * // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
1405
+ * const fRange = fWorksheet.getRange('A1:D10');
1406
+ * const rule = fWorksheet.newConditionalFormattingRule()
1407
+ * .setDuplicateValues()
1408
+ * .setBackground('#FF0000')
1409
+ * .setRanges([fRange.getRange()])
1410
+ * .build();
1411
+ * fWorksheet.addConditionalFormattingRule(rule);
1412
+ * ```
1413
+ */
1414
+ setDuplicateValues() {
1415
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setDuplicateValues();
1416
+ }
1417
+ /**
1418
+ * Set rank rule.
1419
+ * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
1420
+ * @param {boolean} config.isBottom - Whether to highlight the bottom rank.
1421
+ * @param {boolean} config.isPercent - Whether to use a percentage rank.
1422
+ * @param {number} config.value - The rank value.
1423
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1424
+ * @example
1425
+ * ```typescript
1426
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1427
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1428
+ * if (!fWorksheet) return;
1429
+ *
1430
+ * // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
1431
+ * const fRange = fWorksheet.getRange('A1:D10');
1432
+ * const rule = fWorksheet.newConditionalFormattingRule()
1433
+ * .setRank({ isBottom: true, isPercent: true, value: 10 })
1434
+ * .setBackground('#FF0000')
1435
+ * .setRanges([fRange.getRange()])
1436
+ * .build();
1437
+ * fWorksheet.addConditionalFormattingRule(rule);
1438
+ * ```
1439
+ */
1440
+ setRank(config) {
1441
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setRank(config);
1442
+ }
1443
+ /**
1444
+ * Get the icon set mapping dictionary.
1445
+ * @returns {Record<string, string[]>} The icon set mapping dictionary.
1446
+ * @example
1447
+ * ```typescript
1448
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1449
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1450
+ * if (!fWorksheet) return;
1451
+ * console.log(fWorksheet.newConditionalFormattingRule().getIconMap()); // icons key-value map
1452
+ * ```
1453
+ */
1454
+ getIconMap() {
1455
+ return _cool_office_sheets_conditional_formatting.iconMap;
1456
+ }
1457
+ /**
1458
+ * Set up icon set conditional formatting rule.
1459
+ * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
1460
+ * @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
1461
+ * @param {boolean} config.isShowValue - Whether to show the value in the cell.
1462
+ * @returns {ConditionalFormatIconSetRuleBuilder} The conditional format icon set rule builder.
1463
+ * @example
1464
+ * ```typescript
1465
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1466
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1467
+ * if (!fWorksheet) return;
1468
+ *
1469
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
1470
+ * // The first arrow is green for values greater than 20.
1471
+ * // The second arrow is yellow for values greater than 10.
1472
+ * // The third arrow is red for values less than or equal to 10.
1473
+ * const fRange = fWorksheet.getRange('A1:D10');
1474
+ * const builder = fWorksheet.newConditionalFormattingRule();
1475
+ * console.log(builder.getIconMap()); // icons key-value map
1476
+ * const rule = builder.setIconSet({
1477
+ * iconConfigs: [
1478
+ * {
1479
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1480
+ * iconId: '0',
1481
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1482
+ * value: {
1483
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1484
+ * value: 20
1485
+ * }
1486
+ * },
1487
+ * {
1488
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1489
+ * iconId: '1',
1490
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,
1491
+ * value: {
1492
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1493
+ * value: 10
1494
+ * }
1495
+ * },
1496
+ * {
1497
+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,
1498
+ * iconId: '2',
1499
+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,
1500
+ * value: {
1501
+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,
1502
+ * value: 10
1503
+ * }
1504
+ * }
1505
+ * ],
1506
+ * isShowValue: true,
1507
+ * })
1508
+ * .setRanges([fRange.getRange()])
1509
+ * .build();
1510
+ * fWorksheet.addConditionalFormattingRule(rule);
1511
+ * ```
1512
+ */
1513
+ setIconSet(config) {
1514
+ return new ConditionalFormatIconSetRuleBuilder(this._initConfig).setIconSet(config);
1515
+ }
1516
+ /**
1517
+ * Set color scale rule.
1518
+ * @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
1519
+ * @param {number} config.index - The index of the color scale.
1520
+ * @param {string} config.color - The color for the color scale.
1521
+ * @param {IValueConfig} config.value - The value for the color scale.
1522
+ * @returns {ConditionalFormatColorScaleRuleBuilder} The conditional format color scale rule builder.
1523
+ * @example
1524
+ * ```typescript
1525
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1526
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1527
+ * if (!fWorksheet) return;
1528
+ *
1529
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
1530
+ * // The color scale is green for 0, yellow for 50, and red for 100.
1531
+ * const fRange = fWorksheet.getRange('A1:D10');
1532
+ * const rule = fWorksheet.newConditionalFormattingRule()
1533
+ * .setColorScale([
1534
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
1535
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
1536
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
1537
+ * ])
1538
+ * .setRanges([fRange.getRange()])
1539
+ * .build();
1540
+ * fWorksheet.addConditionalFormattingRule(rule);
1541
+ * ```
1542
+ */
1543
+ setColorScale(config) {
1544
+ return new ConditionalFormatColorScaleRuleBuilder(this._initConfig).setColorScale(config);
1545
+ }
1546
+ /**
1547
+ * Set data bar rule.
1548
+ * @param {object} config - The data bar rule settings.
1549
+ * @param {IValueConfig} config.min - The minimum value for the data bar.
1550
+ * @param {IValueConfig} config.max - The maximum value for the data bar.
1551
+ * @param {boolean} [config.isGradient] - Whether the data bar is gradient.
1552
+ * @param {string} config.positiveColor - The color for positive values.
1553
+ * @param {string} config.nativeColor - The color for negative values.
1554
+ * @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
1555
+ * @returns {ConditionalFormatDataBarRuleBuilder} The conditional format data bar rule builder.
1556
+ * @example
1557
+ * ```typescript
1558
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1559
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1560
+ * if (!fWorksheet) return;
1561
+ *
1562
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
1563
+ * // positive values are green and negative values are red.
1564
+ * const fRange = fWorksheet.getRange('A1:D10');
1565
+ * const rule = fWorksheet.newConditionalFormattingRule()
1566
+ * .setDataBar({
1567
+ * min: { type: 'num', value: -100 },
1568
+ * max: { type: 'num', value: 100 },
1569
+ * positiveColor: '#00FF00',
1570
+ * nativeColor: '#FF0000',
1571
+ * isShowValue: true
1572
+ * })
1573
+ * .setRanges([fRange.getRange()])
1574
+ * .build();
1575
+ * fWorksheet.addConditionalFormattingRule(rule);
1576
+ * ```
1577
+ */
1578
+ setDataBar(config) {
1579
+ return new ConditionalFormatDataBarRuleBuilder(this._initConfig).setDataBar(config);
1580
+ }
1581
+ /**
1582
+ * Sets the background color for the conditional format rule's format.
1583
+ * @param {string} [color] - The background color to set. If not provided, the background color is removed.
1584
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1585
+ * @example
1586
+ * ```typescript
1587
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1588
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1589
+ * if (!fWorksheet) return;
1590
+ *
1591
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
1592
+ * const fRange = fWorksheet.getRange('A1:D10');
1593
+ * const rule = fWorksheet.newConditionalFormattingRule()
1594
+ * .whenCellEmpty()
1595
+ * .setBackground('#FF0000')
1596
+ * .setRanges([fRange.getRange()])
1597
+ * .build();
1598
+ * fWorksheet.addConditionalFormattingRule(rule);
1599
+ * ```
1600
+ */
1601
+ setBackground(color) {
1602
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setBackground(color);
1603
+ }
1604
+ /**
1605
+ * Sets text bolding for the conditional format rule's format.
1606
+ * @param {boolean} isBold - Whether to bold the text.
1607
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1608
+ * @example
1609
+ * ```typescript
1610
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1611
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1612
+ * if (!fWorksheet) return;
1613
+ *
1614
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
1615
+ * const fRange = fWorksheet.getRange('A1:D10');
1616
+ * const rule = fWorksheet.newConditionalFormattingRule()
1617
+ * .whenCellNotEmpty()
1618
+ * .setBold(true)
1619
+ * .setRanges([fRange.getRange()])
1620
+ * .build();
1621
+ * fWorksheet.addConditionalFormattingRule(rule);
1622
+ * ```
1623
+ */
1624
+ setBold(isBold) {
1625
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setBold(isBold);
1626
+ }
1627
+ /**
1628
+ * Sets the font color for the conditional format rule's format.
1629
+ * @param {string} [color] - The font color to set. If not provided, the font color is removed.
1630
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1631
+ * @example
1632
+ * ```typescript
1633
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1634
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1635
+ * if (!fWorksheet) return;
1636
+ *
1637
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
1638
+ * const fRange = fWorksheet.getRange('A1:D10');
1639
+ * const rule = fWorksheet.newConditionalFormattingRule()
1640
+ * .whenCellNotEmpty()
1641
+ * .setFontColor('#FF0000')
1642
+ * .setRanges([fRange.getRange()])
1643
+ * .build();
1644
+ * fWorksheet.addConditionalFormattingRule(rule);
1645
+ * ```
1646
+ */
1647
+ setFontColor(color) {
1648
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setFontColor(color);
1649
+ }
1650
+ /**
1651
+ * Sets text italics for the conditional format rule's format.
1652
+ * @param {boolean} isItalic - Whether to italicize the text.
1653
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1654
+ * @example
1655
+ * ```typescript
1656
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1657
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1658
+ * if (!fWorksheet) return;
1659
+ *
1660
+ * // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
1661
+ * const fRange = fWorksheet.getRange('A1:D10');
1662
+ * const rule = fWorksheet.newConditionalFormattingRule()
1663
+ * .whenCellNotEmpty()
1664
+ * .setItalic(true)
1665
+ * .setRanges([fRange.getRange()])
1666
+ * .build();
1667
+ * fWorksheet.addConditionalFormattingRule(rule);
1668
+ * ```
1669
+ */
1670
+ setItalic(isItalic) {
1671
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setItalic(isItalic);
1672
+ }
1673
+ /**
1674
+ * Sets text strikethrough for the conditional format rule's format.
1675
+ * @param {boolean} isStrikethrough - Whether is strikethrough the text.
1676
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1677
+ * @example
1678
+ * ```typescript
1679
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1680
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1681
+ * if (!fWorksheet) return;
1682
+ *
1683
+ * // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
1684
+ * const fRange = fWorksheet.getRange('A1:D10');
1685
+ * const rule = fWorksheet.newConditionalFormattingRule()
1686
+ * .whenCellNotEmpty()
1687
+ * .setStrikethrough(true)
1688
+ * .setRanges([fRange.getRange()])
1689
+ * .build();
1690
+ * fWorksheet.addConditionalFormattingRule(rule);
1691
+ * ```
1692
+ */
1693
+ setStrikethrough(isStrikethrough) {
1694
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setStrikethrough(isStrikethrough);
1695
+ }
1696
+ /**
1697
+ * Sets text underlining for the conditional format rule's format.
1698
+ * @param {boolean} isUnderline - Whether to underline the text.
1699
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1700
+ * @example
1701
+ * ```typescript
1702
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1703
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1704
+ * if (!fWorksheet) return;
1705
+ *
1706
+ * // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
1707
+ * const fRange = fWorksheet.getRange('A1:D10');
1708
+ * const rule = fWorksheet.newConditionalFormattingRule()
1709
+ * .whenCellNotEmpty()
1710
+ * .setUnderline(true)
1711
+ * .setRanges([fRange.getRange()])
1712
+ * .build();
1713
+ * fWorksheet.addConditionalFormattingRule(rule);
1714
+ * ```
1715
+ */
1716
+ setUnderline(isUnderline) {
1717
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).setUnderline(isUnderline);
1718
+ }
1719
+ /**
1720
+ * Sets the conditional format rule to trigger when the cell is empty.
1721
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1722
+ * @example
1723
+ * ```typescript
1724
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1725
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1726
+ * if (!fWorksheet) return;
1727
+ *
1728
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
1729
+ * const fRange = fWorksheet.getRange('A1:D10');
1730
+ * const rule = fWorksheet.newConditionalFormattingRule()
1731
+ * .whenCellEmpty()
1732
+ * .setBackground('#FF0000')
1733
+ * .setRanges([fRange.getRange()])
1734
+ * .build();
1735
+ * fWorksheet.addConditionalFormattingRule(rule);
1736
+ * ```
1737
+ */
1738
+ whenCellEmpty() {
1739
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenCellEmpty();
1740
+ }
1741
+ /**
1742
+ * Sets the conditional format rule to trigger when the cell is not empty.
1743
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1744
+ * @example
1745
+ * ```typescript
1746
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1747
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1748
+ * if (!fWorksheet) return;
1749
+ *
1750
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
1751
+ * const fRange = fWorksheet.getRange('A1:D10');
1752
+ * const rule = fWorksheet.newConditionalFormattingRule()
1753
+ * .whenCellNotEmpty()
1754
+ * .setFontColor('#FF0000')
1755
+ * .setRanges([fRange.getRange()])
1756
+ * .build();
1757
+ * fWorksheet.addConditionalFormattingRule(rule);
1758
+ * ```
1759
+ */
1760
+ whenCellNotEmpty() {
1761
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenCellNotEmpty();
1762
+ }
1763
+ /**
1764
+ * Sets the conditional format rule to trigger when a time period is met.
1765
+ * @param {CFTimePeriodOperator} date - The time period to check for.
1766
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1767
+ * @example
1768
+ * ```typescript
1769
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1770
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1771
+ * if (!fWorksheet) return;
1772
+ *
1773
+ * // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
1774
+ * const fRange = fWorksheet.getRange('A1:D10');
1775
+ * const rule = fWorksheet.newConditionalFormattingRule()
1776
+ * .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
1777
+ * .setBackground('#FF0000')
1778
+ * .setRanges([fRange.getRange()])
1779
+ * .build();
1780
+ * fWorksheet.addConditionalFormattingRule(rule);
1781
+ * ```
1782
+ */
1783
+ whenDate(date) {
1784
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenDate(date);
1785
+ }
1786
+ /**
1787
+ * Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
1788
+ * @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
1789
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1790
+ * @example
1791
+ * ```typescript
1792
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1793
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1794
+ * if (!fWorksheet) return;
1795
+ *
1796
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1797
+ * const fRange = fWorksheet.getRange('A1:D10');
1798
+ * const rule = fWorksheet.newConditionalFormattingRule()
1799
+ * .whenFormulaSatisfied('=A1>10')
1800
+ * .setBackground('#FF0000')
1801
+ * .setRanges([fRange.getRange()])
1802
+ * .build();
1803
+ * fWorksheet.addConditionalFormattingRule(rule);
1804
+ * ```
1805
+ */
1806
+ whenFormulaSatisfied(formulaString) {
1807
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenFormulaSatisfied(formulaString);
1808
+ }
1809
+ /**
1810
+ * Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
1811
+ * @param {number} start - The lowest acceptable value.
1812
+ * @param {number} end - The highest acceptable value.
1813
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1814
+ * @example
1815
+ * ```typescript
1816
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1817
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1818
+ * if (!fWorksheet) return;
1819
+ *
1820
+ * // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
1821
+ * const fRange = fWorksheet.getRange('A1:D10');
1822
+ * const rule = fWorksheet.newConditionalFormattingRule()
1823
+ * .whenNumberBetween(10, 20)
1824
+ * .setBackground('#FF0000')
1825
+ * .setRanges([fRange.getRange()])
1826
+ * .build();
1827
+ * fWorksheet.addConditionalFormattingRule(rule);
1828
+ * ```
1829
+ */
1830
+ whenNumberBetween(start, end) {
1831
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberBetween(start, end);
1832
+ }
1833
+ /**
1834
+ * Sets the conditional format rule to trigger when a number is equal to the given value.
1835
+ * @param {number} value - The sole acceptable value.
1836
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1837
+ * @example
1838
+ * ```typescript
1839
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1840
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1841
+ * if (!fWorksheet) return;
1842
+ *
1843
+ * // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
1844
+ * const fRange = fWorksheet.getRange('A1:D10');
1845
+ * const rule = fWorksheet.newConditionalFormattingRule()
1846
+ * .whenNumberEqualTo(10)
1847
+ * .setBackground('#FF0000')
1848
+ * .setRanges([fRange.getRange()])
1849
+ * .build();
1850
+ * fWorksheet.addConditionalFormattingRule(rule);
1851
+ * ```
1852
+ */
1853
+ whenNumberEqualTo(value) {
1854
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberEqualTo(value);
1855
+ }
1856
+ /**
1857
+ * Sets the conditional format rule to trigger when a number is greater than the given value.
1858
+ * @param {number} value - The highest unacceptable value.
1859
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1860
+ * @example
1861
+ * ```typescript
1862
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1863
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1864
+ * if (!fWorksheet) return;
1865
+ *
1866
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1867
+ * const fRange = fWorksheet.getRange('A1:D10');
1868
+ * const rule = fWorksheet.newConditionalFormattingRule()
1869
+ * .whenNumberGreaterThan(10)
1870
+ * .setBackground('#FF0000')
1871
+ * .setRanges([fRange.getRange()])
1872
+ * .build();
1873
+ * fWorksheet.addConditionalFormattingRule(rule);
1874
+ * ```
1875
+ */
1876
+ whenNumberGreaterThan(value) {
1877
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberGreaterThan(value);
1878
+ }
1879
+ /**
1880
+ * Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
1881
+ * @param {number} value - The lowest acceptable value.
1882
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1883
+ * @example
1884
+ * ```typescript
1885
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1886
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1887
+ * if (!fWorksheet) return;
1888
+ *
1889
+ * // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
1890
+ * const fRange = fWorksheet.getRange('A1:D10');
1891
+ * const rule = fWorksheet.newConditionalFormattingRule()
1892
+ * .whenNumberGreaterThanOrEqualTo(10)
1893
+ * .setBackground('#FF0000')
1894
+ * .setRanges([fRange.getRange()])
1895
+ * .build();
1896
+ * fWorksheet.addConditionalFormattingRule(rule);
1897
+ * ```
1898
+ */
1899
+ whenNumberGreaterThanOrEqualTo(value) {
1900
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberGreaterThanOrEqualTo(value);
1901
+ }
1902
+ /**
1903
+ * Sets the conditional conditional format rule to trigger when a number less than the given value.
1904
+ * @param {number} value - The lowest unacceptable value.
1905
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1906
+ * @example
1907
+ * ```typescript
1908
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1909
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1910
+ * if (!fWorksheet) return;
1911
+ *
1912
+ * // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
1913
+ * const fRange = fWorksheet.getRange('A1:D10');
1914
+ * const rule = fWorksheet.newConditionalFormattingRule()
1915
+ * .whenNumberLessThan(10)
1916
+ * .setBackground('#FF0000')
1917
+ * .setRanges([fRange.getRange()])
1918
+ * .build();
1919
+ * fWorksheet.addConditionalFormattingRule(rule);
1920
+ * ```
1921
+ */
1922
+ whenNumberLessThan(value) {
1923
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberLessThan(value);
1924
+ }
1925
+ /**
1926
+ * Sets the conditional format rule to trigger when a number less than or equal to the given value.
1927
+ * @param {number} value - The highest acceptable value.
1928
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1929
+ * @example
1930
+ * ```typescript
1931
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1932
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1933
+ * if (!fWorksheet) return;
1934
+ *
1935
+ * // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
1936
+ * const fRange = fWorksheet.getRange('A1:D10');
1937
+ * const rule = fWorksheet.newConditionalFormattingRule()
1938
+ * .whenNumberLessThanOrEqualTo(10)
1939
+ * .setBackground('#FF0000')
1940
+ * .setRanges([fRange.getRange()])
1941
+ * .build();
1942
+ * fWorksheet.addConditionalFormattingRule(rule);
1943
+ * ```
1944
+ */
1945
+ whenNumberLessThanOrEqualTo(value) {
1946
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberLessThanOrEqualTo(value);
1947
+ }
1948
+ /**
1949
+ * Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
1950
+ * @param {number} start - The lowest unacceptable value.
1951
+ * @param {number} end - The highest unacceptable value.
1952
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1953
+ * @example
1954
+ * ```typescript
1955
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1956
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1957
+ * if (!fWorksheet) return;
1958
+ *
1959
+ * // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
1960
+ * const fRange = fWorksheet.getRange('A1:D10');
1961
+ * const rule = fWorksheet.newConditionalFormattingRule()
1962
+ * .whenNumberNotBetween(10, 20)
1963
+ * .setBackground('#FF0000')
1964
+ * .setRanges([fRange.getRange()])
1965
+ * .build();
1966
+ * fWorksheet.addConditionalFormattingRule(rule);
1967
+ * ```
1968
+ */
1969
+ whenNumberNotBetween(start, end) {
1970
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberNotBetween(start, end);
1971
+ }
1972
+ /**
1973
+ * Sets the conditional format rule to trigger when a number is not equal to the given value.
1974
+ * @param {number} value - The sole unacceptable value.
1975
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1976
+ * @example
1977
+ * ```typescript
1978
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1979
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
1980
+ * if (!fWorksheet) return;
1981
+ *
1982
+ * // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
1983
+ * const fRange = fWorksheet.getRange('A1:D10');
1984
+ * const rule = fWorksheet.newConditionalFormattingRule()
1985
+ * .whenNumberNotEqualTo(10)
1986
+ * .setBackground('#FF0000')
1987
+ * .setRanges([fRange.getRange()])
1988
+ * .build();
1989
+ * fWorksheet.addConditionalFormattingRule(rule);
1990
+ * ```
1991
+ */
1992
+ whenNumberNotEqualTo(value) {
1993
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenNumberNotEqualTo(value);
1994
+ }
1995
+ /**
1996
+ * Sets the conditional format rule to trigger when that the input contains the given value.
1997
+ * @param {string} text - The value that the input must contain.
1998
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1999
+ * @example
2000
+ * ```typescript
2001
+ * const fWorkbook = univerAPI.getActiveWorkbook();
2002
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
2003
+ * if (!fWorksheet) return;
2004
+ *
2005
+ * // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
2006
+ * const fRange = fWorksheet.getRange('A1:D10');
2007
+ * const rule = fWorksheet.newConditionalFormattingRule()
2008
+ * .whenTextContains('apple')
2009
+ * .setBackground('#FF0000')
2010
+ * .setRanges([fRange.getRange()])
2011
+ * .build();
2012
+ * fWorksheet.addConditionalFormattingRule(rule);
2013
+ * ```
2014
+ */
2015
+ whenTextContains(text) {
2016
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenTextContains(text);
2017
+ }
2018
+ /**
2019
+ * Sets the conditional format rule to trigger when that the input does not contain the given value.
2020
+ * @param {string} text - The value that the input must not contain.
2021
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
2022
+ * @example
2023
+ * ```typescript
2024
+ * const fWorkbook = univerAPI.getActiveWorkbook();
2025
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
2026
+ * if (!fWorksheet) return;
2027
+ *
2028
+ * // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
2029
+ * const fRange = fWorksheet.getRange('A1:D10');
2030
+ * const rule = fWorksheet.newConditionalFormattingRule()
2031
+ * .whenTextDoesNotContain('apple')
2032
+ * .setBackground('#FF0000')
2033
+ * .setRanges([fRange.getRange()])
2034
+ * .build();
2035
+ * fWorksheet.addConditionalFormattingRule(rule);
2036
+ * ```
2037
+ */
2038
+ whenTextDoesNotContain(text) {
2039
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenTextDoesNotContain(text);
2040
+ }
2041
+ /**
2042
+ * Sets the conditional format rule to trigger when that the input ends with the given value.
2043
+ * @param {string} text - Text to compare against the end of the string.
2044
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
2045
+ * @example
2046
+ * ```typescript
2047
+ * const fWorkbook = univerAPI.getActiveWorkbook();
2048
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
2049
+ * if (!fWorksheet) return;
2050
+ *
2051
+ * // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
2052
+ * const fRange = fWorksheet.getRange('A1:D10');
2053
+ * const rule = fWorksheet.newConditionalFormattingRule()
2054
+ * .whenTextEndsWith('.ai')
2055
+ * .setBackground('#FF0000')
2056
+ * .setRanges([fRange.getRange()])
2057
+ * .build();
2058
+ * fWorksheet.addConditionalFormattingRule(rule);
2059
+ * ```
2060
+ */
2061
+ whenTextEndsWith(text) {
2062
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenTextEndsWith(text);
2063
+ }
2064
+ /**
2065
+ * Sets the conditional format rule to trigger when that the input is equal to the given value.
2066
+ * @param {string} text - The sole acceptable value.
2067
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
2068
+ * @example
2069
+ * ```typescript
2070
+ * const fWorkbook = univerAPI.getActiveWorkbook();
2071
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
2072
+ * if (!fWorksheet) return;
2073
+ *
2074
+ * // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
2075
+ * const fRange = fWorksheet.getRange('A1:D10');
2076
+ * const rule = fWorksheet.newConditionalFormattingRule()
2077
+ * .whenTextEqualTo('apple')
2078
+ * .setBackground('#FF0000')
2079
+ * .setRanges([fRange.getRange()])
2080
+ * .build();
2081
+ * fWorksheet.addConditionalFormattingRule(rule);
2082
+ * ```
2083
+ */
2084
+ whenTextEqualTo(text) {
2085
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenTextEqualTo(text);
2086
+ }
2087
+ /**
2088
+ * Sets the conditional format rule to trigger when that the input starts with the given value.
2089
+ * @param {string} text - Text to compare against the beginning of the string.
2090
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
2091
+ * @example
2092
+ * ```typescript
2093
+ * const fWorkbook = univerAPI.getActiveWorkbook();
2094
+ * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
2095
+ * if (!fWorksheet) return;
2096
+ *
2097
+ * // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
2098
+ * const fRange = fWorksheet.getRange('A1:D10');
2099
+ * const rule = fWorksheet.newConditionalFormattingRule()
2100
+ * .whenTextStartsWith('https://')
2101
+ * .setBackground('#FF0000')
2102
+ * .setRanges([fRange.getRange()])
2103
+ * .build();
2104
+ * fWorksheet.addConditionalFormattingRule(rule);
2105
+ * ```
2106
+ */
2107
+ whenTextStartsWith(text) {
2108
+ return new ConditionalFormatHighlightRuleBuilder(this._initConfig).whenTextStartsWith(text);
2109
+ }
2110
+ };
2111
+
2112
+ //#endregion
2113
+ //#region src/facade/f-range.ts
2114
+ var FRangeSheetsConditionalFormattingMixin = class extends _cool_office_sheets_facade.FRange {
2115
+ _getConditionalFormattingRuleModel() {
2116
+ return this._injector.get(_cool_office_sheets_conditional_formatting.ConditionalFormattingRuleModel);
2117
+ }
2118
+ getConditionalFormattingRules() {
2119
+ return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((rule) => rule.ranges.some((range) => _cool_office_core.Rectangle.intersects(range, this._range)));
2120
+ }
2121
+ createConditionalFormattingRule() {
2122
+ return new FConditionalFormattingBuilder({ ranges: [this._range] });
2123
+ }
2124
+ clearConditionalFormatRules() {
2125
+ const params = {
2126
+ unitId: this._workbook.getUnitId(),
2127
+ subUnitId: this._worksheet.getSheetId(),
2128
+ ranges: [this._range]
2129
+ };
2130
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.ClearRangeCfCommand.id, params);
2131
+ return this;
2132
+ }
2133
+ };
2134
+ _cool_office_sheets_facade.FRange.extend(FRangeSheetsConditionalFormattingMixin);
2135
+
2136
+ //#endregion
2137
+ //#region src/facade/f-worksheet.ts
2138
+ var FWorksheetConditionalFormattingMixin = class extends _cool_office_sheets_facade.FWorksheet {
2139
+ _getConditionalFormattingRuleModel() {
2140
+ return this._injector.get(_cool_office_sheets_conditional_formatting.ConditionalFormattingRuleModel);
2141
+ }
2142
+ getConditionalFormattingRules() {
2143
+ return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
2144
+ }
2145
+ newConditionalFormattingRule() {
2146
+ return new FConditionalFormattingBuilder();
2147
+ }
2148
+ addConditionalFormattingRule(rule) {
2149
+ const params = {
2150
+ unitId: this._workbook.getUnitId(),
2151
+ subUnitId: this._worksheet.getSheetId(),
2152
+ rule
2153
+ };
2154
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.AddCfCommand.id, params);
2155
+ return this;
2156
+ }
2157
+ deleteConditionalFormattingRule(cfId) {
2158
+ const params = {
2159
+ unitId: this._workbook.getUnitId(),
2160
+ subUnitId: this._worksheet.getSheetId(),
2161
+ cfId
2162
+ };
2163
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.DeleteCfCommand.id, params);
2164
+ return this;
2165
+ }
2166
+ moveConditionalFormattingRule(cfId, toCfId, type = "after") {
2167
+ const params = {
2168
+ unitId: this._workbook.getUnitId(),
2169
+ subUnitId: this._worksheet.getSheetId(),
2170
+ start: {
2171
+ id: cfId,
2172
+ type: "self"
2173
+ },
2174
+ end: {
2175
+ id: toCfId,
2176
+ type
2177
+ }
2178
+ };
2179
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.MoveCfCommand.id, params);
2180
+ return this;
2181
+ }
2182
+ setConditionalFormattingRule(cfId, rule) {
2183
+ const params = {
2184
+ unitId: this._workbook.getUnitId(),
2185
+ subUnitId: this._worksheet.getSheetId(),
2186
+ cfId,
2187
+ rule
2188
+ };
2189
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.SetCfCommand.id, params);
2190
+ return this;
2191
+ }
2192
+ clearConditionalFormatRules() {
2193
+ const params = {
2194
+ unitId: this._workbook.getUnitId(),
2195
+ subUnitId: this._worksheet.getSheetId()
2196
+ };
2197
+ this._commandService.syncExecuteCommand(_cool_office_sheets_conditional_formatting.ClearWorksheetCfCommand.id, params);
2198
+ return this;
2199
+ }
2200
+ };
2201
+ _cool_office_sheets_facade.FWorksheet.extend(FWorksheetConditionalFormattingMixin);
2202
+
2203
+ //#endregion
2204
+ //#region src/facade/f-enum.ts
2205
+ /**
2206
+ * Copyright 2023-present DreamNum Co., Ltd.
2207
+ *
2208
+ * Licensed under the Apache License, Version 2.0 (the "License");
2209
+ * you may not use this file except in compliance with the License.
2210
+ * You may obtain a copy of the License at
2211
+ *
2212
+ * http://www.apache.org/licenses/LICENSE-2.0
2213
+ *
2214
+ * Unless required by applicable law or agreed to in writing, software
2215
+ * distributed under the License is distributed on an "AS IS" BASIS,
2216
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2217
+ * See the License for the specific language governing permissions and
2218
+ * limitations under the License.
2219
+ */
2220
+ var FSheetsConditionalFormattingEnumMixin = class extends _cool_office_core_facade.FEnum {
2221
+ get ConditionFormatNumberOperatorEnum() {
2222
+ return _cool_office_sheets_conditional_formatting.CFNumberOperator;
2223
+ }
2224
+ get ConditionFormatTimePeriodOperatorEnum() {
2225
+ return _cool_office_sheets_conditional_formatting.CFTimePeriodOperator;
2226
+ }
2227
+ get ConditionFormatIconSetTypeEnum() {
2228
+ return _cool_office_sheets_conditional_formatting.IIconSetType;
2229
+ }
2230
+ get ConditionFormatValueTypeEnum() {
2231
+ return _cool_office_sheets_conditional_formatting.CFValueType;
2232
+ }
2233
+ };
2234
+ _cool_office_core_facade.FEnum.extend(FSheetsConditionalFormattingEnumMixin);
2235
+
2236
+ //#endregion
2237
+ exports.FConditionalFormattingBuilder = FConditionalFormattingBuilder;