@univerjs/sheets-conditional-formatting 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +815 -0
- package/lib/es/index.js +205 -200
- package/lib/types/facade/conditional-formatting-builder.d.ts +487 -0
- package/lib/types/facade/f-range.d.ts +106 -0
- package/lib/types/facade/f-workbook.d.ts +12 -0
- package/lib/types/facade/f-worksheet.d.ts +116 -0
- package/lib/types/facade/index.d.ts +22 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +18 -8
package/lib/es/facade.js
ADDED
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var q = (u, e, t) => e in u ? N(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
|
|
3
|
+
var b = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ColorKit as _, Tools as c, BooleanNumber as a, Rectangle as U, ColorBuilder as B } from "@univerjs/core";
|
|
5
|
+
import { CFRuleType as n, CFNumberOperator as l, CFValueType as C, EMPTY_ICON_TYPE as f, CFSubRuleType as o, CFTextOperator as g, createCfId as y, iconMap as M, ConditionalFormattingRuleModel as T, AddConditionalRuleMutation as x, DeleteConditionalRuleMutation as S, MoveConditionalRuleMutation as I, SetConditionalRuleMutation as v } from "@univerjs/sheets-conditional-formatting";
|
|
6
|
+
import { FRange as k, FWorkbook as F, FWorksheet as R } from "@univerjs/sheets/facade";
|
|
7
|
+
class d {
|
|
8
|
+
constructor(e = {}) {
|
|
9
|
+
b(this, "_rule", {});
|
|
10
|
+
this._rule = e, this._ensureAttr(this._rule, ["rule"]);
|
|
11
|
+
}
|
|
12
|
+
get _ruleConfig() {
|
|
13
|
+
return this._rule.rule || null;
|
|
14
|
+
}
|
|
15
|
+
_getDefaultConfig(e = n.highlightCell) {
|
|
16
|
+
switch (e) {
|
|
17
|
+
case n.colorScale:
|
|
18
|
+
return {
|
|
19
|
+
type: e,
|
|
20
|
+
config: [
|
|
21
|
+
{ index: 0, color: new _("").toRgbString(), value: { type: C.min } },
|
|
22
|
+
{ index: 0, color: new _("green").toRgbString(), value: { type: C.max } }
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
case n.dataBar:
|
|
26
|
+
return {
|
|
27
|
+
type: e,
|
|
28
|
+
isShowValue: !0,
|
|
29
|
+
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new _("green").toRgbString(), nativeColor: new _("").toRgbString(), isGradient: !1 }
|
|
30
|
+
};
|
|
31
|
+
case n.highlightCell:
|
|
32
|
+
return {
|
|
33
|
+
type: e,
|
|
34
|
+
subType: o.text,
|
|
35
|
+
operator: g.containsText,
|
|
36
|
+
value: "abc",
|
|
37
|
+
style: {}
|
|
38
|
+
};
|
|
39
|
+
case n.iconSet:
|
|
40
|
+
return {
|
|
41
|
+
type: e,
|
|
42
|
+
isShowValue: !0,
|
|
43
|
+
config: [
|
|
44
|
+
{
|
|
45
|
+
operator: l.greaterThanOrEqual,
|
|
46
|
+
value: { type: C.min },
|
|
47
|
+
iconType: f,
|
|
48
|
+
iconId: ""
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
operator: l.greaterThanOrEqual,
|
|
52
|
+
value: { type: C.percentile, value: 0.5 },
|
|
53
|
+
iconType: f,
|
|
54
|
+
iconId: ""
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
operator: l.lessThanOrEqual,
|
|
58
|
+
value: { type: C.max },
|
|
59
|
+
iconType: f,
|
|
60
|
+
iconId: ""
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line ts/no-explicit-any
|
|
67
|
+
_ensureAttr(e, t) {
|
|
68
|
+
return t.reduce((r, s) => (r[s] || (r[s] = {}), r[s]), e), e;
|
|
69
|
+
}
|
|
70
|
+
build() {
|
|
71
|
+
var r;
|
|
72
|
+
this._rule.cfId || (this._rule.cfId = y()), 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"]));
|
|
73
|
+
const e = this._getDefaultConfig(this._rule.rule.type);
|
|
74
|
+
return { ...this._rule, rule: { ...e, ...this._rule.rule } };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* deep clone a current builder.
|
|
78
|
+
*
|
|
79
|
+
* @return {*}
|
|
80
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
81
|
+
*/
|
|
82
|
+
copy() {
|
|
83
|
+
return new d(c.deepClone(this._rule));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the scope of the current conditional format
|
|
87
|
+
* @return {*}
|
|
88
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
89
|
+
*/
|
|
90
|
+
getRanges() {
|
|
91
|
+
return this._rule.ranges || [];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the icon set mapping dictionary
|
|
95
|
+
*/
|
|
96
|
+
getIconMap() {
|
|
97
|
+
return M;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* create a conditional format ID.
|
|
101
|
+
* @return {*}
|
|
102
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
103
|
+
*/
|
|
104
|
+
createCfId() {
|
|
105
|
+
return y();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sets the scope for conditional formatting
|
|
109
|
+
* @param {IRange[]} ranges
|
|
110
|
+
* @return {*}
|
|
111
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
112
|
+
*/
|
|
113
|
+
setRanges(e) {
|
|
114
|
+
return this._rule.ranges = e, this;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
class i extends d {
|
|
118
|
+
constructor(e = {}) {
|
|
119
|
+
super(e), this._ensureAttr(this._rule, ["rule", "style"]);
|
|
120
|
+
}
|
|
121
|
+
copy() {
|
|
122
|
+
return new i(c.deepClone(this._rule));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Set average rule
|
|
126
|
+
*
|
|
127
|
+
* @param {IAverageHighlightCell['operator']} operator
|
|
128
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
129
|
+
*/
|
|
130
|
+
setAverage(e) {
|
|
131
|
+
const t = this._ruleConfig;
|
|
132
|
+
return t.type = n.highlightCell, t.subType = o.average, t.operator = e, this;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Set uniqueValues rule
|
|
136
|
+
*
|
|
137
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
138
|
+
*/
|
|
139
|
+
setUniqueValues() {
|
|
140
|
+
const e = this._ruleConfig;
|
|
141
|
+
return e.type = n.highlightCell, e.subType = o.uniqueValues, this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Set duplicateValues rule
|
|
145
|
+
*
|
|
146
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
147
|
+
*/
|
|
148
|
+
setDuplicateValues() {
|
|
149
|
+
const e = this._ruleConfig;
|
|
150
|
+
return e.type = n.highlightCell, e.subType = o.duplicateValues, this;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Set rank rule
|
|
154
|
+
*
|
|
155
|
+
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
|
|
156
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
157
|
+
*/
|
|
158
|
+
setRank(e) {
|
|
159
|
+
const t = this._ruleConfig;
|
|
160
|
+
return t.type = n.highlightCell, t.subType = o.rank, t.isBottom = e.isBottom, t.isPercent = e.isPercent, t.value = e.value, this;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sets the background color
|
|
164
|
+
* @param {string} [color]
|
|
165
|
+
* @return {*}
|
|
166
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
167
|
+
*/
|
|
168
|
+
setBackground(e) {
|
|
169
|
+
var t;
|
|
170
|
+
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
171
|
+
if (e) {
|
|
172
|
+
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
173
|
+
const r = new _(e);
|
|
174
|
+
this._ruleConfig.style.bg.rgb = r.toRgbString();
|
|
175
|
+
} else
|
|
176
|
+
delete this._ruleConfig.style.bg;
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Set Bold
|
|
181
|
+
* @param {boolean} isBold
|
|
182
|
+
* @return {*}
|
|
183
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
184
|
+
*/
|
|
185
|
+
setBold(e) {
|
|
186
|
+
var t;
|
|
187
|
+
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;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sets the font color
|
|
191
|
+
* @param {string} [color]
|
|
192
|
+
* @return {*}
|
|
193
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
194
|
+
*/
|
|
195
|
+
setFontColor(e) {
|
|
196
|
+
var t;
|
|
197
|
+
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
198
|
+
if (e) {
|
|
199
|
+
const r = new _(e);
|
|
200
|
+
this._ensureAttr(this._ruleConfig, ["style", "cl"]), this._ruleConfig.style.cl.rgb = r.toRgbString();
|
|
201
|
+
} else
|
|
202
|
+
delete this._ruleConfig.style.cl;
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Set the text to italic
|
|
207
|
+
* @param {boolean} isItalic
|
|
208
|
+
* @return {*}
|
|
209
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
210
|
+
*/
|
|
211
|
+
setItalic(e) {
|
|
212
|
+
var t;
|
|
213
|
+
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;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Set the strikethrough
|
|
217
|
+
* @param {boolean} isStrikethrough
|
|
218
|
+
* @return {*}
|
|
219
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
220
|
+
*/
|
|
221
|
+
setStrikethrough(e) {
|
|
222
|
+
var t;
|
|
223
|
+
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;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Set the underscore
|
|
227
|
+
* @param {boolean} isUnderline
|
|
228
|
+
* @return {*}
|
|
229
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
230
|
+
*/
|
|
231
|
+
setUnderline(e) {
|
|
232
|
+
var t;
|
|
233
|
+
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;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Sets the conditional formatting rule to fire when the cell is empty.
|
|
237
|
+
*/
|
|
238
|
+
whenCellEmpty() {
|
|
239
|
+
const e = this._ruleConfig;
|
|
240
|
+
return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.equal, this;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sets the conditional formatting rule to fire when the cell is not empty
|
|
244
|
+
* @return {*}
|
|
245
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
246
|
+
*/
|
|
247
|
+
whenCellNotEmpty() {
|
|
248
|
+
const e = this._ruleConfig;
|
|
249
|
+
return e.type = n.highlightCell, e.subType = o.text, e.value = "", e.operator = g.notEqual, this;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Highlight when the date is in a time period, custom time is not supported.
|
|
253
|
+
*
|
|
254
|
+
* @param {CFTimePeriodOperator} date
|
|
255
|
+
* @return {*}
|
|
256
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
257
|
+
*/
|
|
258
|
+
whenDate(e) {
|
|
259
|
+
const t = this._ruleConfig;
|
|
260
|
+
return t.type = n.highlightCell, t.subType = o.timePeriod, t.operator = e, this;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Sets a conditional formatting rule to fire when a given formula evaluates to true.
|
|
264
|
+
* @param {string} formulaString formulaString start with' = '
|
|
265
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
266
|
+
*/
|
|
267
|
+
whenFormulaSatisfied(e) {
|
|
268
|
+
const t = this._ruleConfig;
|
|
269
|
+
return t.type = n.highlightCell, t.subType = o.formula, t.value = e, this;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Sets the conditional formatting rule to fire when a number is between two specified values or equal to one of them.
|
|
273
|
+
* @param {number} start
|
|
274
|
+
* @param {number} end
|
|
275
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
276
|
+
*/
|
|
277
|
+
whenNumberBetween(e, t) {
|
|
278
|
+
const r = Math.min(e, t), s = Math.max(e, t), h = this._ruleConfig;
|
|
279
|
+
return h.type = n.highlightCell, h.subType = o.number, h.value = [r, s], h.operator = l.between, this;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Sets the conditional formatting rule to fire when the number equals the given value
|
|
283
|
+
*
|
|
284
|
+
* @param {number} value
|
|
285
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
286
|
+
*/
|
|
287
|
+
whenNumberEqualTo(e) {
|
|
288
|
+
const t = this._ruleConfig;
|
|
289
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.equal, this;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Sets the conditional formatting rule to fire when the number is greater than the given value
|
|
293
|
+
* @param {number} value
|
|
294
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
295
|
+
*/
|
|
296
|
+
whenNumberGreaterThan(e) {
|
|
297
|
+
const t = this._ruleConfig;
|
|
298
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.greaterThan, this;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Sets a conditional formatting rule to fire when a number is greater than or equal to a given value.
|
|
302
|
+
* @param {number} value
|
|
303
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
304
|
+
*/
|
|
305
|
+
whenNumberGreaterThanOrEqualTo(e) {
|
|
306
|
+
const t = this._ruleConfig;
|
|
307
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.greaterThanOrEqual, this;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Sets a conditional formatting rule to fire when the number is less than the given value.
|
|
311
|
+
* @param {number} value
|
|
312
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
313
|
+
*/
|
|
314
|
+
whenNumberLessThan(e) {
|
|
315
|
+
const t = this._ruleConfig;
|
|
316
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.lessThan, this;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Sets the conditional formatting rule to fire when the value is less than or equal to the given value.
|
|
320
|
+
* @param {number} value
|
|
321
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
322
|
+
*/
|
|
323
|
+
whenNumberLessThanOrEqualTo(e) {
|
|
324
|
+
const t = this._ruleConfig;
|
|
325
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.lessThanOrEqual, this;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Sets a conditional formatting rule to fire when a number is not between two specified values and is not equal to them.
|
|
329
|
+
* @param {number} start
|
|
330
|
+
* @param {number} end
|
|
331
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
332
|
+
*/
|
|
333
|
+
whenNumberNotBetween(e, t) {
|
|
334
|
+
const r = Math.min(e, t), s = Math.max(e, t), h = this._ruleConfig;
|
|
335
|
+
return h.type = n.highlightCell, h.subType = o.number, h.value = [r, s], h.operator = l.notBetween, this;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Sets the conditional formatting rule to fire when a number does not equal a given value.
|
|
339
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
340
|
+
*/
|
|
341
|
+
whenNumberNotEqualTo(e) {
|
|
342
|
+
const t = this._ruleConfig;
|
|
343
|
+
return t.type = n.highlightCell, t.subType = o.number, t.value = e, t.operator = l.notEqual, this;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Sets the conditional formatting rule to fire when the input contains the given value.
|
|
347
|
+
* @param {string} text
|
|
348
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
349
|
+
*/
|
|
350
|
+
whenTextContains(e) {
|
|
351
|
+
const t = this._ruleConfig;
|
|
352
|
+
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.containsText, this;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Sets a conditional formatting rule to fire when the input does not contain the given value.
|
|
356
|
+
* @param {string} text
|
|
357
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
358
|
+
*/
|
|
359
|
+
whenTextDoesNotContain(e) {
|
|
360
|
+
const t = this._ruleConfig;
|
|
361
|
+
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.notContainsText, this;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Sets a conditional formatting rule to fire when input ends with a specified value.
|
|
365
|
+
* @param {string} text
|
|
366
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
367
|
+
*/
|
|
368
|
+
whenTextEndsWith(e) {
|
|
369
|
+
const t = this._ruleConfig;
|
|
370
|
+
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.endsWith, this;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Sets the conditional formatting rule to fire when the input equals the given value.
|
|
374
|
+
* @param {string} text
|
|
375
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
376
|
+
*/
|
|
377
|
+
whenTextEqualTo(e) {
|
|
378
|
+
const t = this._ruleConfig;
|
|
379
|
+
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.equal, this;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Sets the conditional formatting rule to fire when the input value begins with the given value.
|
|
383
|
+
* @param {string} text
|
|
384
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
385
|
+
*/
|
|
386
|
+
whenTextStartsWith(e) {
|
|
387
|
+
const t = this._ruleConfig;
|
|
388
|
+
return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.beginsWith, this;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
class m extends d {
|
|
392
|
+
copy() {
|
|
393
|
+
return new m(c.deepClone(this._rule));
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Data bar settings
|
|
397
|
+
*
|
|
398
|
+
* @param {{
|
|
399
|
+
* min: IValueConfig;
|
|
400
|
+
* max: IValueConfig;
|
|
401
|
+
* isGradient?: boolean;
|
|
402
|
+
* positiveColor: string;
|
|
403
|
+
* nativeColor: string;
|
|
404
|
+
* isShowValue?: boolean;
|
|
405
|
+
* }} config
|
|
406
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
407
|
+
*/
|
|
408
|
+
setDataBar(e) {
|
|
409
|
+
const t = this._ruleConfig;
|
|
410
|
+
return t.type = n.dataBar, t.isShowValue = !!e.isShowValue, t.config = {
|
|
411
|
+
min: e.min,
|
|
412
|
+
max: e.max,
|
|
413
|
+
positiveColor: e.positiveColor,
|
|
414
|
+
nativeColor: e.nativeColor,
|
|
415
|
+
isGradient: !!e.isGradient
|
|
416
|
+
}, this;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
class w extends d {
|
|
420
|
+
copy() {
|
|
421
|
+
return new w(c.deepClone(this._rule));
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Color scale set
|
|
425
|
+
* @param {{ index: number; color: string; value: IValueConfig }[]} config
|
|
426
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
427
|
+
*/
|
|
428
|
+
setColorScale(e) {
|
|
429
|
+
const t = this._ruleConfig;
|
|
430
|
+
return t.type = n.colorScale, t.config = e, this;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
class p extends d {
|
|
434
|
+
copy() {
|
|
435
|
+
return new p(c.deepClone(this._rule));
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
*
|
|
439
|
+
* Icon Set
|
|
440
|
+
* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
|
|
441
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
442
|
+
*/
|
|
443
|
+
setIconSet(e) {
|
|
444
|
+
const t = this._ruleConfig;
|
|
445
|
+
return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
class E {
|
|
449
|
+
constructor(e = {}) {
|
|
450
|
+
this._initConfig = e;
|
|
451
|
+
}
|
|
452
|
+
build() {
|
|
453
|
+
return new d(this._initConfig).build();
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Set average rule
|
|
457
|
+
*
|
|
458
|
+
* @param {IAverageHighlightCell['operator']} operator
|
|
459
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
460
|
+
*/
|
|
461
|
+
setAverage(e) {
|
|
462
|
+
return new i(this._initConfig).setAverage(e);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Set uniqueValues rule
|
|
466
|
+
*
|
|
467
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
468
|
+
*/
|
|
469
|
+
setUniqueValues() {
|
|
470
|
+
return new i(this._initConfig).setUniqueValues();
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Set duplicateValues rule
|
|
474
|
+
*
|
|
475
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
476
|
+
*/
|
|
477
|
+
setDuplicateValues() {
|
|
478
|
+
return new i(this._initConfig).setDuplicateValues();
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Set rank rule
|
|
482
|
+
*
|
|
483
|
+
* @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
|
|
484
|
+
* @memberof ConditionalFormatHighlightRuleBuilder
|
|
485
|
+
*/
|
|
486
|
+
setRank(e) {
|
|
487
|
+
return new i(this._initConfig).setRank(e);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
*
|
|
491
|
+
* Set iconSet rule
|
|
492
|
+
* @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
|
|
493
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
494
|
+
*/
|
|
495
|
+
setIconSet(e) {
|
|
496
|
+
return new p(this._initConfig).setIconSet(e);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Set colorScale rule
|
|
500
|
+
* @param {{ index: number; color: string; value: IValueConfig }[]} config
|
|
501
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
502
|
+
*/
|
|
503
|
+
setColorScale(e) {
|
|
504
|
+
return new w(this._initConfig).setColorScale(e);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Set dataBar rule
|
|
508
|
+
*
|
|
509
|
+
* @param {{
|
|
510
|
+
* min: IValueConfig;
|
|
511
|
+
* max: IValueConfig;
|
|
512
|
+
* isGradient?: boolean;
|
|
513
|
+
* positiveColor: string;
|
|
514
|
+
* nativeColor: string;
|
|
515
|
+
* isShowValue?: boolean;
|
|
516
|
+
* }} config
|
|
517
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
518
|
+
*/
|
|
519
|
+
setDataBar(e) {
|
|
520
|
+
return new m(this._initConfig).setDataBar(e);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Sets the background color
|
|
524
|
+
* @param {string} [color]
|
|
525
|
+
* @return {*}
|
|
526
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
527
|
+
*/
|
|
528
|
+
setBackground(e) {
|
|
529
|
+
return new i(this._initConfig).setBackground(e);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Set Bold
|
|
533
|
+
* @param {boolean} isBold
|
|
534
|
+
* @return {*}
|
|
535
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
536
|
+
*/
|
|
537
|
+
setBold(e) {
|
|
538
|
+
return new i(this._initConfig).setBold(e);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Sets the font color
|
|
542
|
+
* @param {string} [color]
|
|
543
|
+
* @return {*}
|
|
544
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
545
|
+
*/
|
|
546
|
+
setFontColor(e) {
|
|
547
|
+
return new i(this._initConfig).setFontColor(e);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Set the text to italic
|
|
551
|
+
* @param {boolean} isItalic
|
|
552
|
+
* @return {*}
|
|
553
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
554
|
+
*/
|
|
555
|
+
setItalic(e) {
|
|
556
|
+
return new i(this._initConfig).setItalic(e);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Set the strikethrough
|
|
560
|
+
* @param {boolean} isStrikethrough
|
|
561
|
+
* @return {*}
|
|
562
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
563
|
+
*/
|
|
564
|
+
setStrikethrough(e) {
|
|
565
|
+
return new i(this._initConfig).setStrikethrough(e);
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Set the underscore
|
|
569
|
+
* @param {boolean} isUnderline
|
|
570
|
+
* @return {*}
|
|
571
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
572
|
+
*/
|
|
573
|
+
setUnderline(e) {
|
|
574
|
+
return new i(this._initConfig).setUnderline(e);
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Sets the conditional formatting rule to fire when the cell is empty.
|
|
578
|
+
*/
|
|
579
|
+
whenCellEmpty() {
|
|
580
|
+
return new i(this._initConfig).whenCellEmpty();
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Sets the conditional formatting rule to fire when the cell is not empty
|
|
584
|
+
* @return {*}
|
|
585
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
586
|
+
*/
|
|
587
|
+
whenCellNotEmpty() {
|
|
588
|
+
return new i(this._initConfig).whenCellNotEmpty();
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Highlight when the date is in a time period, custom time is not supported.
|
|
592
|
+
*
|
|
593
|
+
* @param {CFTimePeriodOperator} date
|
|
594
|
+
* @return {*}
|
|
595
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
596
|
+
*/
|
|
597
|
+
whenDate(e) {
|
|
598
|
+
return new i(this._initConfig).whenDate(e);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Sets a conditional formatting rule to fire when a given formula evaluates to true.
|
|
602
|
+
* @param {string} formulaString formulaString start with' = '
|
|
603
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
604
|
+
*/
|
|
605
|
+
whenFormulaSatisfied(e) {
|
|
606
|
+
return new i(this._initConfig).whenFormulaSatisfied(e);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Sets the conditional formatting rule to fire when a number is between two specified values or equal to one of them.
|
|
610
|
+
* @param {number} start
|
|
611
|
+
* @param {number} end
|
|
612
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
613
|
+
*/
|
|
614
|
+
whenNumberBetween(e, t) {
|
|
615
|
+
return new i(this._initConfig).whenNumberBetween(e, t);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Sets the conditional formatting rule to fire when the number equals the given value
|
|
619
|
+
*
|
|
620
|
+
* @param {number} value
|
|
621
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
622
|
+
*/
|
|
623
|
+
whenNumberEqualTo(e) {
|
|
624
|
+
return new i(this._initConfig).whenNumberEqualTo(e);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Sets the conditional formatting rule to fire when the number is greater than the given value
|
|
628
|
+
* @param {number} value
|
|
629
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
630
|
+
*/
|
|
631
|
+
whenNumberGreaterThan(e) {
|
|
632
|
+
return new i(this._initConfig).whenNumberGreaterThan(e);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Sets a conditional formatting rule to fire when a number is greater than or equal to a given value.
|
|
636
|
+
* @param {number} value
|
|
637
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
638
|
+
*/
|
|
639
|
+
whenNumberGreaterThanOrEqualTo(e) {
|
|
640
|
+
return new i(this._initConfig).whenNumberGreaterThanOrEqualTo(e);
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Sets a conditional formatting rule to fire when the number is less than the given value.
|
|
644
|
+
* @param {number} value
|
|
645
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
646
|
+
*/
|
|
647
|
+
whenNumberLessThan(e) {
|
|
648
|
+
return new i(this._initConfig).whenNumberLessThan(e);
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Sets the conditional formatting rule to fire when the value is less than or equal to the given value.
|
|
652
|
+
* @param {number} value
|
|
653
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
654
|
+
*/
|
|
655
|
+
whenNumberLessThanOrEqualTo(e) {
|
|
656
|
+
return new i(this._initConfig).whenNumberLessThanOrEqualTo(e);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Sets a conditional formatting rule to fire when a number is not between two specified values and is not equal to them.
|
|
660
|
+
* @param {number} start
|
|
661
|
+
* @param {number} end
|
|
662
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
663
|
+
*/
|
|
664
|
+
whenNumberNotBetween(e, t) {
|
|
665
|
+
return new i(this._initConfig).whenNumberNotBetween(e, t);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Sets the conditional formatting rule to fire when a number does not equal a given value.
|
|
669
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
670
|
+
*/
|
|
671
|
+
whenNumberNotEqualTo(e) {
|
|
672
|
+
return new i(this._initConfig).whenNumberNotEqualTo(e);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Sets the conditional formatting rule to fire when the input contains the given value.
|
|
676
|
+
* @param {string} text
|
|
677
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
678
|
+
*/
|
|
679
|
+
whenTextContains(e) {
|
|
680
|
+
return new i(this._initConfig).whenTextContains(e);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Sets a conditional formatting rule to fire when the input does not contain the given value.
|
|
684
|
+
* @param {string} text
|
|
685
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
686
|
+
*/
|
|
687
|
+
whenTextDoesNotContain(e) {
|
|
688
|
+
return new i(this._initConfig).whenTextDoesNotContain(e);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Sets a conditional formatting rule to fire when input ends with a specified value.
|
|
692
|
+
* @param {string} text
|
|
693
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
694
|
+
*/
|
|
695
|
+
whenTextEndsWith(e) {
|
|
696
|
+
return new i(this._initConfig).whenTextEndsWith(e);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Sets the conditional formatting rule to fire when the input equals the given value.
|
|
700
|
+
* @param {string} text
|
|
701
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
702
|
+
*/
|
|
703
|
+
whenTextEqualTo(e) {
|
|
704
|
+
return new i(this._initConfig).whenTextEqualTo(e);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Sets the conditional formatting rule to fire when the input value begins with the given value.
|
|
708
|
+
* @param {string} text
|
|
709
|
+
* @memberof ConditionalFormatRuleBuilder
|
|
710
|
+
*/
|
|
711
|
+
whenTextStartsWith(e) {
|
|
712
|
+
return new i(this._initConfig).whenTextStartsWith(e);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
class A extends k {
|
|
716
|
+
_getConditionalFormattingRuleModel() {
|
|
717
|
+
return this._injector.get(T);
|
|
718
|
+
}
|
|
719
|
+
getConditionalFormattingRules() {
|
|
720
|
+
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => U.intersects(r, this._range)));
|
|
721
|
+
}
|
|
722
|
+
createConditionalFormattingRule() {
|
|
723
|
+
return new E({ ranges: [this._range] });
|
|
724
|
+
}
|
|
725
|
+
addConditionalFormattingRule(e) {
|
|
726
|
+
const t = {
|
|
727
|
+
rule: e,
|
|
728
|
+
unitId: this._workbook.getUnitId(),
|
|
729
|
+
subUnitId: this._worksheet.getSheetId()
|
|
730
|
+
};
|
|
731
|
+
return this._commandService.executeCommand(x.id, t);
|
|
732
|
+
}
|
|
733
|
+
deleteConditionalFormattingRule(e) {
|
|
734
|
+
const t = {
|
|
735
|
+
unitId: this._workbook.getUnitId(),
|
|
736
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
737
|
+
cfId: e
|
|
738
|
+
};
|
|
739
|
+
return this._commandService.executeCommand(S.id, t);
|
|
740
|
+
}
|
|
741
|
+
moveConditionalFormattingRule(e, t, r = "after") {
|
|
742
|
+
const s = {
|
|
743
|
+
unitId: this._workbook.getUnitId(),
|
|
744
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
745
|
+
start: { id: e, type: "self" },
|
|
746
|
+
end: { id: t, type: r }
|
|
747
|
+
};
|
|
748
|
+
return this._commandService.executeCommand(I.id, s);
|
|
749
|
+
}
|
|
750
|
+
setConditionalFormattingRule(e, t) {
|
|
751
|
+
const r = {
|
|
752
|
+
unitId: this._workbook.getUnitId(),
|
|
753
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
754
|
+
rule: t,
|
|
755
|
+
cfId: e
|
|
756
|
+
};
|
|
757
|
+
return this._commandService.executeCommand(v.id, r);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
k.extend(A);
|
|
761
|
+
class D extends F {
|
|
762
|
+
newColor() {
|
|
763
|
+
return new B();
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
F.extend(D);
|
|
767
|
+
class V extends R {
|
|
768
|
+
_getConditionalFormattingRuleModel() {
|
|
769
|
+
return this._injector.get(T);
|
|
770
|
+
}
|
|
771
|
+
getConditionalFormattingRules() {
|
|
772
|
+
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
|
|
773
|
+
}
|
|
774
|
+
createConditionalFormattingRule() {
|
|
775
|
+
return new E();
|
|
776
|
+
}
|
|
777
|
+
addConditionalFormattingRule(e) {
|
|
778
|
+
const t = {
|
|
779
|
+
rule: e,
|
|
780
|
+
unitId: this._workbook.getUnitId(),
|
|
781
|
+
subUnitId: this._worksheet.getSheetId()
|
|
782
|
+
};
|
|
783
|
+
return this._commandService.executeCommand(x.id, t);
|
|
784
|
+
}
|
|
785
|
+
deleteConditionalFormattingRule(e) {
|
|
786
|
+
const t = {
|
|
787
|
+
unitId: this._workbook.getUnitId(),
|
|
788
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
789
|
+
cfId: e
|
|
790
|
+
};
|
|
791
|
+
return this._commandService.executeCommand(S.id, t);
|
|
792
|
+
}
|
|
793
|
+
moveConditionalFormattingRule(e, t, r = "after") {
|
|
794
|
+
const s = {
|
|
795
|
+
unitId: this._workbook.getUnitId(),
|
|
796
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
797
|
+
start: { id: e, type: "self" },
|
|
798
|
+
end: { id: t, type: r }
|
|
799
|
+
};
|
|
800
|
+
return this._commandService.executeCommand(I.id, s);
|
|
801
|
+
}
|
|
802
|
+
setConditionalFormattingRule(e, t) {
|
|
803
|
+
const r = {
|
|
804
|
+
unitId: this._workbook.getUnitId(),
|
|
805
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
806
|
+
rule: t,
|
|
807
|
+
cfId: e
|
|
808
|
+
};
|
|
809
|
+
return this._commandService.executeCommand(v.id, r);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
R.extend(V);
|
|
813
|
+
export {
|
|
814
|
+
E as FConditionalFormattingBuilder
|
|
815
|
+
};
|