@univerjs/sheets-conditional-formatting 0.6.7 → 0.6.9

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 (3) hide show
  1. package/lib/facade.js +1915 -0
  2. package/lib/index.js +1967 -0
  3. package/package.json +7 -7
package/lib/facade.js ADDED
@@ -0,0 +1,1915 @@
1
+ var U = Object.defineProperty;
2
+ var q = (u, e, t) => e in u ? U(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
+ var T = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ColorKit as m, Tools as f, BooleanNumber as a, Rectangle as B, ColorBuilder as A } from "@univerjs/core";
5
+ import { iconMap as I, CFRuleType as n, EMPTY_ICON_TYPE as _, CFValueType as C, CFNumberOperator as s, CFTextOperator as g, CFSubRuleType as o, createCfId as d, ConditionalFormattingRuleModel as x, AddCfCommand as S, DeleteCfCommand as E, MoveCfCommand as k, SetCfCommand as F, ClearRangeCfCommand as M, ClearWorksheetCfCommand as O, CFTimePeriodOperator as D } from "@univerjs/sheets-conditional-formatting";
6
+ import { FRange as v, FWorkbook as R, FWorksheet as N } from "@univerjs/sheets/facade";
7
+ import { FEnum as V } from "@univerjs/core/facade";
8
+ class c {
9
+ constructor(e = {}) {
10
+ T(this, "_rule", {});
11
+ this._rule = e, this._ensureAttr(this._rule, ["rule"]);
12
+ }
13
+ get _ruleConfig() {
14
+ return this._rule.rule || null;
15
+ }
16
+ _getDefaultConfig(e = n.highlightCell) {
17
+ switch (e) {
18
+ case n.colorScale:
19
+ return {
20
+ type: e,
21
+ config: [
22
+ { index: 0, color: new m("").toRgbString(), value: { type: C.min } },
23
+ { index: 0, color: new m("green").toRgbString(), value: { type: C.max } }
24
+ ]
25
+ };
26
+ case n.dataBar:
27
+ return {
28
+ type: e,
29
+ isShowValue: !0,
30
+ config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new m("green").toRgbString(), nativeColor: new m("").toRgbString(), isGradient: !1 }
31
+ };
32
+ case n.highlightCell:
33
+ return {
34
+ type: e,
35
+ subType: o.text,
36
+ operator: g.containsText,
37
+ value: "abc",
38
+ style: {}
39
+ };
40
+ case n.iconSet:
41
+ return {
42
+ type: e,
43
+ isShowValue: !0,
44
+ config: [{
45
+ operator: s.greaterThanOrEqual,
46
+ value: { type: C.min },
47
+ iconType: _,
48
+ iconId: ""
49
+ }, {
50
+ operator: s.greaterThanOrEqual,
51
+ value: { type: C.percentile, value: 0.5 },
52
+ iconType: _,
53
+ iconId: ""
54
+ }, {
55
+ operator: s.lessThanOrEqual,
56
+ value: { type: C.max },
57
+ iconType: _,
58
+ iconId: ""
59
+ }]
60
+ };
61
+ }
62
+ }
63
+ // eslint-disable-next-line ts/no-explicit-any
64
+ _ensureAttr(e, t) {
65
+ return t.reduce((r, l) => (r[l] || (r[l] = {}), r[l]), e), e;
66
+ }
67
+ /**
68
+ * Constructs a conditional format rule from the settings applied to the builder.
69
+ * @returns {IConditionFormattingRule} The conditional format rule.
70
+ * @example
71
+ * ```typescript
72
+ * const fWorkbook = univerAPI.getActiveWorkbook();
73
+ * const fWorksheet = fWorkbook.getActiveSheet();
74
+ *
75
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
76
+ * const fRange = fWorksheet.getRange('A1:D10');
77
+ * const rule = fWorksheet.newConditionalFormattingRule()
78
+ * .whenCellEmpty()
79
+ * .setBackground('#FF0000')
80
+ * .setRanges([fRange.getRange()])
81
+ * .build();
82
+ * fWorksheet.addConditionalFormattingRule(rule);
83
+ * ```
84
+ */
85
+ build() {
86
+ var r;
87
+ this._rule.cfId || (this._rule.cfId = d()), this._rule.ranges || (this._rule.ranges = []), this._rule.stopIfTrue === void 0 && (this._rule.stopIfTrue = !1), (r = this._rule.rule) != null && r.type || (this._rule.rule.type = n.highlightCell, this._ensureAttr(this._rule, ["rule", "style"]));
88
+ const e = this._getDefaultConfig(this._rule.rule.type);
89
+ return { ...this._rule, rule: { ...e, ...this._rule.rule } };
90
+ }
91
+ /**
92
+ * Deep clone a current builder.
93
+ * @returns {ConditionalFormatRuleBaseBuilder} A new builder with the same settings as the original.
94
+ * @example
95
+ * ```typescript
96
+ * const fWorkbook = univerAPI.getActiveWorkbook();
97
+ * const fWorksheet = fWorkbook.getActiveSheet();
98
+ *
99
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
100
+ * const fRange = fWorksheet.getRange('A1:D10');
101
+ * const builder = fWorksheet.newConditionalFormattingRule()
102
+ * .whenCellEmpty()
103
+ * .setBackground('#FF0000')
104
+ * .setRanges([fRange.getRange()]);
105
+ * fWorksheet.addConditionalFormattingRule(builder.build());
106
+ *
107
+ * // Copy the rule and change the background color to green for the range A1:B2.
108
+ * const newRange = fWorksheet.getRange('A1:B2');
109
+ * const newBuilder = builder.copy()
110
+ * .setBackground('#00FF00')
111
+ * .setRanges([newRange.getRange()]);
112
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
113
+ * ```
114
+ */
115
+ copy() {
116
+ const e = f.deepClone(this._rule);
117
+ return e.cfId && (e.cfId = d()), new c(e);
118
+ }
119
+ /**
120
+ * Gets the scope of the current conditional format.
121
+ * @returns {IRange[]} The ranges to which the conditional format applies.
122
+ */
123
+ getRanges() {
124
+ return this._rule.ranges || [];
125
+ }
126
+ /**
127
+ * Get the icon set mapping dictionary.
128
+ * @returns {Record<string, string[]>} The icon set mapping dictionary.
129
+ */
130
+ getIconMap() {
131
+ return I;
132
+ }
133
+ /**
134
+ * Create a conditional format ID.
135
+ * @returns {string} The conditional format ID.
136
+ */
137
+ createCfId() {
138
+ return d();
139
+ }
140
+ /**
141
+ * Sets the scope for conditional formatting.
142
+ * @param {IRange[]} ranges - The ranges to which the conditional format applies.
143
+ * @returns {ConditionalFormatRuleBaseBuilder} This builder for chaining.
144
+ * @example
145
+ * ```typescript
146
+ * const fWorkbook = univerAPI.getActiveWorkbook();
147
+ * const fWorksheet = fWorkbook.getActiveSheet();
148
+ *
149
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
150
+ * const fRange = fWorksheet.getRange('A1:D10');
151
+ * const rule = fWorksheet.newConditionalFormattingRule()
152
+ * .whenCellEmpty()
153
+ * .setBackground('#FF0000')
154
+ * .setRanges([fRange.getRange()])
155
+ * .build();
156
+ * fWorksheet.addConditionalFormattingRule(rule);
157
+ * ```
158
+ */
159
+ setRanges(e) {
160
+ return this._rule.ranges = e, this;
161
+ }
162
+ }
163
+ class i extends c {
164
+ constructor(e = {}) {
165
+ super(e), this._ensureAttr(this._rule, ["rule", "style"]);
166
+ }
167
+ /**
168
+ * Deep clone a current builder.
169
+ * @returns {ConditionalFormatHighlightRuleBuilder} A new builder with the same settings as the original.
170
+ * @example
171
+ * ```typescript
172
+ * const fWorkbook = univerAPI.getActiveWorkbook();
173
+ * const fWorksheet = fWorkbook.getActiveSheet();
174
+ *
175
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
176
+ * const fRange = fWorksheet.getRange('A1:D10');
177
+ * const builder = fWorksheet.newConditionalFormattingRule()
178
+ * .whenCellEmpty()
179
+ * .setBackground('#FF0000')
180
+ * .setRanges([fRange.getRange()]);
181
+ * fWorksheet.addConditionalFormattingRule(builder.build());
182
+ *
183
+ * // Copy the rule and change the background color to green for the range A1:B2.
184
+ * const newRange = fWorksheet.getRange('A1:B2');
185
+ * const newBuilder = builder.copy()
186
+ * .setBackground('#00FF00')
187
+ * .setRanges([newRange.getRange()]);
188
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
189
+ * ```
190
+ */
191
+ copy() {
192
+ const e = f.deepClone(this._rule);
193
+ return e.cfId && (e.cfId = d()), new i(e);
194
+ }
195
+ /**
196
+ * Set average rule.
197
+ * @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
198
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
199
+ * @example
200
+ * ```typescript
201
+ * const fWorkbook = univerAPI.getActiveWorkbook();
202
+ * const fWorksheet = fWorkbook.getActiveSheet();
203
+ *
204
+ * // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
205
+ * const fRange = fWorksheet.getRange('A1:D10');
206
+ * const rule = fWorksheet.newConditionalFormattingRule()
207
+ * .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
208
+ * .setBackground('#FF0000')
209
+ * .setRanges([fRange.getRange()])
210
+ * .build();
211
+ * fWorksheet.addConditionalFormattingRule(rule);
212
+ * ```
213
+ */
214
+ setAverage(e) {
215
+ const t = this._ruleConfig;
216
+ return t.type = n.highlightCell, t.subType = o.average, t.operator = e, this;
217
+ }
218
+ /**
219
+ * Set unique values rule.
220
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
221
+ * @example
222
+ * ```typescript
223
+ * const fWorkbook = univerAPI.getActiveWorkbook();
224
+ * const fWorksheet = fWorkbook.getActiveSheet();
225
+ *
226
+ * // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
227
+ * const fRange = fWorksheet.getRange('A1:D10');
228
+ * const rule = fWorksheet.newConditionalFormattingRule()
229
+ * .setUniqueValues()
230
+ * .setBackground('#FF0000')
231
+ * .setRanges([fRange.getRange()])
232
+ * .build();
233
+ * fWorksheet.addConditionalFormattingRule(rule);
234
+ * ```
235
+ */
236
+ setUniqueValues() {
237
+ const e = this._ruleConfig;
238
+ return e.type = n.highlightCell, e.subType = o.uniqueValues, this;
239
+ }
240
+ /**
241
+ * Set duplicate values rule.
242
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
243
+ * @example
244
+ * ```typescript
245
+ * const fWorkbook = univerAPI.getActiveWorkbook();
246
+ * const fWorksheet = fWorkbook.getActiveSheet();
247
+ *
248
+ * // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
249
+ * const fRange = fWorksheet.getRange('A1:D10');
250
+ * const rule = fWorksheet.newConditionalFormattingRule()
251
+ * .setDuplicateValues()
252
+ * .setBackground('#FF0000')
253
+ * .setRanges([fRange.getRange()])
254
+ * .build();
255
+ * fWorksheet.addConditionalFormattingRule(rule);
256
+ * ```
257
+ */
258
+ setDuplicateValues() {
259
+ const e = this._ruleConfig;
260
+ return e.type = n.highlightCell, e.subType = o.duplicateValues, this;
261
+ }
262
+ /**
263
+ * Set rank rule.
264
+ * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
265
+ * @param {boolean} config.isBottom - Whether to highlight the bottom rank.
266
+ * @param {boolean} config.isPercent - Whether to use a percentage rank.
267
+ * @param {number} config.value - The rank value.
268
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
269
+ * @example
270
+ * ```typescript
271
+ * const fWorkbook = univerAPI.getActiveWorkbook();
272
+ * const fWorksheet = fWorkbook.getActiveSheet();
273
+ *
274
+ * // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
275
+ * const fRange = fWorksheet.getRange('A1:D10');
276
+ * const rule = fWorksheet.newConditionalFormattingRule()
277
+ * .setRank({ isBottom: true, isPercent: true, value: 10 })
278
+ * .setBackground('#FF0000')
279
+ * .setRanges([fRange.getRange()])
280
+ * .build();
281
+ * fWorksheet.addConditionalFormattingRule(rule);
282
+ * ```
283
+ */
284
+ setRank(e) {
285
+ const t = this._ruleConfig;
286
+ return t.type = n.highlightCell, t.subType = o.rank, t.isBottom = e.isBottom, t.isPercent = e.isPercent, t.value = e.value, this;
287
+ }
288
+ /**
289
+ * Sets the background color for the conditional format rule's format.
290
+ * @param {string} [color] - The background color to set. If not provided, the background color is removed.
291
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
292
+ * @example
293
+ * ```typescript
294
+ * const fWorkbook = univerAPI.getActiveWorkbook();
295
+ * const fWorksheet = fWorkbook.getActiveSheet();
296
+ *
297
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
298
+ * const fRange = fWorksheet.getRange('A1:D10');
299
+ * const rule = fWorksheet.newConditionalFormattingRule()
300
+ * .whenCellEmpty()
301
+ * .setBackground('#FF0000')
302
+ * .setRanges([fRange.getRange()])
303
+ * .build();
304
+ * fWorksheet.addConditionalFormattingRule(rule);
305
+ * ```
306
+ */
307
+ setBackground(e) {
308
+ var t;
309
+ if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
310
+ if (e) {
311
+ this._ensureAttr(this._ruleConfig, ["style", "bg"]);
312
+ const r = new m(e);
313
+ this._ruleConfig.style.bg.rgb = r.toRgbString();
314
+ } else
315
+ delete this._ruleConfig.style.bg;
316
+ return this;
317
+ }
318
+ /**
319
+ * Sets text bolding for the conditional format rule's format.
320
+ * @param {boolean} isBold - Whether to bold the text.
321
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
322
+ * @example
323
+ * ```typescript
324
+ * const fWorkbook = univerAPI.getActiveWorkbook();
325
+ * const fWorksheet = fWorkbook.getActiveSheet();
326
+ *
327
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
328
+ * const fRange = fWorksheet.getRange('A1:D10');
329
+ * const rule = fWorksheet.newConditionalFormattingRule()
330
+ * .whenCellNotEmpty()
331
+ * .setBold(true)
332
+ * .setRanges([fRange.getRange()])
333
+ * .build();
334
+ * fWorksheet.addConditionalFormattingRule(rule);
335
+ * ```
336
+ */
337
+ setBold(e) {
338
+ var t;
339
+ return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style"]), this._ruleConfig.style.bl = e ? a.TRUE : a.FALSE), this;
340
+ }
341
+ /**
342
+ * Sets the font color for the conditional format rule's format.
343
+ * @param {string} [color] - The font color to set. If not provided, the font color is removed.
344
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
345
+ * @example
346
+ * ```typescript
347
+ * const fWorkbook = univerAPI.getActiveWorkbook();
348
+ * const fWorksheet = fWorkbook.getActiveSheet();
349
+ *
350
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
351
+ * const fRange = fWorksheet.getRange('A1:D10');
352
+ * const rule = fWorksheet.newConditionalFormattingRule()
353
+ * .whenCellNotEmpty()
354
+ * .setFontColor('#FF0000')
355
+ * .setRanges([fRange.getRange()])
356
+ * .build();
357
+ * fWorksheet.addConditionalFormattingRule(rule);
358
+ * ```
359
+ */
360
+ setFontColor(e) {
361
+ var t;
362
+ if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
363
+ if (e) {
364
+ const r = new m(e);
365
+ this._ensureAttr(this._ruleConfig, ["style", "cl"]), this._ruleConfig.style.cl.rgb = r.toRgbString();
366
+ } else
367
+ delete this._ruleConfig.style.cl;
368
+ return this;
369
+ }
370
+ /**
371
+ * Sets text italics for the conditional format rule's format.
372
+ * @param {boolean} isItalic - Whether to italicize the text.
373
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
374
+ * @example
375
+ * ```typescript
376
+ * const fWorkbook = univerAPI.getActiveWorkbook();
377
+ * const fWorksheet = fWorkbook.getActiveSheet();
378
+ *
379
+ * // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
380
+ * const fRange = fWorksheet.getRange('A1:D10');
381
+ * const rule = fWorksheet.newConditionalFormattingRule()
382
+ * .whenCellNotEmpty()
383
+ * .setItalic(true)
384
+ * .setRanges([fRange.getRange()])
385
+ * .build();
386
+ * fWorksheet.addConditionalFormattingRule(rule);
387
+ * ```
388
+ */
389
+ setItalic(e) {
390
+ var t;
391
+ return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style"]), this._ruleConfig.style.it = e ? a.TRUE : a.FALSE), this;
392
+ }
393
+ /**
394
+ * Sets text strikethrough for the conditional format rule's format.
395
+ * @param {boolean} isStrikethrough - Whether is strikethrough the text.
396
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
397
+ * @example
398
+ * ```typescript
399
+ * const fWorkbook = univerAPI.getActiveWorkbook();
400
+ * const fWorksheet = fWorkbook.getActiveSheet();
401
+ *
402
+ * // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
403
+ * const fRange = fWorksheet.getRange('A1:D10');
404
+ * const rule = fWorksheet.newConditionalFormattingRule()
405
+ * .whenCellNotEmpty()
406
+ * .setStrikethrough(true)
407
+ * .setRanges([fRange.getRange()])
408
+ * .build();
409
+ * fWorksheet.addConditionalFormattingRule(rule);
410
+ * ```
411
+ */
412
+ setStrikethrough(e) {
413
+ var t;
414
+ return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style", "st"]), this._ruleConfig.style.st.s = e ? a.TRUE : a.FALSE), this;
415
+ }
416
+ /**
417
+ * Sets text underlining for the conditional format rule's format.
418
+ * @param {boolean} isUnderline - Whether to underline the text.
419
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
420
+ * @example
421
+ * ```typescript
422
+ * const fWorkbook = univerAPI.getActiveWorkbook();
423
+ * const fWorksheet = fWorkbook.getActiveSheet();
424
+ *
425
+ * // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
426
+ * const fRange = fWorksheet.getRange('A1:D10');
427
+ * const rule = fWorksheet.newConditionalFormattingRule()
428
+ * .whenCellNotEmpty()
429
+ * .setUnderline(true)
430
+ * .setRanges([fRange.getRange()])
431
+ * .build();
432
+ * fWorksheet.addConditionalFormattingRule(rule);
433
+ * ```
434
+ */
435
+ setUnderline(e) {
436
+ var t;
437
+ return ((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell && (this._ensureAttr(this._ruleConfig, ["style", "ul"]), this._ruleConfig.style.ul.s = e ? a.TRUE : a.FALSE), this;
438
+ }
439
+ /**
440
+ * Sets the conditional format rule to trigger when the cell is empty.
441
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
442
+ * @example
443
+ * ```typescript
444
+ * const fWorkbook = univerAPI.getActiveWorkbook();
445
+ * const fWorksheet = fWorkbook.getActiveSheet();
446
+ *
447
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
448
+ * const fRange = fWorksheet.getRange('A1:D10');
449
+ * const rule = fWorksheet.newConditionalFormattingRule()
450
+ * .whenCellEmpty()
451
+ * .setBackground('#FF0000')
452
+ * .setRanges([fRange.getRange()])
453
+ * .build();
454
+ * fWorksheet.addConditionalFormattingRule(rule);
455
+ * ```
456
+ */
457
+ whenCellEmpty() {
458
+ const e = this._ruleConfig;
459
+ return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.equal, this;
460
+ }
461
+ /**
462
+ * Sets the conditional format rule to trigger when the cell is not empty.
463
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
464
+ * @example
465
+ * ```typescript
466
+ * const fWorkbook = univerAPI.getActiveWorkbook();
467
+ * const fWorksheet = fWorkbook.getActiveSheet();
468
+ *
469
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
470
+ * const fRange = fWorksheet.getRange('A1:D10');
471
+ * const rule = fWorksheet.newConditionalFormattingRule()
472
+ * .whenCellNotEmpty()
473
+ * .setFontColor('#FF0000')
474
+ * .setRanges([fRange.getRange()])
475
+ * .build();
476
+ * fWorksheet.addConditionalFormattingRule(rule);
477
+ * ```
478
+ */
479
+ whenCellNotEmpty() {
480
+ const e = this._ruleConfig;
481
+ return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.notEqual, this;
482
+ }
483
+ /**
484
+ * Sets the conditional format rule to trigger when a time period is met.
485
+ * @param {CFTimePeriodOperator} date - The time period to check for.
486
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
487
+ * @example
488
+ * ```typescript
489
+ * const fWorkbook = univerAPI.getActiveWorkbook();
490
+ * const fWorksheet = fWorkbook.getActiveSheet();
491
+ *
492
+ * // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
493
+ * const fRange = fWorksheet.getRange('A1:D10');
494
+ * const rule = fWorksheet.newConditionalFormattingRule()
495
+ * .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
496
+ * .setBackground('#FF0000')
497
+ * .setRanges([fRange.getRange()])
498
+ * .build();
499
+ * fWorksheet.addConditionalFormattingRule(rule);
500
+ * ```
501
+ */
502
+ whenDate(e) {
503
+ const t = this._ruleConfig;
504
+ return t.type = n.highlightCell, t.subType = o.timePeriod, t.operator = e, this;
505
+ }
506
+ /**
507
+ * Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
508
+ * @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
509
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
510
+ * @example
511
+ * ```typescript
512
+ * const fWorkbook = univerAPI.getActiveWorkbook();
513
+ * const fWorksheet = fWorkbook.getActiveSheet();
514
+ *
515
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
516
+ * const fRange = fWorksheet.getRange('A1:D10');
517
+ * const rule = fWorksheet.newConditionalFormattingRule()
518
+ * .whenFormulaSatisfied('=A1>10')
519
+ * .setBackground('#FF0000')
520
+ * .setRanges([fRange.getRange()])
521
+ * .build();
522
+ * fWorksheet.addConditionalFormattingRule(rule);
523
+ * ```
524
+ */
525
+ whenFormulaSatisfied(e) {
526
+ const t = this._ruleConfig;
527
+ return t.type = n.highlightCell, t.subType = o.formula, t.value = e, this;
528
+ }
529
+ /**
530
+ * Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
531
+ * @param {number} start - The lowest acceptable value.
532
+ * @param {number} end - The highest acceptable value.
533
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
534
+ * @example
535
+ * ```typescript
536
+ * const fWorkbook = univerAPI.getActiveWorkbook();
537
+ * const fWorksheet = fWorkbook.getActiveSheet();
538
+ *
539
+ * // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
540
+ * const fRange = fWorksheet.getRange('A1:D10');
541
+ * const rule = fWorksheet.newConditionalFormattingRule()
542
+ * .whenNumberBetween(10, 20)
543
+ * .setBackground('#FF0000')
544
+ * .setRanges([fRange.getRange()])
545
+ * .build();
546
+ * fWorksheet.addConditionalFormattingRule(rule);
547
+ * ```
548
+ */
549
+ whenNumberBetween(e, t) {
550
+ const r = Math.min(e, t), l = Math.max(e, t), h = this._ruleConfig;
551
+ return h.type = n.highlightCell, h.subType = o.number, h.value = [r, l], h.operator = s.between, this;
552
+ }
553
+ /**
554
+ * Sets the conditional format rule to trigger when a number is equal to the given value.
555
+ * @param {number} value - The sole acceptable value.
556
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
557
+ * @example
558
+ * ```typescript
559
+ * const fWorkbook = univerAPI.getActiveWorkbook();
560
+ * const fWorksheet = fWorkbook.getActiveSheet();
561
+ *
562
+ * // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
563
+ * const fRange = fWorksheet.getRange('A1:D10');
564
+ * const rule = fWorksheet.newConditionalFormattingRule()
565
+ * .whenNumberEqualTo(10)
566
+ * .setBackground('#FF0000')
567
+ * .setRanges([fRange.getRange()])
568
+ * .build();
569
+ * fWorksheet.addConditionalFormattingRule(rule);
570
+ * ```
571
+ */
572
+ whenNumberEqualTo(e) {
573
+ const t = this._ruleConfig;
574
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.equal, this;
575
+ }
576
+ /**
577
+ * Sets the conditional format rule to trigger when a number is greater than the given value.
578
+ * @param {number} value - The highest unacceptable value.
579
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
580
+ * @example
581
+ * ```typescript
582
+ * const fWorkbook = univerAPI.getActiveWorkbook();
583
+ * const fWorksheet = fWorkbook.getActiveSheet();
584
+ *
585
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
586
+ * const fRange = fWorksheet.getRange('A1:D10');
587
+ * const rule = fWorksheet.newConditionalFormattingRule()
588
+ * .whenNumberGreaterThan(10)
589
+ * .setBackground('#FF0000')
590
+ * .setRanges([fRange.getRange()])
591
+ * .build();
592
+ * fWorksheet.addConditionalFormattingRule(rule);
593
+ * ```
594
+ */
595
+ whenNumberGreaterThan(e) {
596
+ const t = this._ruleConfig;
597
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.greaterThan, this;
598
+ }
599
+ /**
600
+ * Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
601
+ * @param {number} value - The lowest acceptable value.
602
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
603
+ * @example
604
+ * ```typescript
605
+ * const fWorkbook = univerAPI.getActiveWorkbook();
606
+ * const fWorksheet = fWorkbook.getActiveSheet();
607
+ *
608
+ * // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
609
+ * const fRange = fWorksheet.getRange('A1:D10');
610
+ * const rule = fWorksheet.newConditionalFormattingRule()
611
+ * .whenNumberGreaterThanOrEqualTo(10)
612
+ * .setBackground('#FF0000')
613
+ * .setRanges([fRange.getRange()])
614
+ * .build();
615
+ * fWorksheet.addConditionalFormattingRule(rule);
616
+ * ```
617
+ */
618
+ whenNumberGreaterThanOrEqualTo(e) {
619
+ const t = this._ruleConfig;
620
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.greaterThanOrEqual, this;
621
+ }
622
+ /**
623
+ * Sets the conditional conditional format rule to trigger when a number less than the given value.
624
+ * @param {number} value - The lowest unacceptable value.
625
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
626
+ * @example
627
+ * ```typescript
628
+ * const fWorkbook = univerAPI.getActiveWorkbook();
629
+ * const fWorksheet = fWorkbook.getActiveSheet();
630
+ *
631
+ * // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
632
+ * const fRange = fWorksheet.getRange('A1:D10');
633
+ * const rule = fWorksheet.newConditionalFormattingRule()
634
+ * .whenNumberLessThan(10)
635
+ * .setBackground('#FF0000')
636
+ * .setRanges([fRange.getRange()])
637
+ * .build();
638
+ * fWorksheet.addConditionalFormattingRule(rule);
639
+ * ```
640
+ */
641
+ whenNumberLessThan(e) {
642
+ const t = this._ruleConfig;
643
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.lessThan, this;
644
+ }
645
+ /**
646
+ * Sets the conditional format rule to trigger when a number less than or equal to the given value.
647
+ * @param {number} value - The highest acceptable value.
648
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
649
+ * @example
650
+ * ```typescript
651
+ * const fWorkbook = univerAPI.getActiveWorkbook();
652
+ * const fWorksheet = fWorkbook.getActiveSheet();
653
+ *
654
+ * // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
655
+ * const fRange = fWorksheet.getRange('A1:D10');
656
+ * const rule = fWorksheet.newConditionalFormattingRule()
657
+ * .whenNumberLessThanOrEqualTo(10)
658
+ * .setBackground('#FF0000')
659
+ * .setRanges([fRange.getRange()])
660
+ * .build();
661
+ * fWorksheet.addConditionalFormattingRule(rule);
662
+ * ```
663
+ */
664
+ whenNumberLessThanOrEqualTo(e) {
665
+ const t = this._ruleConfig;
666
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.lessThanOrEqual, this;
667
+ }
668
+ /**
669
+ * Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
670
+ * @param {number} start - The lowest unacceptable value.
671
+ * @param {number} end - The highest unacceptable value.
672
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
673
+ * @example
674
+ * ```typescript
675
+ * const fWorkbook = univerAPI.getActiveWorkbook();
676
+ * const fWorksheet = fWorkbook.getActiveSheet();
677
+ *
678
+ * // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
679
+ * const fRange = fWorksheet.getRange('A1:D10');
680
+ * const rule = fWorksheet.newConditionalFormattingRule()
681
+ * .whenNumberNotBetween(10, 20)
682
+ * .setBackground('#FF0000')
683
+ * .setRanges([fRange.getRange()])
684
+ * .build();
685
+ * fWorksheet.addConditionalFormattingRule(rule);
686
+ * ```
687
+ */
688
+ whenNumberNotBetween(e, t) {
689
+ const r = Math.min(e, t), l = Math.max(e, t), h = this._ruleConfig;
690
+ return h.type = n.highlightCell, h.subType = o.number, h.value = [r, l], h.operator = s.notBetween, this;
691
+ }
692
+ /**
693
+ * Sets the conditional format rule to trigger when a number is not equal to the given value.
694
+ * @param {number} value - The sole unacceptable value.
695
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
696
+ * @example
697
+ * ```typescript
698
+ * const fWorkbook = univerAPI.getActiveWorkbook();
699
+ * const fWorksheet = fWorkbook.getActiveSheet();
700
+ *
701
+ * // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
702
+ * const fRange = fWorksheet.getRange('A1:D10');
703
+ * const rule = fWorksheet.newConditionalFormattingRule()
704
+ * .whenNumberNotEqualTo(10)
705
+ * .setBackground('#FF0000')
706
+ * .setRanges([fRange.getRange()])
707
+ * .build();
708
+ * fWorksheet.addConditionalFormattingRule(rule);
709
+ * ```
710
+ */
711
+ whenNumberNotEqualTo(e) {
712
+ const t = this._ruleConfig;
713
+ return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = s.notEqual, this;
714
+ }
715
+ /**
716
+ * Sets the conditional format rule to trigger when that the input contains the given value.
717
+ * @param {string} text - The value that the input must contain.
718
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
719
+ * @example
720
+ * ```typescript
721
+ * const fWorkbook = univerAPI.getActiveWorkbook();
722
+ * const fWorksheet = fWorkbook.getActiveSheet();
723
+ *
724
+ * // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
725
+ * const fRange = fWorksheet.getRange('A1:D10');
726
+ * const rule = fWorksheet.newConditionalFormattingRule()
727
+ * .whenTextContains('apple')
728
+ * .setBackground('#FF0000')
729
+ * .setRanges([fRange.getRange()])
730
+ * .build();
731
+ * fWorksheet.addConditionalFormattingRule(rule);
732
+ * ```
733
+ */
734
+ whenTextContains(e) {
735
+ const t = this._ruleConfig;
736
+ return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.containsText, this;
737
+ }
738
+ /**
739
+ * Sets the conditional format rule to trigger when that the input does not contain the given value.
740
+ * @param {string} text - The value that the input must not contain.
741
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
742
+ * @example
743
+ * ```typescript
744
+ * const fWorkbook = univerAPI.getActiveWorkbook();
745
+ * const fWorksheet = fWorkbook.getActiveSheet();
746
+ *
747
+ * // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
748
+ * const fRange = fWorksheet.getRange('A1:D10');
749
+ * const rule = fWorksheet.newConditionalFormattingRule()
750
+ * .whenTextDoesNotContain('apple')
751
+ * .setBackground('#FF0000')
752
+ * .setRanges([fRange.getRange()])
753
+ * .build();
754
+ * fWorksheet.addConditionalFormattingRule(rule);
755
+ * ```
756
+ */
757
+ whenTextDoesNotContain(e) {
758
+ const t = this._ruleConfig;
759
+ return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.notContainsText, this;
760
+ }
761
+ /**
762
+ * Sets the conditional format rule to trigger when that the input ends with the given value.
763
+ * @param {string} text - Text to compare against the end of the string.
764
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
765
+ * @example
766
+ * ```typescript
767
+ * const fWorkbook = univerAPI.getActiveWorkbook();
768
+ * const fWorksheet = fWorkbook.getActiveSheet();
769
+ *
770
+ * // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
771
+ * const fRange = fWorksheet.getRange('A1:D10');
772
+ * const rule = fWorksheet.newConditionalFormattingRule()
773
+ * .whenTextEndsWith('.ai')
774
+ * .setBackground('#FF0000')
775
+ * .setRanges([fRange.getRange()])
776
+ * .build();
777
+ * fWorksheet.addConditionalFormattingRule(rule);
778
+ * ```
779
+ */
780
+ whenTextEndsWith(e) {
781
+ const t = this._ruleConfig;
782
+ return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.endsWith, this;
783
+ }
784
+ /**
785
+ * Sets the conditional format rule to trigger when that the input is equal to the given value.
786
+ * @param {string} text - The sole acceptable value.
787
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
788
+ * @example
789
+ * ```typescript
790
+ * const fWorkbook = univerAPI.getActiveWorkbook();
791
+ * const fWorksheet = fWorkbook.getActiveSheet();
792
+ *
793
+ * // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
794
+ * const fRange = fWorksheet.getRange('A1:D10');
795
+ * const rule = fWorksheet.newConditionalFormattingRule()
796
+ * .whenTextEqualTo('apple')
797
+ * .setBackground('#FF0000')
798
+ * .setRanges([fRange.getRange()])
799
+ * .build();
800
+ * fWorksheet.addConditionalFormattingRule(rule);
801
+ * ```
802
+ */
803
+ whenTextEqualTo(e) {
804
+ const t = this._ruleConfig;
805
+ return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.equal, this;
806
+ }
807
+ /**
808
+ * Sets the conditional format rule to trigger when that the input starts with the given value.
809
+ * @param {string} text - Text to compare against the beginning of the string.
810
+ * @returns {ConditionalFormatHighlightRuleBuilder} This builder for chaining.
811
+ * @example
812
+ * ```typescript
813
+ * const fWorkbook = univerAPI.getActiveWorkbook();
814
+ * const fWorksheet = fWorkbook.getActiveSheet();
815
+ *
816
+ * // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
817
+ * const fRange = fWorksheet.getRange('A1:D10');
818
+ * const rule = fWorksheet.newConditionalFormattingRule()
819
+ * .whenTextStartsWith('https://')
820
+ * .setBackground('#FF0000')
821
+ * .setRanges([fRange.getRange()])
822
+ * .build();
823
+ * fWorksheet.addConditionalFormattingRule(rule);
824
+ * ```
825
+ */
826
+ whenTextStartsWith(e) {
827
+ const t = this._ruleConfig;
828
+ return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.beginsWith, this;
829
+ }
830
+ }
831
+ class p extends c {
832
+ /**
833
+ * Deep clone a current builder.
834
+ * @returns {ConditionalFormatDataBarRuleBuilder} A new instance of the builder with the same settings as the original.
835
+ * @example
836
+ * ```typescript
837
+ * const fWorkbook = univerAPI.getActiveWorkbook();
838
+ * const fWorksheet = fWorkbook.getActiveSheet();
839
+ *
840
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
841
+ * // positive values are green and negative values are red.
842
+ * const fRange = fWorksheet.getRange('A1:D10');
843
+ * const builder = fWorksheet.newConditionalFormattingRule()
844
+ * .setDataBar({
845
+ * min: { type: 'num', value: -100 },
846
+ * max: { type: 'num', value: 100 },
847
+ * positiveColor: '#00FF00',
848
+ * nativeColor: '#FF0000',
849
+ * isShowValue: true
850
+ * })
851
+ * .setRanges([fRange.getRange()]);
852
+ * fWorksheet.addConditionalFormattingRule(builder.build());
853
+ *
854
+ * // Copy the rule and apply it to a new range.
855
+ * const newRange = fWorksheet.getRange('F1:F10');
856
+ * const newBuilder = builder.copy()
857
+ * .setRanges([newRange.getRange()]);
858
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
859
+ * ```
860
+ */
861
+ copy() {
862
+ const e = f.deepClone(this._rule);
863
+ return e.cfId && (e.cfId = d()), new p(e);
864
+ }
865
+ /**
866
+ * Set data bar rule.
867
+ * @param {{
868
+ * min: IValueConfig;
869
+ * max: IValueConfig;
870
+ * isGradient?: boolean;
871
+ * positiveColor: string;
872
+ * nativeColor: string;
873
+ * isShowValue?: boolean;
874
+ * }} config - The data bar rule settings.
875
+ * @param {IValueConfig} config.min - The minimum value for the data bar.
876
+ * @param {IValueConfig} config.max - The maximum value for the data bar.
877
+ * @param {boolean} [config.isGradient] - Whether the data bar is gradient.
878
+ * @param {string} config.positiveColor - The color for positive values.
879
+ * @param {string} config.nativeColor - The color for negative values.
880
+ * @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
881
+ * @returns {ConditionalFormatDataBarRuleBuilder} This builder for chaining.
882
+ * @example
883
+ * ```typescript
884
+ * const fWorkbook = univerAPI.getActiveWorkbook();
885
+ * const fWorksheet = fWorkbook.getActiveSheet();
886
+ *
887
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
888
+ * // positive values are green and negative values are red.
889
+ * const fRange = fWorksheet.getRange('A1:D10');
890
+ * const rule = fWorksheet.newConditionalFormattingRule()
891
+ * .setDataBar({
892
+ * min: { type: 'num', value: -100 },
893
+ * max: { type: 'num', value: 100 },
894
+ * positiveColor: '#00FF00',
895
+ * nativeColor: '#FF0000',
896
+ * isShowValue: true
897
+ * })
898
+ * .setRanges([fRange.getRange()])
899
+ * .build();
900
+ * fWorksheet.addConditionalFormattingRule(rule);
901
+ * ```
902
+ */
903
+ setDataBar(e) {
904
+ const t = this._ruleConfig;
905
+ return t.type = n.dataBar, t.isShowValue = !!e.isShowValue, t.config = {
906
+ min: e.min,
907
+ max: e.max,
908
+ positiveColor: e.positiveColor,
909
+ nativeColor: e.nativeColor,
910
+ isGradient: !!e.isGradient
911
+ }, this;
912
+ }
913
+ }
914
+ class y extends c {
915
+ /**
916
+ * Deep clone a current builder.
917
+ * @returns {ConditionalFormatColorScaleRuleBuilder} A new instance of the builder with the same settings as the original.
918
+ * @example
919
+ * ```typescript
920
+ * const fWorkbook = univerAPI.getActiveWorkbook();
921
+ * const fWorksheet = fWorkbook.getActiveSheet();
922
+ *
923
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
924
+ * // The color scale is green for 0, yellow for 50, and red for 100.
925
+ * const fRange = fWorksheet.getRange('A1:D10');
926
+ * const builder = fWorksheet.newConditionalFormattingRule()
927
+ * .setColorScale([
928
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
929
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
930
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
931
+ * ])
932
+ * .setRanges([fRange.getRange()]);
933
+ * fWorksheet.addConditionalFormattingRule(builder.build());
934
+ *
935
+ * // Copy the rule and apply it to a new range.
936
+ * const newRange = fWorksheet.getRange('F1:F10');
937
+ * const newBuilder = builder.copy()
938
+ * .setRanges([newRange.getRange()]);
939
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
940
+ * ```
941
+ */
942
+ copy() {
943
+ const e = f.deepClone(this._rule);
944
+ return e.cfId && (e.cfId = d()), new y(e);
945
+ }
946
+ /**
947
+ * Set color scale rule.
948
+ * @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
949
+ * @param {number} config.index - The index of the color scale configuration.
950
+ * @param {string} config.color - The color corresponding to the index of the color scale configuration.
951
+ * @param {IValueConfig} config.value - The condition value corresponding to the index of the color scale configuration.
952
+ * @returns {ConditionalFormatColorScaleRuleBuilder} This builder for chaining.
953
+ * @example
954
+ * ```typescript
955
+ * const fWorkbook = univerAPI.getActiveWorkbook();
956
+ * const fWorksheet = fWorkbook.getActiveSheet();
957
+ *
958
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
959
+ * // The color scale is green for 0, yellow for 50, and red for 100.
960
+ * const fRange = fWorksheet.getRange('A1:D10');
961
+ * const rule = fWorksheet.newConditionalFormattingRule()
962
+ * .setColorScale([
963
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
964
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
965
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
966
+ * ])
967
+ * .setRanges([fRange.getRange()])
968
+ * .build();
969
+ * fWorksheet.addConditionalFormattingRule(rule);
970
+ * ```
971
+ */
972
+ setColorScale(e) {
973
+ const t = this._ruleConfig;
974
+ return t.type = n.colorScale, t.config = e, this;
975
+ }
976
+ }
977
+ class b extends c {
978
+ /**
979
+ * Deep clone a current builder.
980
+ * @returns {ConditionalFormatIconSetRuleBuilder} A new instance of the builder with the same settings as the original.
981
+ * @example
982
+ * ```typescript
983
+ * const fWorkbook = univerAPI.getActiveWorkbook();
984
+ * const fWorksheet = fWorkbook.getActiveSheet();
985
+ *
986
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
987
+ * // The first arrow is green for values greater than 20.
988
+ * // The second arrow is yellow for values greater than 10.
989
+ * // The third arrow is red for values less than or equal to 10.
990
+ * const fRange = fWorksheet.getRange('A1:D10');
991
+ * const builder = fWorksheet.newConditionalFormattingRule()
992
+ * .setIconSet({
993
+ * iconConfigs: [
994
+ * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
995
+ * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
996
+ * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
997
+ * ],
998
+ * isShowValue: true,
999
+ * })
1000
+ * .setRanges([fRange.getRange()]);
1001
+ * fWorksheet.addConditionalFormattingRule(builder.build());
1002
+ *
1003
+ * // Copy the rule and apply it to a new range.
1004
+ * const newRange = fWorksheet.getRange('F1:F10');
1005
+ * const newBuilder = builder.copy()
1006
+ * .setRanges([newRange.getRange()]);
1007
+ * fWorksheet.addConditionalFormattingRule(newBuilder.build());
1008
+ * ```
1009
+ */
1010
+ copy() {
1011
+ const e = f.deepClone(this._rule);
1012
+ return e.cfId && (e.cfId = d()), new b(e);
1013
+ }
1014
+ /**
1015
+ * Set up icon set conditional formatting rule.
1016
+ * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
1017
+ * @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
1018
+ * @param {boolean} config.isShowValue - Whether to show the value in the cell.
1019
+ * @returns {ConditionalFormatIconSetRuleBuilder} This builder for chaining.
1020
+ * @example
1021
+ * ```typescript
1022
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1023
+ * const fWorksheet = fWorkbook.getActiveSheet();
1024
+ *
1025
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
1026
+ * // The first arrow is green for values greater than 20.
1027
+ * // The second arrow is yellow for values greater than 10.
1028
+ * // The third arrow is red for values less than or equal to 10.
1029
+ * const fRange = fWorksheet.getRange('A1:D10');
1030
+ * const builder = fWorksheet.newConditionalFormattingRule();
1031
+ * console.log(builder.getIconMap()); // icons key-value map
1032
+ * const rule = builder.setIconSet({
1033
+ * iconConfigs: [
1034
+ * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
1035
+ * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
1036
+ * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
1037
+ * ],
1038
+ * isShowValue: true,
1039
+ * })
1040
+ * .setRanges([fRange.getRange()])
1041
+ * .build();
1042
+ * fWorksheet.addConditionalFormattingRule(rule);
1043
+ * ```
1044
+ */
1045
+ setIconSet(e) {
1046
+ const t = this._ruleConfig;
1047
+ return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
1048
+ }
1049
+ }
1050
+ class w {
1051
+ constructor(e = {}) {
1052
+ this._initConfig = e;
1053
+ }
1054
+ /**
1055
+ * Constructs a conditional format rule from the settings applied to the builder.
1056
+ * @returns {IConditionFormattingRule} The conditional format rule.
1057
+ * @example
1058
+ * ```typescript
1059
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1060
+ * const fWorksheet = fWorkbook.getActiveSheet();
1061
+ *
1062
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1063
+ * const fRange = fWorksheet.getRange('A1:D10');
1064
+ * const rule = fWorksheet.newConditionalFormattingRule()
1065
+ * .whenNumberGreaterThan(10)
1066
+ * .setBackground('#FF0000')
1067
+ * .setRanges([fRange.getRange()])
1068
+ * .build();
1069
+ * fWorksheet.addConditionalFormattingRule(rule);
1070
+ * ```
1071
+ */
1072
+ build() {
1073
+ return new c(this._initConfig).build();
1074
+ }
1075
+ /**
1076
+ * Set average rule.
1077
+ * @param {IAverageHighlightCell['operator']} operator - The operator to use for the average rule.
1078
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1079
+ * @example
1080
+ * ```typescript
1081
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1082
+ * const fWorksheet = fWorkbook.getActiveSheet();
1083
+ *
1084
+ * // Create a conditional formatting rule that highlights cells with greater than average values in red for the range A1:D10.
1085
+ * const fRange = fWorksheet.getRange('A1:D10');
1086
+ * const rule = fWorksheet.newConditionalFormattingRule()
1087
+ * .setAverage(univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan)
1088
+ * .setBackground('#FF0000')
1089
+ * .setRanges([fRange.getRange()])
1090
+ * .build();
1091
+ * fWorksheet.addConditionalFormattingRule(rule);
1092
+ * ```
1093
+ */
1094
+ setAverage(e) {
1095
+ return new i(this._initConfig).setAverage(e);
1096
+ }
1097
+ /**
1098
+ * Set unique values rule.
1099
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1100
+ * @example
1101
+ * ```typescript
1102
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1103
+ * const fWorksheet = fWorkbook.getActiveSheet();
1104
+ *
1105
+ * // Create a conditional formatting rule that highlights cells with unique values in red for the range A1:D10.
1106
+ * const fRange = fWorksheet.getRange('A1:D10');
1107
+ * const rule = fWorksheet.newConditionalFormattingRule()
1108
+ * .setUniqueValues()
1109
+ * .setBackground('#FF0000')
1110
+ * .setRanges([fRange.getRange()])
1111
+ * .build();
1112
+ * fWorksheet.addConditionalFormattingRule(rule);
1113
+ * ```
1114
+ */
1115
+ setUniqueValues() {
1116
+ return new i(this._initConfig).setUniqueValues();
1117
+ }
1118
+ /**
1119
+ * Set duplicate values rule.
1120
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1121
+ * @example
1122
+ * ```typescript
1123
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1124
+ * const fWorksheet = fWorkbook.getActiveSheet();
1125
+ *
1126
+ * // Create a conditional formatting rule that highlights cells with duplicate values in red for the range A1:D10.
1127
+ * const fRange = fWorksheet.getRange('A1:D10');
1128
+ * const rule = fWorksheet.newConditionalFormattingRule()
1129
+ * .setDuplicateValues()
1130
+ * .setBackground('#FF0000')
1131
+ * .setRanges([fRange.getRange()])
1132
+ * .build();
1133
+ * fWorksheet.addConditionalFormattingRule(rule);
1134
+ * ```
1135
+ */
1136
+ setDuplicateValues() {
1137
+ return new i(this._initConfig).setDuplicateValues();
1138
+ }
1139
+ /**
1140
+ * Set rank rule.
1141
+ * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config - The rank rule settings.
1142
+ * @param {boolean} config.isBottom - Whether to highlight the bottom rank.
1143
+ * @param {boolean} config.isPercent - Whether to use a percentage rank.
1144
+ * @param {number} config.value - The rank value.
1145
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1146
+ * @example
1147
+ * ```typescript
1148
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1149
+ * const fWorksheet = fWorkbook.getActiveSheet();
1150
+ *
1151
+ * // Create a conditional formatting rule that highlights the bottom 10% of values in red for the range A1:D10.
1152
+ * const fRange = fWorksheet.getRange('A1:D10');
1153
+ * const rule = fWorksheet.newConditionalFormattingRule()
1154
+ * .setRank({ isBottom: true, isPercent: true, value: 10 })
1155
+ * .setBackground('#FF0000')
1156
+ * .setRanges([fRange.getRange()])
1157
+ * .build();
1158
+ * fWorksheet.addConditionalFormattingRule(rule);
1159
+ * ```
1160
+ */
1161
+ setRank(e) {
1162
+ return new i(this._initConfig).setRank(e);
1163
+ }
1164
+ /**
1165
+ * Get the icon set mapping dictionary.
1166
+ * @returns {Record<string, string[]>} The icon set mapping dictionary.
1167
+ * @example
1168
+ * ```typescript
1169
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1170
+ * const fWorksheet = fWorkbook.getActiveSheet();
1171
+ * console.log(fWorksheet.newConditionalFormattingRule().getIconMap()); // icons key-value map
1172
+ * ```
1173
+ */
1174
+ getIconMap() {
1175
+ return I;
1176
+ }
1177
+ /**
1178
+ * Set up icon set conditional formatting rule.
1179
+ * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config - The icon set conditional formatting rule settings.
1180
+ * @param {IIconSet['config']} config.iconConfigs - The icon configurations. iconId property is a string indexing of a group icons.
1181
+ * @param {boolean} config.isShowValue - Whether to show the value in the cell.
1182
+ * @returns {ConditionalFormatIconSetRuleBuilder} The conditional format icon set rule builder.
1183
+ * @example
1184
+ * ```typescript
1185
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1186
+ * const fWorksheet = fWorkbook.getActiveSheet();
1187
+ *
1188
+ * // Create a 3-arrow icon set conditional formatting rule in the range A1:D10.
1189
+ * // The first arrow is green for values greater than 20.
1190
+ * // The second arrow is yellow for values greater than 10.
1191
+ * // The third arrow is red for values less than or equal to 10.
1192
+ * const fRange = fWorksheet.getRange('A1:D10');
1193
+ * const builder = fWorksheet.newConditionalFormattingRule();
1194
+ * console.log(builder.getIconMap()); // icons key-value map
1195
+ * const rule = builder.setIconSet({
1196
+ * iconConfigs: [
1197
+ * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },
1198
+ * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },
1199
+ * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }
1200
+ * ],
1201
+ * isShowValue: true,
1202
+ * })
1203
+ * .setRanges([fRange.getRange()])
1204
+ * .build();
1205
+ * fWorksheet.addConditionalFormattingRule(rule);
1206
+ * ```
1207
+ */
1208
+ setIconSet(e) {
1209
+ return new b(this._initConfig).setIconSet(e);
1210
+ }
1211
+ /**
1212
+ * Set color scale rule.
1213
+ * @param {{ index: number; color: string; value: IValueConfig }[]} config - The color scale rule settings.
1214
+ * @param {number} config.index - The index of the color scale.
1215
+ * @param {string} config.color - The color for the color scale.
1216
+ * @param {IValueConfig} config.value - The value for the color scale.
1217
+ * @returns {ConditionalFormatColorScaleRuleBuilder} The conditional format color scale rule builder.
1218
+ * @example
1219
+ * ```typescript
1220
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1221
+ * const fWorksheet = fWorkbook.getActiveSheet();
1222
+ *
1223
+ * // Create a conditional formatting rule that adds a color scale to cells with values between 0 and 100 in the range A1:D10.
1224
+ * // The color scale is green for 0, yellow for 50, and red for 100.
1225
+ * const fRange = fWorksheet.getRange('A1:D10');
1226
+ * const rule = fWorksheet.newConditionalFormattingRule()
1227
+ * .setColorScale([
1228
+ * { index: 0, color: '#00FF00', value: { type: 'num', value: 0 } },
1229
+ * { index: 1, color: '#FFFF00', value: { type: 'num', value: 50 } },
1230
+ * { index: 2, color: '#FF0000', value: { type: 'num', value: 100 } }
1231
+ * ])
1232
+ * .setRanges([fRange.getRange()])
1233
+ * .build();
1234
+ * fWorksheet.addConditionalFormattingRule(rule);
1235
+ * ```
1236
+ */
1237
+ setColorScale(e) {
1238
+ return new y(this._initConfig).setColorScale(e);
1239
+ }
1240
+ /**
1241
+ * Set data bar rule.
1242
+ * @param {{
1243
+ * min: IValueConfig;
1244
+ * max: IValueConfig;
1245
+ * isGradient?: boolean;
1246
+ * positiveColor: string;
1247
+ * nativeColor: string;
1248
+ * isShowValue?: boolean;
1249
+ * }} config - The data bar rule settings.
1250
+ * @param {IValueConfig} config.min - The minimum value for the data bar.
1251
+ * @param {IValueConfig} config.max - The maximum value for the data bar.
1252
+ * @param {boolean} [config.isGradient] - Whether the data bar is gradient.
1253
+ * @param {string} config.positiveColor - The color for positive values.
1254
+ * @param {string} config.nativeColor - The color for negative values.
1255
+ * @param {boolean} [config.isShowValue] - Whether to show the value in the cell.
1256
+ * @returns {ConditionalFormatDataBarRuleBuilder} The conditional format data bar rule builder.
1257
+ * @example
1258
+ * ```typescript
1259
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1260
+ * const fWorksheet = fWorkbook.getActiveSheet();
1261
+ *
1262
+ * // Create a conditional formatting rule that adds a data bar to cells with values between -100 and 100 in the range A1:D10.
1263
+ * // positive values are green and negative values are red.
1264
+ * const fRange = fWorksheet.getRange('A1:D10');
1265
+ * const rule = fWorksheet.newConditionalFormattingRule()
1266
+ * .setDataBar({
1267
+ * min: { type: 'num', value: -100 },
1268
+ * max: { type: 'num', value: 100 },
1269
+ * positiveColor: '#00FF00',
1270
+ * nativeColor: '#FF0000',
1271
+ * isShowValue: true
1272
+ * })
1273
+ * .setRanges([fRange.getRange()])
1274
+ * .build();
1275
+ * fWorksheet.addConditionalFormattingRule(rule);
1276
+ * ```
1277
+ */
1278
+ setDataBar(e) {
1279
+ return new p(this._initConfig).setDataBar(e);
1280
+ }
1281
+ /**
1282
+ * Sets the background color for the conditional format rule's format.
1283
+ * @param {string} [color] - The background color to set. If not provided, the background color is removed.
1284
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1285
+ * @example
1286
+ * ```typescript
1287
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1288
+ * const fWorksheet = fWorkbook.getActiveSheet();
1289
+ *
1290
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
1291
+ * const fRange = fWorksheet.getRange('A1:D10');
1292
+ * const rule = fWorksheet.newConditionalFormattingRule()
1293
+ * .whenCellEmpty()
1294
+ * .setBackground('#FF0000')
1295
+ * .setRanges([fRange.getRange()])
1296
+ * .build();
1297
+ * fWorksheet.addConditionalFormattingRule(rule);
1298
+ * ```
1299
+ */
1300
+ setBackground(e) {
1301
+ return new i(this._initConfig).setBackground(e);
1302
+ }
1303
+ /**
1304
+ * Sets text bolding for the conditional format rule's format.
1305
+ * @param {boolean} isBold - Whether to bold the text.
1306
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1307
+ * @example
1308
+ * ```typescript
1309
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1310
+ * const fWorksheet = fWorkbook.getActiveSheet();
1311
+ *
1312
+ * // Create a conditional formatting rule that bolds the text for cells with not empty content in the range A1:D10.
1313
+ * const fRange = fWorksheet.getRange('A1:D10');
1314
+ * const rule = fWorksheet.newConditionalFormattingRule()
1315
+ * .whenCellNotEmpty()
1316
+ * .setBold(true)
1317
+ * .setRanges([fRange.getRange()])
1318
+ * .build();
1319
+ * fWorksheet.addConditionalFormattingRule(rule);
1320
+ * ```
1321
+ */
1322
+ setBold(e) {
1323
+ return new i(this._initConfig).setBold(e);
1324
+ }
1325
+ /**
1326
+ * Sets the font color for the conditional format rule's format.
1327
+ * @param {string} [color] - The font color to set. If not provided, the font color is removed.
1328
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1329
+ * @example
1330
+ * ```typescript
1331
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1332
+ * const fWorksheet = fWorkbook.getActiveSheet();
1333
+ *
1334
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
1335
+ * const fRange = fWorksheet.getRange('A1:D10');
1336
+ * const rule = fWorksheet.newConditionalFormattingRule()
1337
+ * .whenCellNotEmpty()
1338
+ * .setFontColor('#FF0000')
1339
+ * .setRanges([fRange.getRange()])
1340
+ * .build();
1341
+ * fWorksheet.addConditionalFormattingRule(rule);
1342
+ * ```
1343
+ */
1344
+ setFontColor(e) {
1345
+ return new i(this._initConfig).setFontColor(e);
1346
+ }
1347
+ /**
1348
+ * Sets text italics for the conditional format rule's format.
1349
+ * @param {boolean} isItalic - Whether to italicize the text.
1350
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1351
+ * @example
1352
+ * ```typescript
1353
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1354
+ * const fWorksheet = fWorkbook.getActiveSheet();
1355
+ *
1356
+ * // Create a conditional formatting rule that italicizes the text for cells with not empty content in the range A1:D10.
1357
+ * const fRange = fWorksheet.getRange('A1:D10');
1358
+ * const rule = fWorksheet.newConditionalFormattingRule()
1359
+ * .whenCellNotEmpty()
1360
+ * .setItalic(true)
1361
+ * .setRanges([fRange.getRange()])
1362
+ * .build();
1363
+ * fWorksheet.addConditionalFormattingRule(rule);
1364
+ * ```
1365
+ */
1366
+ setItalic(e) {
1367
+ return new i(this._initConfig).setItalic(e);
1368
+ }
1369
+ /**
1370
+ * Sets text strikethrough for the conditional format rule's format.
1371
+ * @param {boolean} isStrikethrough - Whether is strikethrough the text.
1372
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1373
+ * @example
1374
+ * ```typescript
1375
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1376
+ * const fWorksheet = fWorkbook.getActiveSheet();
1377
+ *
1378
+ * // Create a conditional formatting rule that set text strikethrough for cells with not empty content in the range A1:D10.
1379
+ * const fRange = fWorksheet.getRange('A1:D10');
1380
+ * const rule = fWorksheet.newConditionalFormattingRule()
1381
+ * .whenCellNotEmpty()
1382
+ * .setStrikethrough(true)
1383
+ * .setRanges([fRange.getRange()])
1384
+ * .build();
1385
+ * fWorksheet.addConditionalFormattingRule(rule);
1386
+ * ```
1387
+ */
1388
+ setStrikethrough(e) {
1389
+ return new i(this._initConfig).setStrikethrough(e);
1390
+ }
1391
+ /**
1392
+ * Sets text underlining for the conditional format rule's format.
1393
+ * @param {boolean} isUnderline - Whether to underline the text.
1394
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1395
+ * @example
1396
+ * ```typescript
1397
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1398
+ * const fWorksheet = fWorkbook.getActiveSheet();
1399
+ *
1400
+ * // Create a conditional formatting rule that underlines the text for cells with not empty content in the range A1:D10.
1401
+ * const fRange = fWorksheet.getRange('A1:D10');
1402
+ * const rule = fWorksheet.newConditionalFormattingRule()
1403
+ * .whenCellNotEmpty()
1404
+ * .setUnderline(true)
1405
+ * .setRanges([fRange.getRange()])
1406
+ * .build();
1407
+ * fWorksheet.addConditionalFormattingRule(rule);
1408
+ * ```
1409
+ */
1410
+ setUnderline(e) {
1411
+ return new i(this._initConfig).setUnderline(e);
1412
+ }
1413
+ /**
1414
+ * Sets the conditional format rule to trigger when the cell is empty.
1415
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1416
+ * @example
1417
+ * ```typescript
1418
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1419
+ * const fWorksheet = fWorkbook.getActiveSheet();
1420
+ *
1421
+ * // Create a conditional formatting rule that highlights cells with no content in red for the range A1:D10.
1422
+ * const fRange = fWorksheet.getRange('A1:D10');
1423
+ * const rule = fWorksheet.newConditionalFormattingRule()
1424
+ * .whenCellEmpty()
1425
+ * .setBackground('#FF0000')
1426
+ * .setRanges([fRange.getRange()])
1427
+ * .build();
1428
+ * fWorksheet.addConditionalFormattingRule(rule);
1429
+ * ```
1430
+ */
1431
+ whenCellEmpty() {
1432
+ return new i(this._initConfig).whenCellEmpty();
1433
+ }
1434
+ /**
1435
+ * Sets the conditional format rule to trigger when the cell is not empty.
1436
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1437
+ * @example
1438
+ * ```typescript
1439
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1440
+ * const fWorksheet = fWorkbook.getActiveSheet();
1441
+ *
1442
+ * // Create a conditional formatting rule that changes the font color to red for cells with not empty content in the range A1:D10.
1443
+ * const fRange = fWorksheet.getRange('A1:D10');
1444
+ * const rule = fWorksheet.newConditionalFormattingRule()
1445
+ * .whenCellNotEmpty()
1446
+ * .setFontColor('#FF0000')
1447
+ * .setRanges([fRange.getRange()])
1448
+ * .build();
1449
+ * fWorksheet.addConditionalFormattingRule(rule);
1450
+ * ```
1451
+ */
1452
+ whenCellNotEmpty() {
1453
+ return new i(this._initConfig).whenCellNotEmpty();
1454
+ }
1455
+ /**
1456
+ * Sets the conditional format rule to trigger when a time period is met.
1457
+ * @param {CFTimePeriodOperator} date - The time period to check for.
1458
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1459
+ * @example
1460
+ * ```typescript
1461
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1462
+ * const fWorksheet = fWorkbook.getActiveSheet();
1463
+ *
1464
+ * // Create a conditional formatting rule that highlights cells with dates in the last 7 days in red for the range A1:D10.
1465
+ * const fRange = fWorksheet.getRange('A1:D10');
1466
+ * const rule = fWorksheet.newConditionalFormattingRule()
1467
+ * .whenDate(univerAPI.Enum.ConditionFormatTimePeriodOperatorEnum.last7Days)
1468
+ * .setBackground('#FF0000')
1469
+ * .setRanges([fRange.getRange()])
1470
+ * .build();
1471
+ * fWorksheet.addConditionalFormattingRule(rule);
1472
+ * ```
1473
+ */
1474
+ whenDate(e) {
1475
+ return new i(this._initConfig).whenDate(e);
1476
+ }
1477
+ /**
1478
+ * Sets the conditional format rule to trigger when that the given formula evaluates to `true`.
1479
+ * @param {string} formulaString - A custom formula that evaluates to true if the input is valid. formulaString start with '='.
1480
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1481
+ * @example
1482
+ * ```typescript
1483
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1484
+ * const fWorksheet = fWorkbook.getActiveSheet();
1485
+ *
1486
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1487
+ * const fRange = fWorksheet.getRange('A1:D10');
1488
+ * const rule = fWorksheet.newConditionalFormattingRule()
1489
+ * .whenFormulaSatisfied('=A1>10')
1490
+ * .setBackground('#FF0000')
1491
+ * .setRanges([fRange.getRange()])
1492
+ * .build();
1493
+ * fWorksheet.addConditionalFormattingRule(rule);
1494
+ * ```
1495
+ */
1496
+ whenFormulaSatisfied(e) {
1497
+ return new i(this._initConfig).whenFormulaSatisfied(e);
1498
+ }
1499
+ /**
1500
+ * Sets the conditional format rule to trigger when a number falls between, or is either of, two specified values.
1501
+ * @param {number} start - The lowest acceptable value.
1502
+ * @param {number} end - The highest acceptable value.
1503
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1504
+ * @example
1505
+ * ```typescript
1506
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1507
+ * const fWorksheet = fWorkbook.getActiveSheet();
1508
+ *
1509
+ * // Create a conditional formatting rule that highlights cells with values between 10 and 20 in red for the range A1:D10.
1510
+ * const fRange = fWorksheet.getRange('A1:D10');
1511
+ * const rule = fWorksheet.newConditionalFormattingRule()
1512
+ * .whenNumberBetween(10, 20)
1513
+ * .setBackground('#FF0000')
1514
+ * .setRanges([fRange.getRange()])
1515
+ * .build();
1516
+ * fWorksheet.addConditionalFormattingRule(rule);
1517
+ * ```
1518
+ */
1519
+ whenNumberBetween(e, t) {
1520
+ return new i(this._initConfig).whenNumberBetween(e, t);
1521
+ }
1522
+ /**
1523
+ * Sets the conditional format rule to trigger when a number is equal to the given value.
1524
+ * @param {number} value - The sole acceptable value.
1525
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1526
+ * @example
1527
+ * ```typescript
1528
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1529
+ * const fWorksheet = fWorkbook.getActiveSheet();
1530
+ *
1531
+ * // Create a conditional formatting rule that highlights cells with values equal to 10 in red for the range A1:D10.
1532
+ * const fRange = fWorksheet.getRange('A1:D10');
1533
+ * const rule = fWorksheet.newConditionalFormattingRule()
1534
+ * .whenNumberEqualTo(10)
1535
+ * .setBackground('#FF0000')
1536
+ * .setRanges([fRange.getRange()])
1537
+ * .build();
1538
+ * fWorksheet.addConditionalFormattingRule(rule);
1539
+ * ```
1540
+ */
1541
+ whenNumberEqualTo(e) {
1542
+ return new i(this._initConfig).whenNumberEqualTo(e);
1543
+ }
1544
+ /**
1545
+ * Sets the conditional format rule to trigger when a number is greater than the given value.
1546
+ * @param {number} value - The highest unacceptable value.
1547
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1548
+ * @example
1549
+ * ```typescript
1550
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1551
+ * const fWorksheet = fWorkbook.getActiveSheet();
1552
+ *
1553
+ * // Create a conditional formatting rule that highlights cells with values greater than 10 in red for the range A1:D10.
1554
+ * const fRange = fWorksheet.getRange('A1:D10');
1555
+ * const rule = fWorksheet.newConditionalFormattingRule()
1556
+ * .whenNumberGreaterThan(10)
1557
+ * .setBackground('#FF0000')
1558
+ * .setRanges([fRange.getRange()])
1559
+ * .build();
1560
+ * fWorksheet.addConditionalFormattingRule(rule);
1561
+ * ```
1562
+ */
1563
+ whenNumberGreaterThan(e) {
1564
+ return new i(this._initConfig).whenNumberGreaterThan(e);
1565
+ }
1566
+ /**
1567
+ * Sets the conditional format rule to trigger when a number is greater than or equal to the given value.
1568
+ * @param {number} value - The lowest acceptable value.
1569
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1570
+ * @example
1571
+ * ```typescript
1572
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1573
+ * const fWorksheet = fWorkbook.getActiveSheet();
1574
+ *
1575
+ * // Create a conditional formatting rule that highlights cells with values greater than or equal to 10 in red for the range A1:D10.
1576
+ * const fRange = fWorksheet.getRange('A1:D10');
1577
+ * const rule = fWorksheet.newConditionalFormattingRule()
1578
+ * .whenNumberGreaterThanOrEqualTo(10)
1579
+ * .setBackground('#FF0000')
1580
+ * .setRanges([fRange.getRange()])
1581
+ * .build();
1582
+ * fWorksheet.addConditionalFormattingRule(rule);
1583
+ * ```
1584
+ */
1585
+ whenNumberGreaterThanOrEqualTo(e) {
1586
+ return new i(this._initConfig).whenNumberGreaterThanOrEqualTo(e);
1587
+ }
1588
+ /**
1589
+ * Sets the conditional conditional format rule to trigger when a number less than the given value.
1590
+ * @param {number} value - The lowest unacceptable value.
1591
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1592
+ * @example
1593
+ * ```typescript
1594
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1595
+ * const fWorksheet = fWorkbook.getActiveSheet();
1596
+ *
1597
+ * // Create a conditional formatting rule that highlights cells with values less than 10 in red for the range A1:D10.
1598
+ * const fRange = fWorksheet.getRange('A1:D10');
1599
+ * const rule = fWorksheet.newConditionalFormattingRule()
1600
+ * .whenNumberLessThan(10)
1601
+ * .setBackground('#FF0000')
1602
+ * .setRanges([fRange.getRange()])
1603
+ * .build();
1604
+ * fWorksheet.addConditionalFormattingRule(rule);
1605
+ * ```
1606
+ */
1607
+ whenNumberLessThan(e) {
1608
+ return new i(this._initConfig).whenNumberLessThan(e);
1609
+ }
1610
+ /**
1611
+ * Sets the conditional format rule to trigger when a number less than or equal to the given value.
1612
+ * @param {number} value - The highest acceptable value.
1613
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1614
+ * @example
1615
+ * ```typescript
1616
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1617
+ * const fWorksheet = fWorkbook.getActiveSheet();
1618
+ *
1619
+ * // Create a conditional formatting rule that highlights cells with values less than or equal to 10 in red for the range A1:D10.
1620
+ * const fRange = fWorksheet.getRange('A1:D10');
1621
+ * const rule = fWorksheet.newConditionalFormattingRule()
1622
+ * .whenNumberLessThanOrEqualTo(10)
1623
+ * .setBackground('#FF0000')
1624
+ * .setRanges([fRange.getRange()])
1625
+ * .build();
1626
+ * fWorksheet.addConditionalFormattingRule(rule);
1627
+ * ```
1628
+ */
1629
+ whenNumberLessThanOrEqualTo(e) {
1630
+ return new i(this._initConfig).whenNumberLessThanOrEqualTo(e);
1631
+ }
1632
+ /**
1633
+ * Sets the conditional format rule to trigger when a number does not fall between, and is neither of, two specified values.
1634
+ * @param {number} start - The lowest unacceptable value.
1635
+ * @param {number} end - The highest unacceptable value.
1636
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1637
+ * @example
1638
+ * ```typescript
1639
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1640
+ * const fWorksheet = fWorkbook.getActiveSheet();
1641
+ *
1642
+ * // Create a conditional formatting rule that highlights cells with values not between 10 and 20 in red for the range A1:D10.
1643
+ * const fRange = fWorksheet.getRange('A1:D10');
1644
+ * const rule = fWorksheet.newConditionalFormattingRule()
1645
+ * .whenNumberNotBetween(10, 20)
1646
+ * .setBackground('#FF0000')
1647
+ * .setRanges([fRange.getRange()])
1648
+ * .build();
1649
+ * fWorksheet.addConditionalFormattingRule(rule);
1650
+ * ```
1651
+ */
1652
+ whenNumberNotBetween(e, t) {
1653
+ return new i(this._initConfig).whenNumberNotBetween(e, t);
1654
+ }
1655
+ /**
1656
+ * Sets the conditional format rule to trigger when a number is not equal to the given value.
1657
+ * @param {number} value - The sole unacceptable value.
1658
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1659
+ * @example
1660
+ * ```typescript
1661
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1662
+ * const fWorksheet = fWorkbook.getActiveSheet();
1663
+ *
1664
+ * // Create a conditional formatting rule that highlights cells with values not equal to 10 in red for the range A1:D10.
1665
+ * const fRange = fWorksheet.getRange('A1:D10');
1666
+ * const rule = fWorksheet.newConditionalFormattingRule()
1667
+ * .whenNumberNotEqualTo(10)
1668
+ * .setBackground('#FF0000')
1669
+ * .setRanges([fRange.getRange()])
1670
+ * .build();
1671
+ * fWorksheet.addConditionalFormattingRule(rule);
1672
+ * ```
1673
+ */
1674
+ whenNumberNotEqualTo(e) {
1675
+ return new i(this._initConfig).whenNumberNotEqualTo(e);
1676
+ }
1677
+ /**
1678
+ * Sets the conditional format rule to trigger when that the input contains the given value.
1679
+ * @param {string} text - The value that the input must contain.
1680
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1681
+ * @example
1682
+ * ```typescript
1683
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1684
+ * const fWorksheet = fWorkbook.getActiveSheet();
1685
+ *
1686
+ * // Create a conditional formatting rule that highlights cells with text containing 'apple' in red for the range A1:D10.
1687
+ * const fRange = fWorksheet.getRange('A1:D10');
1688
+ * const rule = fWorksheet.newConditionalFormattingRule()
1689
+ * .whenTextContains('apple')
1690
+ * .setBackground('#FF0000')
1691
+ * .setRanges([fRange.getRange()])
1692
+ * .build();
1693
+ * fWorksheet.addConditionalFormattingRule(rule);
1694
+ * ```
1695
+ */
1696
+ whenTextContains(e) {
1697
+ return new i(this._initConfig).whenTextContains(e);
1698
+ }
1699
+ /**
1700
+ * Sets the conditional format rule to trigger when that the input does not contain the given value.
1701
+ * @param {string} text - The value that the input must not contain.
1702
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1703
+ * @example
1704
+ * ```typescript
1705
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1706
+ * const fWorksheet = fWorkbook.getActiveSheet();
1707
+ *
1708
+ * // Create a conditional formatting rule that highlights cells with text not containing 'apple' in red for the range A1:D10.
1709
+ * const fRange = fWorksheet.getRange('A1:D10');
1710
+ * const rule = fWorksheet.newConditionalFormattingRule()
1711
+ * .whenTextDoesNotContain('apple')
1712
+ * .setBackground('#FF0000')
1713
+ * .setRanges([fRange.getRange()])
1714
+ * .build();
1715
+ * fWorksheet.addConditionalFormattingRule(rule);
1716
+ * ```
1717
+ */
1718
+ whenTextDoesNotContain(e) {
1719
+ return new i(this._initConfig).whenTextDoesNotContain(e);
1720
+ }
1721
+ /**
1722
+ * Sets the conditional format rule to trigger when that the input ends with the given value.
1723
+ * @param {string} text - Text to compare against the end of the string.
1724
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1725
+ * @example
1726
+ * ```typescript
1727
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1728
+ * const fWorksheet = fWorkbook.getActiveSheet();
1729
+ *
1730
+ * // Create a conditional formatting rule that highlights cells with text ending with '.ai' in red for the range A1:D10.
1731
+ * const fRange = fWorksheet.getRange('A1:D10');
1732
+ * const rule = fWorksheet.newConditionalFormattingRule()
1733
+ * .whenTextEndsWith('.ai')
1734
+ * .setBackground('#FF0000')
1735
+ * .setRanges([fRange.getRange()])
1736
+ * .build();
1737
+ * fWorksheet.addConditionalFormattingRule(rule);
1738
+ * ```
1739
+ */
1740
+ whenTextEndsWith(e) {
1741
+ return new i(this._initConfig).whenTextEndsWith(e);
1742
+ }
1743
+ /**
1744
+ * Sets the conditional format rule to trigger when that the input is equal to the given value.
1745
+ * @param {string} text - The sole acceptable value.
1746
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1747
+ * @example
1748
+ * ```typescript
1749
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1750
+ * const fWorksheet = fWorkbook.getActiveSheet();
1751
+ *
1752
+ * // Create a conditional formatting rule that highlights cells with text equal to 'apple' in red for the range A1:D10.
1753
+ * const fRange = fWorksheet.getRange('A1:D10');
1754
+ * const rule = fWorksheet.newConditionalFormattingRule()
1755
+ * .whenTextEqualTo('apple')
1756
+ * .setBackground('#FF0000')
1757
+ * .setRanges([fRange.getRange()])
1758
+ * .build();
1759
+ * fWorksheet.addConditionalFormattingRule(rule);
1760
+ * ```
1761
+ */
1762
+ whenTextEqualTo(e) {
1763
+ return new i(this._initConfig).whenTextEqualTo(e);
1764
+ }
1765
+ /**
1766
+ * Sets the conditional format rule to trigger when that the input starts with the given value.
1767
+ * @param {string} text - Text to compare against the beginning of the string.
1768
+ * @returns {ConditionalFormatHighlightRuleBuilder} The conditional format highlight rule builder.
1769
+ * @example
1770
+ * ```typescript
1771
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1772
+ * const fWorksheet = fWorkbook.getActiveSheet();
1773
+ *
1774
+ * // Create a conditional formatting rule that highlights cells with text starting with 'https://' in red for the range A1:D10.
1775
+ * const fRange = fWorksheet.getRange('A1:D10');
1776
+ * const rule = fWorksheet.newConditionalFormattingRule()
1777
+ * .whenTextStartsWith('https://')
1778
+ * .setBackground('#FF0000')
1779
+ * .setRanges([fRange.getRange()])
1780
+ * .build();
1781
+ * fWorksheet.addConditionalFormattingRule(rule);
1782
+ * ```
1783
+ */
1784
+ whenTextStartsWith(e) {
1785
+ return new i(this._initConfig).whenTextStartsWith(e);
1786
+ }
1787
+ }
1788
+ class W extends v {
1789
+ _getConditionalFormattingRuleModel() {
1790
+ return this._injector.get(x);
1791
+ }
1792
+ getConditionalFormattingRules() {
1793
+ return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => B.intersects(r, this._range)));
1794
+ }
1795
+ createConditionalFormattingRule() {
1796
+ return new w({ ranges: [this._range] });
1797
+ }
1798
+ addConditionalFormattingRule(e) {
1799
+ const t = {
1800
+ unitId: this._workbook.getUnitId(),
1801
+ subUnitId: this._worksheet.getSheetId(),
1802
+ rule: e
1803
+ };
1804
+ return this._commandService.syncExecuteCommand(S.id, t), this;
1805
+ }
1806
+ deleteConditionalFormattingRule(e) {
1807
+ const t = {
1808
+ unitId: this._workbook.getUnitId(),
1809
+ subUnitId: this._worksheet.getSheetId(),
1810
+ cfId: e
1811
+ };
1812
+ return this._commandService.syncExecuteCommand(E.id, t), this;
1813
+ }
1814
+ moveConditionalFormattingRule(e, t, r = "after") {
1815
+ const l = {
1816
+ unitId: this._workbook.getUnitId(),
1817
+ subUnitId: this._worksheet.getSheetId(),
1818
+ start: { id: e, type: "self" },
1819
+ end: { id: t, type: r }
1820
+ };
1821
+ return this._commandService.syncExecuteCommand(k.id, l), this;
1822
+ }
1823
+ setConditionalFormattingRule(e, t) {
1824
+ const r = {
1825
+ unitId: this._workbook.getUnitId(),
1826
+ subUnitId: this._worksheet.getSheetId(),
1827
+ rule: t,
1828
+ cfId: e
1829
+ };
1830
+ return this._commandService.syncExecuteCommand(F.id, r), this;
1831
+ }
1832
+ clearConditionalFormatRules() {
1833
+ const e = {
1834
+ unitId: this._workbook.getUnitId(),
1835
+ subUnitId: this._worksheet.getSheetId(),
1836
+ ranges: [this._range]
1837
+ };
1838
+ return this._commandService.syncExecuteCommand(M.id, e), this;
1839
+ }
1840
+ }
1841
+ v.extend(W);
1842
+ class L extends R {
1843
+ newColor() {
1844
+ return new A();
1845
+ }
1846
+ }
1847
+ R.extend(L);
1848
+ class G extends N {
1849
+ _getConditionalFormattingRuleModel() {
1850
+ return this._injector.get(x);
1851
+ }
1852
+ getConditionalFormattingRules() {
1853
+ return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
1854
+ }
1855
+ createConditionalFormattingRule() {
1856
+ return new w();
1857
+ }
1858
+ newConditionalFormattingRule() {
1859
+ return new w();
1860
+ }
1861
+ addConditionalFormattingRule(e) {
1862
+ const t = {
1863
+ unitId: this._workbook.getUnitId(),
1864
+ subUnitId: this._worksheet.getSheetId(),
1865
+ rule: e
1866
+ };
1867
+ return this._commandService.syncExecuteCommand(S.id, t), this;
1868
+ }
1869
+ deleteConditionalFormattingRule(e) {
1870
+ const t = {
1871
+ unitId: this._workbook.getUnitId(),
1872
+ subUnitId: this._worksheet.getSheetId(),
1873
+ cfId: e
1874
+ };
1875
+ return this._commandService.syncExecuteCommand(E.id, t), this;
1876
+ }
1877
+ moveConditionalFormattingRule(e, t, r = "after") {
1878
+ const l = {
1879
+ unitId: this._workbook.getUnitId(),
1880
+ subUnitId: this._worksheet.getSheetId(),
1881
+ start: { id: e, type: "self" },
1882
+ end: { id: t, type: r }
1883
+ };
1884
+ return this._commandService.syncExecuteCommand(k.id, l), this;
1885
+ }
1886
+ setConditionalFormattingRule(e, t) {
1887
+ const r = {
1888
+ unitId: this._workbook.getUnitId(),
1889
+ subUnitId: this._worksheet.getSheetId(),
1890
+ cfId: e,
1891
+ rule: t
1892
+ };
1893
+ return this._commandService.syncExecuteCommand(F.id, r), this;
1894
+ }
1895
+ clearConditionalFormatRules() {
1896
+ const e = {
1897
+ unitId: this._workbook.getUnitId(),
1898
+ subUnitId: this._worksheet.getSheetId()
1899
+ };
1900
+ return this._commandService.syncExecuteCommand(O.id, e), this;
1901
+ }
1902
+ }
1903
+ N.extend(G);
1904
+ class P {
1905
+ get ConditionFormatNumberOperatorEnum() {
1906
+ return s;
1907
+ }
1908
+ get ConditionFormatTimePeriodOperatorEnum() {
1909
+ return D;
1910
+ }
1911
+ }
1912
+ V.extend(P);
1913
+ export {
1914
+ w as FConditionalFormattingBuilder
1915
+ };