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