@univerjs/sheets-conditional-formatting 1.4.0 → 1.5.1
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/README.md +6 -5
- package/lib/cjs/facade.js +9 -9
- package/lib/cjs/index.js +237 -49
- package/lib/es/facade.js +9 -9
- package/lib/es/index.js +238 -50
- package/lib/facade.js +9 -9
- package/lib/index.js +238 -50
- package/lib/types/render/conditional-formatting-raster-cache.d.ts +24 -0
- package/lib/types/render/data-bar.render.d.ts +4 -1
- package/lib/types/render/icon.render.d.ts +5 -1
- package/lib/types/render/resolve-render-ranges.d.ts +18 -0
- package/lib/types/services/conditional-formatting-range-transform.service.d.ts +7 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutatio
|
|
|
3
3
|
import { BehaviorSubject, Subject } from "rxjs";
|
|
4
4
|
import { BooleanValue, ERROR_TYPE_SET, FormulaResultStatus, OtherFormulaBizType, RegisterOtherFormulaService, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
|
|
5
5
|
import { bufferTime, distinctUntilChanged, filter, map } from "rxjs/operators";
|
|
6
|
-
import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension, SpreadsheetExtensionRegistry, isObject } from "@univerjs/engine-render";
|
|
6
|
+
import { FIX_ONE_PIXEL_BLUR_OFFSET, SheetExtension, SpreadsheetExtensionRegistry, UniverRenderingContext, isObject } from "@univerjs/engine-render";
|
|
7
7
|
|
|
8
8
|
// src/base/const.ts
|
|
9
9
|
const SHEET_CONDITIONAL_FORMATTING_PLUGIN = "SHEET_CONDITIONAL_FORMATTING_PLUGIN";
|
|
@@ -215,7 +215,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
|
|
|
215
215
|
*/
|
|
216
216
|
const createCfId = () => `${generateRandomId(8)}`;
|
|
217
217
|
|
|
218
|
-
// \0@oxc-project+runtime@0.
|
|
218
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
219
219
|
function _typeof(o) {
|
|
220
220
|
"@babel/helpers - typeof";
|
|
221
221
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -225,25 +225,25 @@ function _typeof(o) {
|
|
|
225
225
|
}, _typeof(o);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
// \0@oxc-project+runtime@0.
|
|
229
|
-
function toPrimitive(t,
|
|
228
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
229
|
+
function toPrimitive(t, e) {
|
|
230
230
|
if ("object" != _typeof(t) || !t) return t;
|
|
231
|
-
var
|
|
232
|
-
if (void 0 !==
|
|
233
|
-
var i =
|
|
231
|
+
var r;
|
|
232
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
233
|
+
var i = r.call(t, e || "default");
|
|
234
234
|
if ("object" != _typeof(i)) return i;
|
|
235
235
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
236
236
|
}
|
|
237
|
-
return ("string" ===
|
|
237
|
+
return ("string" === e ? String : Number)(t);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
// \0@oxc-project+runtime@0.
|
|
240
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
241
241
|
function toPropertyKey(t) {
|
|
242
242
|
var i = toPrimitive(t, "string");
|
|
243
243
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
// \0@oxc-project+runtime@0.
|
|
246
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
247
247
|
function _defineProperty(e, r, t) {
|
|
248
248
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
249
249
|
value: t,
|
|
@@ -499,14 +499,14 @@ const AddCfCommand = {
|
|
|
499
499
|
}
|
|
500
500
|
};
|
|
501
501
|
|
|
502
|
-
// \0@oxc-project+runtime@0.
|
|
502
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
503
503
|
function __decorateParam(paramIndex, decorator) {
|
|
504
504
|
return function(target, key) {
|
|
505
505
|
decorator(target, key, paramIndex);
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
// \0@oxc-project+runtime@0.
|
|
509
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
510
510
|
function __decorate(decorators, target, key, desc) {
|
|
511
511
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
512
512
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -603,14 +603,15 @@ ConditionalFormattingRangeIndexModel = __decorate([__decorateParam(0, Inject(Con
|
|
|
603
603
|
// src/services/conditional-formatting-range-transform.service.ts
|
|
604
604
|
var ConditionalFormattingRangeTransformService = class {
|
|
605
605
|
subtractRanges(sourceRanges, rangesToSubtract) {
|
|
606
|
-
return Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract));
|
|
606
|
+
return this._keepCoveredRangeType(Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract)), sourceRanges);
|
|
607
607
|
}
|
|
608
608
|
addRanges(sourceRanges, rangesToAdd) {
|
|
609
|
-
return Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]);
|
|
609
|
+
return this._keepCoveredRangeType(Rectangle.mergeRanges([...sourceRanges, ...rangesToAdd]), sourceRanges);
|
|
610
610
|
}
|
|
611
611
|
applyRangeDelta(sourceRanges, rangesToSubtract, rangesToAdd) {
|
|
612
|
-
const ranges = rangesToSubtract.length ?
|
|
613
|
-
|
|
612
|
+
const ranges = rangesToSubtract.length ? Rectangle.mergeRanges(Rectangle.subtractMulti(sourceRanges, rangesToSubtract)) : sourceRanges;
|
|
613
|
+
const merged = rangesToAdd.length ? Rectangle.mergeRanges([...ranges, ...rangesToAdd]) : ranges;
|
|
614
|
+
return this._keepCoveredRangeType(merged, sourceRanges);
|
|
614
615
|
}
|
|
615
616
|
copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
|
|
616
617
|
const fragments = [];
|
|
@@ -632,6 +633,21 @@ var ConditionalFormattingRangeTransformService = class {
|
|
|
632
633
|
endColumn: range.endColumn + offset.col
|
|
633
634
|
};
|
|
634
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* Rebuilding ranges from coordinates drops `rangeType`. A result range that still covers exactly
|
|
638
|
+
* the same cells as a whole column/row source has to keep that type, otherwise a rule that was
|
|
639
|
+
* not actually changed (for example adding an already covered range) degrades to concrete rows.
|
|
640
|
+
* Results that no longer match a source range are genuine partial coverage and stay concrete.
|
|
641
|
+
*/
|
|
642
|
+
_keepCoveredRangeType(ranges, sourceRanges) {
|
|
643
|
+
return ranges.map((range) => {
|
|
644
|
+
const source = sourceRanges.find((item) => item.rangeType && item.startRow === range.startRow && item.endRow === range.endRow && item.startColumn === range.startColumn && item.endColumn === range.endColumn);
|
|
645
|
+
return source ? {
|
|
646
|
+
...range,
|
|
647
|
+
rangeType: source.rangeType
|
|
648
|
+
} : range;
|
|
649
|
+
});
|
|
650
|
+
}
|
|
635
651
|
};
|
|
636
652
|
|
|
637
653
|
// src/commands/mutations/set-conditional-rule.mutation.ts
|
|
@@ -1199,6 +1215,154 @@ var ColorScaleCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1199
1215
|
}
|
|
1200
1216
|
};
|
|
1201
1217
|
|
|
1218
|
+
// src/render/conditional-formatting-raster-cache.ts
|
|
1219
|
+
/**
|
|
1220
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1221
|
+
*
|
|
1222
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1223
|
+
* you may not use this file except in compliance with the License.
|
|
1224
|
+
* You may obtain a copy of the License at
|
|
1225
|
+
*
|
|
1226
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1227
|
+
*
|
|
1228
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1229
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1230
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1231
|
+
* See the License for the specific language governing permissions and
|
|
1232
|
+
* limitations under the License.
|
|
1233
|
+
*/
|
|
1234
|
+
const MAX_ENTRIES = 128;
|
|
1235
|
+
const MAX_PIXELS = 524288;
|
|
1236
|
+
const MAX_BITMAP_PIXELS = 131072;
|
|
1237
|
+
/** Retain physical pixels without mutating image sources already submitted to the destination. */
|
|
1238
|
+
var ConditionalFormattingRasterCache = class extends Disposable {
|
|
1239
|
+
constructor(..._args) {
|
|
1240
|
+
super(..._args);
|
|
1241
|
+
_defineProperty(this, "_bitmaps", /* @__PURE__ */ new Map());
|
|
1242
|
+
_defineProperty(this, "_pixels", 0);
|
|
1243
|
+
}
|
|
1244
|
+
draw(ctx, x, y, width, height, variant, draw, strokeWidth = 0) {
|
|
1245
|
+
var _native$getContextAtt;
|
|
1246
|
+
this.ensureNotDisposed();
|
|
1247
|
+
const native = ctx._context;
|
|
1248
|
+
const m = native === null || native === void 0 ? void 0 : native.getTransform();
|
|
1249
|
+
const colorSpace = native === null || native === void 0 || (_native$getContextAtt = native.getContextAttributes) === null || _native$getContextAtt === void 0 || (_native$getContextAtt = _native$getContextAtt.call(native)) === null || _native$getContextAtt === void 0 ? void 0 : _native$getContextAtt.colorSpace;
|
|
1250
|
+
if (!m || ctx.__mode === "printing" || typeof document === "undefined" || m.a !== m.d || m.a <= 0 || m.b || m.c || native.globalAlpha !== 1 || native.globalCompositeOperation !== "source-over" || colorSpace && colorSpace !== "srgb" || native.shadowBlur || native.shadowOffsetX || native.shadowOffsetY || ![
|
|
1251
|
+
"rgba(0, 0, 0, 0)",
|
|
1252
|
+
"transparent",
|
|
1253
|
+
"#00000000"
|
|
1254
|
+
].includes(native.shadowColor) || native.filter && native.filter !== "none" || width <= 0 || height <= 0 || typeof native.fillStyle !== "string" || typeof native.strokeStyle !== "string") {
|
|
1255
|
+
draw(ctx, x, y);
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
const px = x * m.a + m.e;
|
|
1259
|
+
const py = y * m.d + m.f;
|
|
1260
|
+
const padding = Math.max(2, Math.ceil(strokeWidth * m.a / 2) + 1);
|
|
1261
|
+
const left = Math.floor(px) - padding;
|
|
1262
|
+
const top = Math.floor(py) - padding;
|
|
1263
|
+
const pixelWidth = Math.ceil(px + width * m.a) - left + padding;
|
|
1264
|
+
const pixelHeight = Math.ceil(py + height * m.d) - top + padding;
|
|
1265
|
+
const pixels = pixelWidth * pixelHeight;
|
|
1266
|
+
if (!Number.isFinite(pixels) || pixels > MAX_BITMAP_PIXELS) {
|
|
1267
|
+
draw(ctx, x, y);
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
const localX = px - left;
|
|
1271
|
+
const localY = py - top;
|
|
1272
|
+
const dash = native.getLineDash();
|
|
1273
|
+
const key = JSON.stringify([
|
|
1274
|
+
variant,
|
|
1275
|
+
width,
|
|
1276
|
+
height,
|
|
1277
|
+
m.a,
|
|
1278
|
+
localX,
|
|
1279
|
+
localY,
|
|
1280
|
+
strokeWidth,
|
|
1281
|
+
native.fillStyle,
|
|
1282
|
+
native.strokeStyle,
|
|
1283
|
+
dash,
|
|
1284
|
+
native.lineDashOffset,
|
|
1285
|
+
native.lineCap,
|
|
1286
|
+
native.lineJoin,
|
|
1287
|
+
native.miterLimit,
|
|
1288
|
+
native.imageSmoothingEnabled,
|
|
1289
|
+
native.imageSmoothingQuality
|
|
1290
|
+
]);
|
|
1291
|
+
let bitmap = this._bitmaps.get(key);
|
|
1292
|
+
if (!bitmap) {
|
|
1293
|
+
const canvas = document.createElement("canvas");
|
|
1294
|
+
canvas.width = pixelWidth;
|
|
1295
|
+
canvas.height = pixelHeight;
|
|
1296
|
+
const context = canvas.getContext("2d");
|
|
1297
|
+
if (!context) {
|
|
1298
|
+
draw(ctx, x, y);
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const paint = new UniverRenderingContext(context);
|
|
1302
|
+
paint.setTransform(m.a, 0, 0, m.d, localX, localY);
|
|
1303
|
+
paint.setLineDash(dash);
|
|
1304
|
+
paint.lineDashOffset = native.lineDashOffset;
|
|
1305
|
+
paint.lineCap = native.lineCap;
|
|
1306
|
+
paint.lineJoin = native.lineJoin;
|
|
1307
|
+
paint.miterLimit = native.miterLimit;
|
|
1308
|
+
paint.imageSmoothingEnabled = native.imageSmoothingEnabled;
|
|
1309
|
+
paint.imageSmoothingQuality = native.imageSmoothingQuality;
|
|
1310
|
+
draw(paint, 0, 0);
|
|
1311
|
+
while (this._bitmaps.size >= MAX_ENTRIES || this._pixels + pixels > MAX_PIXELS) {
|
|
1312
|
+
const oldestKey = this._bitmaps.keys().next().value;
|
|
1313
|
+
if (oldestKey === void 0) break;
|
|
1314
|
+
this._pixels -= this._bitmaps.get(oldestKey).pixels;
|
|
1315
|
+
this._bitmaps.delete(oldestKey);
|
|
1316
|
+
}
|
|
1317
|
+
bitmap = {
|
|
1318
|
+
canvas,
|
|
1319
|
+
pixels
|
|
1320
|
+
};
|
|
1321
|
+
this._bitmaps.set(key, bitmap);
|
|
1322
|
+
this._pixels += pixels;
|
|
1323
|
+
}
|
|
1324
|
+
ctx.save();
|
|
1325
|
+
try {
|
|
1326
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1327
|
+
ctx.imageSmoothingEnabled = false;
|
|
1328
|
+
ctx.drawImage(bitmap.canvas, left, top);
|
|
1329
|
+
} finally {
|
|
1330
|
+
ctx.restore();
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
dispose() {
|
|
1334
|
+
for (const { canvas } of this._bitmaps.values()) {
|
|
1335
|
+
canvas.width = 0;
|
|
1336
|
+
canvas.height = 0;
|
|
1337
|
+
}
|
|
1338
|
+
this._bitmaps.clear();
|
|
1339
|
+
this._pixels = 0;
|
|
1340
|
+
super.dispose();
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
// src/render/resolve-render-ranges.ts
|
|
1345
|
+
function resolveRenderRanges(worksheet, sourceRanges, resolver) {
|
|
1346
|
+
if (!resolver) return sourceRanges;
|
|
1347
|
+
const mergedRanges = worksheet.getMergeData().length ? sourceRanges.flatMap((range) => worksheet.getMergedCellRange(range.startRow, range.startColumn, range.endRow, range.endColumn)) : [];
|
|
1348
|
+
const queryRanges = mergedRanges.length ? [...sourceRanges, ...mergedRanges.map((range) => ({
|
|
1349
|
+
startRow: range.startRow,
|
|
1350
|
+
endRow: range.startRow,
|
|
1351
|
+
startColumn: range.startColumn,
|
|
1352
|
+
endColumn: range.startColumn
|
|
1353
|
+
}))] : sourceRanges;
|
|
1354
|
+
const resolved = resolver(worksheet.getUnitId(), worksheet.getSheetId(), queryRanges);
|
|
1355
|
+
if (!resolved) return sourceRanges;
|
|
1356
|
+
if (!mergedRanges.length || !resolved.length) return resolved;
|
|
1357
|
+
const formattedMerges = mergedRanges.filter((merge) => resolved.some((range) => Rectangle.intersects(merge, range)));
|
|
1358
|
+
const clipped = [];
|
|
1359
|
+
for (const source of sourceRanges) for (const range of [...resolved, ...formattedMerges]) {
|
|
1360
|
+
const intersection = getIntersectRange(source, range);
|
|
1361
|
+
if (intersection) clipped.push(intersection);
|
|
1362
|
+
}
|
|
1363
|
+
return clipped.length > 1 ? Rectangle.mergeRanges(clipped) : clipped;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1202
1366
|
// src/render/data-bar.render.ts
|
|
1203
1367
|
const dataBarUKey = "sheet-conditional-rule-data-bar";
|
|
1204
1368
|
const defaultDataBarPositiveColor = "#ffbe38";
|
|
@@ -1209,11 +1373,13 @@ const stringifyRange$1 = (range) => {
|
|
|
1209
1373
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
1210
1374
|
return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
|
|
1211
1375
|
};
|
|
1212
|
-
var DataBar = class extends SheetExtension {
|
|
1376
|
+
var DataBar = class DataBar extends SheetExtension {
|
|
1213
1377
|
constructor(..._args) {
|
|
1214
1378
|
super(..._args);
|
|
1379
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === DataBar);
|
|
1215
1380
|
_defineProperty(this, "_paddingRightAndLeft", 2);
|
|
1216
1381
|
_defineProperty(this, "_paddingTopAndBottom", 2);
|
|
1382
|
+
_defineProperty(this, "_rasterCache", new ConditionalFormattingRasterCache());
|
|
1217
1383
|
_defineProperty(this, "_renderRangeResolver", null);
|
|
1218
1384
|
_defineProperty(this, "uKey", dataBarUKey);
|
|
1219
1385
|
_defineProperty(this, "Z_INDEX", EXTENSION_Z_INDEX$1);
|
|
@@ -1227,7 +1393,7 @@ var DataBar = class extends SheetExtension {
|
|
|
1227
1393
|
if (!worksheet) return false;
|
|
1228
1394
|
const mergeCellRendered = /* @__PURE__ */ new Set();
|
|
1229
1395
|
const sourceRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [spreadsheetSkeleton.rowColumnSegment];
|
|
1230
|
-
const renderRanges =
|
|
1396
|
+
const renderRanges = resolveRenderRanges(worksheet, sourceRanges, this._renderRangeResolver);
|
|
1231
1397
|
if (!renderRanges.length) return;
|
|
1232
1398
|
ctx.save();
|
|
1233
1399
|
renderRanges.forEach((range) => {
|
|
@@ -1250,43 +1416,42 @@ var DataBar = class extends SheetExtension {
|
|
|
1250
1416
|
const borderHeight = endY + FIX_ONE_PIXEL_BLUR_OFFSET - startY;
|
|
1251
1417
|
const width = borderWidth - this._paddingRightAndLeft * 2;
|
|
1252
1418
|
const height = borderHeight - this._paddingTopAndBottom * 2;
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1419
|
+
const positive = value > 0;
|
|
1420
|
+
const dataBarWidth = Math.max(positive ? width * (1 - startPoint / 100) * value / 100 : width * startPoint / 100 * Math.abs(value) / 100, 1);
|
|
1421
|
+
const x0 = startX + this._paddingRightAndLeft + startPoint / 100 * width - (positive ? 0 : dataBarWidth);
|
|
1422
|
+
const y0 = startY + this._paddingTopAndBottom;
|
|
1423
|
+
ctx.fillStyle = color;
|
|
1424
|
+
ctx.strokeStyle = color;
|
|
1425
|
+
const fillColor = ctx.fillStyle;
|
|
1426
|
+
const strokeColor = ctx.strokeStyle;
|
|
1427
|
+
this._drawAtLocalOrigin(ctx, x0, y0, dataBarWidth, height, (paint, x, y) => {
|
|
1257
1428
|
if (isGradient) {
|
|
1258
|
-
const gradient =
|
|
1259
|
-
gradient.addColorStop(0, color);
|
|
1260
|
-
gradient.addColorStop(1, "rgb(255 255 255)");
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
} else
|
|
1265
|
-
this._drawRectWithRoundedCorner(
|
|
1266
|
-
if (isGradient)
|
|
1267
|
-
}
|
|
1268
|
-
const dataBarWidth = Math.max(width * startPoint / 100 * Math.abs(value) / 100, 1);
|
|
1269
|
-
const x0 = startX + this._paddingRightAndLeft + startPoint / 100 * width - dataBarWidth;
|
|
1270
|
-
const y0 = startY + this._paddingTopAndBottom;
|
|
1271
|
-
if (isGradient) {
|
|
1272
|
-
const gradient = ctx.createLinearGradient(x0, y0, x0 + dataBarWidth, y0);
|
|
1273
|
-
gradient.addColorStop(0, "rgb(255 255 255)");
|
|
1274
|
-
gradient.addColorStop(1, color);
|
|
1275
|
-
ctx.fillStyle = gradient;
|
|
1276
|
-
ctx.strokeStyle = color;
|
|
1277
|
-
ctx.lineWidth = 1;
|
|
1278
|
-
} else ctx.fillStyle = color;
|
|
1279
|
-
this._drawRectWithRoundedCorner(ctx, x0, y0, dataBarWidth, height, true, false, false, true);
|
|
1280
|
-
if (isGradient) ctx.stroke();
|
|
1281
|
-
}
|
|
1429
|
+
const gradient = paint.createLinearGradient(x, y, x + dataBarWidth, y);
|
|
1430
|
+
gradient.addColorStop(0, positive ? color : "rgb(255 255 255)");
|
|
1431
|
+
gradient.addColorStop(1, positive ? "rgb(255 255 255)" : color);
|
|
1432
|
+
paint.fillStyle = gradient;
|
|
1433
|
+
paint.strokeStyle = paint === ctx ? color : strokeColor;
|
|
1434
|
+
paint.lineWidth = 1;
|
|
1435
|
+
} else paint.fillStyle = paint === ctx ? color : fillColor;
|
|
1436
|
+
this._drawRectWithRoundedCorner(paint, x, y, dataBarWidth, height, !positive, positive, positive, !positive);
|
|
1437
|
+
if (isGradient) paint.stroke();
|
|
1438
|
+
}, `${positive}:${isGradient}:${this._radius}:${color}`, isGradient ? 1 : 0);
|
|
1282
1439
|
});
|
|
1283
1440
|
});
|
|
1284
1441
|
ctx.restore();
|
|
1285
1442
|
}
|
|
1286
1443
|
dispose() {
|
|
1444
|
+
this._rasterCache.dispose();
|
|
1287
1445
|
this._renderRangeResolver = null;
|
|
1288
1446
|
super.dispose();
|
|
1289
1447
|
}
|
|
1448
|
+
_drawAtLocalOrigin(ctx, x, y, width, height, draw, variant = "", strokeWidth = 0) {
|
|
1449
|
+
if (typeof navigator !== "undefined" && (ctx.getBrowserType() === "Safari" || Tools.isIPhone())) {
|
|
1450
|
+
draw(ctx, x, y);
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
this._rasterCache.draw(ctx, x, y, width, height, variant, draw, strokeWidth);
|
|
1454
|
+
}
|
|
1290
1455
|
_drawRectWithRoundedCorner(ctx, x, y, width, height, topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius) {
|
|
1291
1456
|
const radius = this._radius;
|
|
1292
1457
|
if (!height || !width) return;
|
|
@@ -2543,7 +2708,7 @@ for (const key in iconMap) {
|
|
|
2543
2708
|
|
|
2544
2709
|
// package.json
|
|
2545
2710
|
var name = "@univerjs/sheets-conditional-formatting";
|
|
2546
|
-
var version = "1.
|
|
2711
|
+
var version = "1.5.1";
|
|
2547
2712
|
|
|
2548
2713
|
// src/config/config.ts
|
|
2549
2714
|
/**
|
|
@@ -2805,7 +2970,9 @@ let ConditionalFormattingService = class ConditionalFormattingService extends Di
|
|
|
2805
2970
|
};
|
|
2806
2971
|
switch (commandInfo.id) {
|
|
2807
2972
|
case SetRangeValuesMutation.id: {
|
|
2973
|
+
var _this$_conditionalFor;
|
|
2808
2974
|
const { subUnitId, unitId, cellValue } = commandInfo.params;
|
|
2975
|
+
if (!((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) === null || _this$_conditionalFor === void 0 ? void 0 : _this$_conditionalFor.length)) break;
|
|
2809
2976
|
const ranges = [];
|
|
2810
2977
|
new ObjectMatrix(cellValue).forValue((row, col, value) => {
|
|
2811
2978
|
if (value && Object.keys(value).some((key) => ["p", "v"].includes(key))) ranges.push({
|
|
@@ -2975,12 +3142,15 @@ const stringifyRange = (range) => {
|
|
|
2975
3142
|
const { startRow, endRow, startColumn, endColumn } = range;
|
|
2976
3143
|
return `${startRow}-${endRow}-${startColumn}-${endColumn}`;
|
|
2977
3144
|
};
|
|
2978
|
-
var ConditionalFormattingIcon = class extends SheetExtension {
|
|
3145
|
+
var ConditionalFormattingIcon = class ConditionalFormattingIcon extends SheetExtension {
|
|
2979
3146
|
constructor() {
|
|
2980
3147
|
super();
|
|
3148
|
+
_defineProperty(this, "viewportCacheReusable", this.constructor === ConditionalFormattingIcon);
|
|
2981
3149
|
_defineProperty(this, "_paddingRightAndLeft", 2);
|
|
2982
3150
|
_defineProperty(this, "_width", 15);
|
|
2983
3151
|
_defineProperty(this, "_imageMap", /* @__PURE__ */ new Map());
|
|
3152
|
+
_defineProperty(this, "_rasterCache", new ConditionalFormattingRasterCache());
|
|
3153
|
+
_defineProperty(this, "_pendingImages", /* @__PURE__ */ new Set());
|
|
2984
3154
|
_defineProperty(this, "_renderRangeResolver", null);
|
|
2985
3155
|
_defineProperty(this, "uKey", IconUKey);
|
|
2986
3156
|
_defineProperty(this, "Z_INDEX", EXTENSION_Z_INDEX);
|
|
@@ -2995,7 +3165,7 @@ var ConditionalFormattingIcon = class extends SheetExtension {
|
|
|
2995
3165
|
if (!worksheet) return false;
|
|
2996
3166
|
const mergeCellRendered = /* @__PURE__ */ new Set();
|
|
2997
3167
|
const sourceRanges = (diffRanges === null || diffRanges === void 0 ? void 0 : diffRanges.length) ? diffRanges : [spreadsheetSkeleton.rowColumnSegment];
|
|
2998
|
-
const renderRanges =
|
|
3168
|
+
const renderRanges = resolveRenderRanges(worksheet, sourceRanges, this._renderRangeResolver);
|
|
2999
3169
|
if (!renderRanges.length) return;
|
|
3000
3170
|
ctx.save();
|
|
3001
3171
|
renderRanges.forEach((range) => {
|
|
@@ -3021,22 +3191,40 @@ var ConditionalFormattingIcon = class extends SheetExtension {
|
|
|
3021
3191
|
const borderHeight = endY - startY;
|
|
3022
3192
|
if (this._width > borderHeight || this._width > borderWidth + this._paddingRightAndLeft * 2) return;
|
|
3023
3193
|
const y = (borderHeight - this._width) / 2 + startY;
|
|
3024
|
-
|
|
3194
|
+
this._drawIcon(ctx, icon, startX + this._paddingRightAndLeft, y);
|
|
3025
3195
|
});
|
|
3026
3196
|
});
|
|
3027
3197
|
ctx.restore();
|
|
3028
3198
|
}
|
|
3029
3199
|
dispose() {
|
|
3200
|
+
this._rasterCache.dispose();
|
|
3201
|
+
for (const image of this._pendingImages) image.onload = null;
|
|
3202
|
+
this._pendingImages.clear();
|
|
3203
|
+
this._imageMap.clear();
|
|
3030
3204
|
this._renderRangeResolver = null;
|
|
3031
3205
|
super.dispose();
|
|
3032
3206
|
}
|
|
3207
|
+
_drawIcon(ctx, image, x, y) {
|
|
3208
|
+
if (!ctx._context || ctx.__mode === "printing" || ctx.getSystemType() !== "Linux") {
|
|
3209
|
+
ctx.drawImage(image, x, y, this._width, this._width);
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
this._rasterCache.draw(ctx, x, y, this._width, this._width, image.src, (paint, left, top) => {
|
|
3213
|
+
paint.drawImage(image, left, top, this._width, this._width);
|
|
3214
|
+
});
|
|
3215
|
+
}
|
|
3033
3216
|
_init() {
|
|
3034
3217
|
for (const type in iconMap) iconMap[type].forEach((base64, index) => {
|
|
3035
3218
|
const key = this._createKey(type, String(index));
|
|
3036
3219
|
const image = new Image();
|
|
3037
3220
|
image.onload = () => {
|
|
3221
|
+
var _this$parent;
|
|
3222
|
+
image.onload = null;
|
|
3223
|
+
this._pendingImages.delete(image);
|
|
3038
3224
|
this._imageMap.set(key, image);
|
|
3225
|
+
(_this$parent = this.parent) === null || _this$parent === void 0 || _this$parent.makeDirty(true);
|
|
3039
3226
|
};
|
|
3227
|
+
this._pendingImages.add(image);
|
|
3040
3228
|
image.src = base64;
|
|
3041
3229
|
});
|
|
3042
3230
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Disposable } from '@univerjs/core';
|
|
17
|
+
import { UniverRenderingContext } from '@univerjs/engine-render';
|
|
18
|
+
/** Retain physical pixels without mutating image sources already submitted to the destination. */
|
|
19
|
+
export declare class ConditionalFormattingRasterCache extends Disposable {
|
|
20
|
+
private readonly _bitmaps;
|
|
21
|
+
private _pixels;
|
|
22
|
+
draw(ctx: UniverRenderingContext, x: number, y: number, width: number, height: number, variant: string, draw: (paint: UniverRenderingContext, x: number, y: number) => void, strokeWidth?: number): void;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
@@ -15,15 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IRange, IScale } from '@univerjs/core';
|
|
17
17
|
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
|
|
18
|
-
import type { IConditionalFormattingRenderRangeResolver } from './type';
|
|
19
18
|
import { SheetExtension } from '@univerjs/engine-render';
|
|
19
|
+
import type { IConditionalFormattingRenderRangeResolver } from './type';
|
|
20
20
|
export declare const dataBarUKey = "sheet-conditional-rule-data-bar";
|
|
21
21
|
export declare const defaultDataBarPositiveColor = "#ffbe38";
|
|
22
22
|
export declare const defaultDataBarNativeColor = "#abd91a";
|
|
23
23
|
export declare const defaultPlaceholderColor = "#000";
|
|
24
24
|
export declare class DataBar extends SheetExtension {
|
|
25
|
+
readonly viewportCacheReusable: boolean;
|
|
25
26
|
private _paddingRightAndLeft;
|
|
26
27
|
private _paddingTopAndBottom;
|
|
28
|
+
private readonly _rasterCache;
|
|
27
29
|
private _renderRangeResolver;
|
|
28
30
|
uKey: string;
|
|
29
31
|
Z_INDEX: number;
|
|
@@ -31,5 +33,6 @@ export declare class DataBar extends SheetExtension {
|
|
|
31
33
|
setRenderRangeResolver(resolver: IConditionalFormattingRenderRangeResolver | null): void;
|
|
32
34
|
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[]): false | undefined;
|
|
33
35
|
dispose(): void;
|
|
36
|
+
private _drawAtLocalOrigin;
|
|
34
37
|
private _drawRectWithRoundedCorner;
|
|
35
38
|
}
|
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { IRange, IScale } from '@univerjs/core';
|
|
17
17
|
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
|
|
18
|
-
import type { IConditionalFormattingRenderRangeResolver } from './type';
|
|
19
18
|
import { SheetExtension } from '@univerjs/engine-render';
|
|
19
|
+
import type { IConditionalFormattingRenderRangeResolver } from './type';
|
|
20
20
|
export declare const IconUKey = "sheet-conditional-rule-icon";
|
|
21
21
|
export declare const DEFAULT_WIDTH = 15;
|
|
22
22
|
export declare const DEFAULT_PADDING = 2;
|
|
23
23
|
export declare class ConditionalFormattingIcon extends SheetExtension {
|
|
24
|
+
readonly viewportCacheReusable: boolean;
|
|
24
25
|
private _paddingRightAndLeft;
|
|
25
26
|
private _width;
|
|
26
27
|
private _imageMap;
|
|
28
|
+
private readonly _rasterCache;
|
|
29
|
+
private readonly _pendingImages;
|
|
27
30
|
private _renderRangeResolver;
|
|
28
31
|
uKey: string;
|
|
29
32
|
Z_INDEX: number;
|
|
@@ -32,6 +35,7 @@ export declare class ConditionalFormattingIcon extends SheetExtension {
|
|
|
32
35
|
setRenderRangeResolver(resolver: IConditionalFormattingRenderRangeResolver | null): void;
|
|
33
36
|
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[]): false | undefined;
|
|
34
37
|
dispose(): void;
|
|
38
|
+
private _drawIcon;
|
|
35
39
|
private _init;
|
|
36
40
|
private _createKey;
|
|
37
41
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { IRange, Worksheet } from '@univerjs/core';
|
|
17
|
+
import type { IConditionalFormattingRenderRangeResolver } from './type';
|
|
18
|
+
export declare function resolveRenderRanges(worksheet: Worksheet, sourceRanges: IRange[], resolver: IConditionalFormattingRenderRangeResolver | null): IRange[];
|
|
@@ -24,4 +24,11 @@ export declare class ConditionalFormattingRangeTransformService {
|
|
|
24
24
|
applyRangeDelta(sourceRanges: IRange[], rangesToSubtract: IRange[], rangesToAdd: IRange[]): IRange[];
|
|
25
25
|
copyIntersectingRanges(sourceRanges: IRange[], sourceRange: IRange, targetAnchor: IRangeAnchor): IRange[];
|
|
26
26
|
translateRange(range: IRange, offset: IRangeAnchor): IRange;
|
|
27
|
+
/**
|
|
28
|
+
* Rebuilding ranges from coordinates drops `rangeType`. A result range that still covers exactly
|
|
29
|
+
* the same cells as a whole column/row source has to keep that type, otherwise a rule that was
|
|
30
|
+
* not actually changed (for example adding an already covered range) degrades to concrete rows.
|
|
31
|
+
* Results that no longer match a source range are genuine partial coverage and stay concrete.
|
|
32
|
+
*/
|
|
33
|
+
private _keepCoveredRangeType;
|
|
27
34
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell){if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg}return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell){if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl}return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell){if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg}return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell){if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl}return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&=(0,n.createCfId)(),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|