@univerjs/sheets-conditional-formatting 1.0.0-rc.0 → 1.0.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/lib/cjs/facade.js +18 -14
- package/lib/cjs/index.js +104 -59
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/facade.js +18 -14
- package/lib/es/index.js +104 -59
- package/lib/facade.js +18 -14
- package/lib/index.js +104 -59
- package/lib/types/services/conditional-formatting-formula.service.d.ts +3 -2
- package/lib/types/utils/range.d.ts +18 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/cjs/facade.js
CHANGED
|
@@ -4,7 +4,7 @@ let _univerjs_sheets_conditional_formatting = require("@univerjs/sheets-conditio
|
|
|
4
4
|
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
5
5
|
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
6
6
|
|
|
7
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -410,11 +410,13 @@ var ConditionalFormatHighlightRuleBuilder = class ConditionalFormatHighlightRule
|
|
|
410
410
|
*/
|
|
411
411
|
setBackground(color) {
|
|
412
412
|
var _this$_ruleConfig;
|
|
413
|
-
if (((_this$_ruleConfig = this._ruleConfig) === null || _this$_ruleConfig === void 0 ? void 0 : _this$_ruleConfig.type) === _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
413
|
+
if (((_this$_ruleConfig = this._ruleConfig) === null || _this$_ruleConfig === void 0 ? void 0 : _this$_ruleConfig.type) === _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell) {
|
|
414
|
+
if (color) {
|
|
415
|
+
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
416
|
+
const colorKit = new _univerjs_core.ColorKit(color);
|
|
417
|
+
this._ruleConfig.style.bg.rgb = colorKit.toRgbString();
|
|
418
|
+
} else delete this._ruleConfig.style.bg;
|
|
419
|
+
}
|
|
418
420
|
return this;
|
|
419
421
|
}
|
|
420
422
|
/**
|
|
@@ -467,11 +469,13 @@ var ConditionalFormatHighlightRuleBuilder = class ConditionalFormatHighlightRule
|
|
|
467
469
|
*/
|
|
468
470
|
setFontColor(color) {
|
|
469
471
|
var _this$_ruleConfig3;
|
|
470
|
-
if (((_this$_ruleConfig3 = this._ruleConfig) === null || _this$_ruleConfig3 === void 0 ? void 0 : _this$_ruleConfig3.type) === _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell)
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
if (((_this$_ruleConfig3 = this._ruleConfig) === null || _this$_ruleConfig3 === void 0 ? void 0 : _this$_ruleConfig3.type) === _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell) {
|
|
473
|
+
if (color) {
|
|
474
|
+
const colorKit = new _univerjs_core.ColorKit(color);
|
|
475
|
+
this._ensureAttr(this._ruleConfig, ["style", "cl"]);
|
|
476
|
+
this._ruleConfig.style.cl.rgb = colorKit.toRgbString();
|
|
477
|
+
} else delete this._ruleConfig.style.cl;
|
|
478
|
+
}
|
|
475
479
|
return this;
|
|
476
480
|
}
|
|
477
481
|
/**
|
package/lib/cjs/index.js
CHANGED
|
@@ -145,9 +145,7 @@ const moveByAnchor = (start, end, ruleList, get) => {
|
|
|
145
145
|
ruleList.splice(endIndex + 1, 0, rule);
|
|
146
146
|
break;
|
|
147
147
|
case "self":
|
|
148
|
-
case "after":
|
|
149
|
-
ruleList.splice(endIndex, 0, rule);
|
|
150
|
-
break;
|
|
148
|
+
case "after": ruleList.splice(endIndex, 0, rule);
|
|
151
149
|
}
|
|
152
150
|
};
|
|
153
151
|
/**
|
|
@@ -221,7 +219,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
|
|
|
221
219
|
const createCfId = () => `${(0, _univerjs_core.generateRandomId)(8)}`;
|
|
222
220
|
|
|
223
221
|
//#endregion
|
|
224
|
-
//#region \0@oxc-project+runtime@0.
|
|
222
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
225
223
|
function _typeof(o) {
|
|
226
224
|
"@babel/helpers - typeof";
|
|
227
225
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -232,7 +230,7 @@ function _typeof(o) {
|
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
//#endregion
|
|
235
|
-
//#region \0@oxc-project+runtime@0.
|
|
233
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
236
234
|
function toPrimitive(t, r) {
|
|
237
235
|
if ("object" != _typeof(t) || !t) return t;
|
|
238
236
|
var e = t[Symbol.toPrimitive];
|
|
@@ -245,14 +243,14 @@ function toPrimitive(t, r) {
|
|
|
245
243
|
}
|
|
246
244
|
|
|
247
245
|
//#endregion
|
|
248
|
-
//#region \0@oxc-project+runtime@0.
|
|
246
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
249
247
|
function toPropertyKey(t) {
|
|
250
248
|
var i = toPrimitive(t, "string");
|
|
251
249
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
252
250
|
}
|
|
253
251
|
|
|
254
252
|
//#endregion
|
|
255
|
-
//#region \0@oxc-project+runtime@0.
|
|
253
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
256
254
|
function _defineProperty(e, r, t) {
|
|
257
255
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
258
256
|
value: t,
|
|
@@ -486,7 +484,8 @@ const AddCfCommand = {
|
|
|
486
484
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
487
485
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
488
486
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
489
|
-
const
|
|
487
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
488
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, params);
|
|
490
489
|
if (!target) return false;
|
|
491
490
|
const { unitId, subUnitId } = target;
|
|
492
491
|
const cfId = conditionalFormattingRuleModel.createCfId(unitId, subUnitId);
|
|
@@ -513,7 +512,7 @@ const AddCfCommand = {
|
|
|
513
512
|
};
|
|
514
513
|
|
|
515
514
|
//#endregion
|
|
516
|
-
//#region \0@oxc-project+runtime@0.
|
|
515
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
517
516
|
function __decorateParam(paramIndex, decorator) {
|
|
518
517
|
return function(target, key) {
|
|
519
518
|
decorator(target, key, paramIndex);
|
|
@@ -521,7 +520,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
521
520
|
}
|
|
522
521
|
|
|
523
522
|
//#endregion
|
|
524
|
-
//#region \0@oxc-project+runtime@0.
|
|
523
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
525
524
|
function __decorate(decorators, target, key, desc) {
|
|
526
525
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
527
526
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -792,7 +791,8 @@ const DeleteCfCommand = {
|
|
|
792
791
|
if (!params) return false;
|
|
793
792
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
794
793
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
795
|
-
const
|
|
794
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
795
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, params);
|
|
796
796
|
if (!target) return false;
|
|
797
797
|
const { unitId, subUnitId } = target;
|
|
798
798
|
const config = {
|
|
@@ -860,7 +860,8 @@ const SetCfCommand = {
|
|
|
860
860
|
if (!params) return false;
|
|
861
861
|
const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
|
|
862
862
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
863
|
-
const
|
|
863
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
864
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, params);
|
|
864
865
|
if (!target) return false;
|
|
865
866
|
const { unitId, subUnitId } = target;
|
|
866
867
|
const config = {
|
|
@@ -883,13 +884,43 @@ const SetCfCommand = {
|
|
|
883
884
|
}
|
|
884
885
|
};
|
|
885
886
|
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/utils/range.ts
|
|
889
|
+
function getRangeInWorksheet(range, worksheet) {
|
|
890
|
+
const maxRows = worksheet.getMaxRows();
|
|
891
|
+
const maxColumns = worksheet.getMaxColumns();
|
|
892
|
+
if (maxRows <= 0 || maxColumns <= 0) return null;
|
|
893
|
+
const effectiveRange = (0, _univerjs_core.getIntersectRange)(_univerjs_core.Range.transformRange(range, worksheet), {
|
|
894
|
+
startRow: 0,
|
|
895
|
+
endRow: maxRows - 1,
|
|
896
|
+
startColumn: 0,
|
|
897
|
+
endColumn: maxColumns - 1
|
|
898
|
+
});
|
|
899
|
+
if (!effectiveRange) return null;
|
|
900
|
+
return {
|
|
901
|
+
startRow: effectiveRange.startRow,
|
|
902
|
+
endRow: effectiveRange.endRow,
|
|
903
|
+
startColumn: effectiveRange.startColumn,
|
|
904
|
+
endColumn: effectiveRange.endColumn
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function getRangesInWorksheet(ranges, worksheet) {
|
|
908
|
+
const effectiveRanges = [];
|
|
909
|
+
ranges.forEach((range) => {
|
|
910
|
+
const effectiveRange = getRangeInWorksheet(range, worksheet);
|
|
911
|
+
if (effectiveRange) effectiveRanges.push(effectiveRange);
|
|
912
|
+
});
|
|
913
|
+
return effectiveRanges;
|
|
914
|
+
}
|
|
915
|
+
|
|
886
916
|
//#endregion
|
|
887
917
|
//#region src/services/conditional-formatting-formula.service.ts
|
|
888
918
|
let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaService extends _univerjs_core.Disposable {
|
|
889
|
-
constructor(_registerOtherFormulaService, _conditionalFormattingRuleModel) {
|
|
919
|
+
constructor(_registerOtherFormulaService, _conditionalFormattingRuleModel, _univerInstanceService) {
|
|
890
920
|
super();
|
|
891
921
|
this._registerOtherFormulaService = _registerOtherFormulaService;
|
|
892
922
|
this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
|
|
923
|
+
this._univerInstanceService = _univerInstanceService;
|
|
893
924
|
_defineProperty(this, "_formulaMap", /* @__PURE__ */ new Map());
|
|
894
925
|
_defineProperty(this, "_result$", new rxjs.Subject());
|
|
895
926
|
_defineProperty(this, "result$", this._result$.asObservable());
|
|
@@ -918,12 +949,10 @@ let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaServ
|
|
|
918
949
|
*/
|
|
919
950
|
_registerRuleFormulas(unitId, subUnitId, rule) {
|
|
920
951
|
switch (rule.rule.type) {
|
|
921
|
-
case "highlightCell":
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}
|
|
926
|
-
break;
|
|
952
|
+
case "highlightCell": if (rule.rule.subType === "formula") {
|
|
953
|
+
const formulaText = rule.rule.value;
|
|
954
|
+
if (formulaText) this.registerFormulaWithRange(unitId, subUnitId, rule.cfId, formulaText, rule.ranges);
|
|
955
|
+
}
|
|
927
956
|
}
|
|
928
957
|
}
|
|
929
958
|
_initFormulaResultChange() {
|
|
@@ -968,10 +997,15 @@ let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaServ
|
|
|
968
997
|
startColumn: 0,
|
|
969
998
|
endColumn: 0
|
|
970
999
|
}]) {
|
|
1000
|
+
var _this$_univerInstance;
|
|
971
1001
|
const formulaMap = this._ensureSubunitFormulaMap(unitId, subUnitId);
|
|
972
1002
|
const cfFormulaId = this.createCFormulaId(cfId, formulaText);
|
|
973
1003
|
if (formulaMap.getValue(cfFormulaId, ["id"])) return;
|
|
974
|
-
const
|
|
1004
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
1005
|
+
if (!worksheet) return;
|
|
1006
|
+
const effectiveRanges = getRangesInWorksheet(ranges, worksheet);
|
|
1007
|
+
if (!effectiveRanges.length) return;
|
|
1008
|
+
const sortedRanges = effectiveRanges.sort((a, b) => a.startRow !== b.startRow ? a.startRow - b.startRow : a.startColumn - b.startColumn);
|
|
975
1009
|
const formulaId = this._registerOtherFormulaService.registerFormulaWithRange(unitId, subUnitId, formulaText, sortedRanges, void 0, _univerjs_engine_formula.OtherFormulaBizType.CONDITIONAL_FORMATTING, cfId);
|
|
976
1010
|
formulaMap.addValue({
|
|
977
1011
|
formulaText,
|
|
@@ -1058,7 +1092,11 @@ let ConditionalFormattingFormulaService = class ConditionalFormattingFormulaServ
|
|
|
1058
1092
|
return `${cfId}_${formulaText}`;
|
|
1059
1093
|
}
|
|
1060
1094
|
};
|
|
1061
|
-
ConditionalFormattingFormulaService = __decorate([
|
|
1095
|
+
ConditionalFormattingFormulaService = __decorate([
|
|
1096
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_engine_formula.RegisterOtherFormulaService)),
|
|
1097
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(ConditionalFormattingRuleModel)),
|
|
1098
|
+
__decorateParam(2, _univerjs_core.IUniverInstanceService)
|
|
1099
|
+
], ConditionalFormattingFormulaService);
|
|
1062
1100
|
|
|
1063
1101
|
//#endregion
|
|
1064
1102
|
//#region src/models/calculate-unit-v2/base-calculate-unit.ts
|
|
@@ -1389,28 +1427,29 @@ var DataBarCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1389
1427
|
isGradient,
|
|
1390
1428
|
isShowValue
|
|
1391
1429
|
};
|
|
1392
|
-
} else if (min < 0 && max > 0)
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1430
|
+
} else if (min < 0 && max > 0) {
|
|
1431
|
+
if (value > 0) {
|
|
1432
|
+
const v = getSafeValue(Math.min(value / max, 1) * 100);
|
|
1433
|
+
if (v === 0) return;
|
|
1434
|
+
return {
|
|
1435
|
+
color: ruleConfig.config.positiveColor || "#ffbe38",
|
|
1436
|
+
startPoint,
|
|
1437
|
+
value: v,
|
|
1438
|
+
isGradient,
|
|
1439
|
+
isShowValue
|
|
1440
|
+
};
|
|
1441
|
+
} else {
|
|
1442
|
+
const v = getSafeValue(Math.min(Math.abs(value) / Math.abs(min), 1) * 100);
|
|
1443
|
+
if (v === 0) return;
|
|
1444
|
+
return {
|
|
1445
|
+
color: ruleConfig.config.nativeColor || "#abd91a",
|
|
1446
|
+
startPoint,
|
|
1447
|
+
value: -v,
|
|
1448
|
+
isGradient,
|
|
1449
|
+
isShowValue
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
} else if (min >= 0 && max > 0) {
|
|
1414
1453
|
const length = max - min;
|
|
1415
1454
|
const startPoint = 0;
|
|
1416
1455
|
const v = getSafeValue((1 - (max - value) / length) * 100);
|
|
@@ -1462,7 +1501,8 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1462
1501
|
const cacheMap = /* @__PURE__ */ new Map();
|
|
1463
1502
|
ranges.forEach((range) => {
|
|
1464
1503
|
_univerjs_core.Range.foreach(range, (row, col) => {
|
|
1465
|
-
const
|
|
1504
|
+
const cell = context.getCellValue(row, col);
|
|
1505
|
+
const v = getCellValue(cell);
|
|
1466
1506
|
if (!isNullable(v)) {
|
|
1467
1507
|
const cache = cacheMap.get(v);
|
|
1468
1508
|
if (cache) cacheMap.set(v, cache + 1);
|
|
@@ -1604,18 +1644,19 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1604
1644
|
const run = () => {
|
|
1605
1645
|
switch (ruleConfig.subType) {
|
|
1606
1646
|
case "number": {
|
|
1607
|
-
const v = cellValue && Number(cellValue.v);
|
|
1608
|
-
const isNumber = (cellValue === null || cellValue === void 0 ? void 0 : cellValue.t) === _univerjs_core.CellValueType.NUMBER;
|
|
1609
1647
|
const subRuleConfig = ruleConfig;
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1648
|
+
const value = cellValue === null || cellValue === void 0 ? void 0 : cellValue.v;
|
|
1649
|
+
if ((cellValue === null || cellValue === void 0 ? void 0 : cellValue.t) !== _univerjs_core.CellValueType.FORCE_STRING && _univerjs_engine_formula.ERROR_TYPE_SET.has(value)) return false;
|
|
1650
|
+
if (value != null && ((cellValue === null || cellValue === void 0 ? void 0 : cellValue.t) === _univerjs_core.CellValueType.BOOLEAN || (cellValue === null || cellValue === void 0 ? void 0 : cellValue.t) !== _univerjs_core.CellValueType.NUMBER && typeof value !== "number")) return [
|
|
1651
|
+
"notEqual",
|
|
1652
|
+
"notBetween",
|
|
1653
|
+
"greaterThan",
|
|
1654
|
+
"greaterThanOrEqual"
|
|
1655
|
+
].includes(subRuleConfig.operator);
|
|
1615
1656
|
return compareWithNumber({
|
|
1616
1657
|
operator: subRuleConfig.operator,
|
|
1617
|
-
value: subRuleConfig.value
|
|
1618
|
-
},
|
|
1658
|
+
value: subRuleConfig.value ?? 0
|
|
1659
|
+
}, Number(value ?? 0));
|
|
1619
1660
|
}
|
|
1620
1661
|
case "text": {
|
|
1621
1662
|
const subRuleConfig = ruleConfig;
|
|
@@ -1798,7 +1839,7 @@ var IconSetCalculateUnit = class extends BaseCalculateUnit {
|
|
|
1798
1839
|
|
|
1799
1840
|
//#endregion
|
|
1800
1841
|
//#region src/models/conditional-formatting-view-model.ts
|
|
1801
|
-
const CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH =
|
|
1842
|
+
const CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH = 9e3;
|
|
1802
1843
|
let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extends _univerjs_core.Disposable {
|
|
1803
1844
|
constructor(_injector, _conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel, _conditionalFormattingFormulaService, _univerInstanceService) {
|
|
1804
1845
|
super();
|
|
@@ -2091,7 +2132,7 @@ const getCacheStyleMatrix = (unitId, subUnitId, rule, context) => {
|
|
|
2091
2132
|
const { accessor } = context;
|
|
2092
2133
|
const conditionalFormattingViewModel = accessor.get(ConditionalFormattingViewModel);
|
|
2093
2134
|
const matrix = new _univerjs_core.ObjectMatrix();
|
|
2094
|
-
rule.ranges.forEach((range) => {
|
|
2135
|
+
getRangesInWorksheet(rule.ranges, context.worksheet).forEach((range) => {
|
|
2095
2136
|
_univerjs_core.Range.foreach(range, (row, col) => {
|
|
2096
2137
|
const cellCfItem = conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
|
|
2097
2138
|
if (cellCfItem) {
|
|
@@ -2153,7 +2194,7 @@ const getColorScaleFromValue = (colorList, value) => {
|
|
|
2153
2194
|
const maxRgb = prefixRgba(maxItem.color.toRgb());
|
|
2154
2195
|
const length = maxItem.value - minItem.value;
|
|
2155
2196
|
const v = (value - minItem.value) / length;
|
|
2156
|
-
|
|
2197
|
+
const rgbResult = [
|
|
2157
2198
|
"r",
|
|
2158
2199
|
"g",
|
|
2159
2200
|
"b",
|
|
@@ -2162,16 +2203,20 @@ const getColorScaleFromValue = (colorList, value) => {
|
|
|
2162
2203
|
const minV = minRgb[key];
|
|
2163
2204
|
obj[key] = (maxRgb[key] - minV) * v + minV;
|
|
2164
2205
|
return obj;
|
|
2165
|
-
}, {})
|
|
2206
|
+
}, {});
|
|
2207
|
+
return new _univerjs_core.ColorKit(rgbResult).toRgbString();
|
|
2166
2208
|
}
|
|
2167
2209
|
} else return colorList[colorList.length - 1].color.toRgbString();
|
|
2168
2210
|
};
|
|
2169
2211
|
const filterRange = (ranges, maxRow, maxCol) => {
|
|
2170
2212
|
return ranges.map((range) => {
|
|
2171
|
-
if (range.startColumn > maxCol || range.startRow > maxRow) return null;
|
|
2213
|
+
if (range.startColumn > maxCol || range.startRow > maxRow || range.endColumn < 0 || range.endRow < 0) return null;
|
|
2172
2214
|
const _range = { ...range };
|
|
2215
|
+
_range.startRow = Math.max(_range.startRow, 0);
|
|
2216
|
+
_range.startColumn = Math.max(_range.startColumn, 0);
|
|
2173
2217
|
_range.endRow = Math.min(_range.endRow, maxRow);
|
|
2174
2218
|
_range.endColumn = Math.min(_range.endColumn, maxCol);
|
|
2219
|
+
if (_range.startRow > _range.endRow || _range.startColumn > _range.endColumn) return null;
|
|
2175
2220
|
return _range;
|
|
2176
2221
|
}).filter((range) => !!range);
|
|
2177
2222
|
};
|
|
@@ -2512,7 +2557,7 @@ for (const key in iconMap) {
|
|
|
2512
2557
|
//#endregion
|
|
2513
2558
|
//#region package.json
|
|
2514
2559
|
var name = "@univerjs/sheets-conditional-formatting";
|
|
2515
|
-
var version = "1.0.
|
|
2560
|
+
var version = "1.0.1";
|
|
2516
2561
|
|
|
2517
2562
|
//#endregion
|
|
2518
2563
|
//#region src/config/config.ts
|
package/lib/cjs/locale/ar-SA.js
CHANGED
package/lib/cjs/locale/ca-ES.js
CHANGED
package/lib/cjs/locale/de-DE.js
CHANGED
package/lib/cjs/locale/en-US.js
CHANGED
package/lib/cjs/locale/es-ES.js
CHANGED
package/lib/cjs/locale/fa-IR.js
CHANGED
package/lib/cjs/locale/fr-FR.js
CHANGED
package/lib/cjs/locale/id-ID.js
CHANGED
package/lib/cjs/locale/it-IT.js
CHANGED
package/lib/cjs/locale/ja-JP.js
CHANGED
package/lib/cjs/locale/ko-KR.js
CHANGED
package/lib/cjs/locale/pl-PL.js
CHANGED
package/lib/cjs/locale/pt-BR.js
CHANGED
package/lib/cjs/locale/ru-RU.js
CHANGED
package/lib/cjs/locale/sk-SK.js
CHANGED
package/lib/cjs/locale/vi-VN.js
CHANGED
package/lib/cjs/locale/zh-CN.js
CHANGED
package/lib/cjs/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/facade.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AddCfCommand, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperat
|
|
|
3
3
|
import { FRange, FWorksheet } from "@univerjs/sheets/facade";
|
|
4
4
|
import { FEnum } from "@univerjs/core/facade";
|
|
5
5
|
|
|
6
|
-
//#region \0@oxc-project+runtime@0.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
7
7
|
function _typeof(o) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
9
9
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, r) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
38
38
|
function _defineProperty(e, r, t) {
|
|
39
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
40
|
value: t,
|
|
@@ -409,11 +409,13 @@ var ConditionalFormatHighlightRuleBuilder = class ConditionalFormatHighlightRule
|
|
|
409
409
|
*/
|
|
410
410
|
setBackground(color) {
|
|
411
411
|
var _this$_ruleConfig;
|
|
412
|
-
if (((_this$_ruleConfig = this._ruleConfig) === null || _this$_ruleConfig === void 0 ? void 0 : _this$_ruleConfig.type) === CFRuleType.highlightCell)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
412
|
+
if (((_this$_ruleConfig = this._ruleConfig) === null || _this$_ruleConfig === void 0 ? void 0 : _this$_ruleConfig.type) === CFRuleType.highlightCell) {
|
|
413
|
+
if (color) {
|
|
414
|
+
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
415
|
+
const colorKit = new ColorKit(color);
|
|
416
|
+
this._ruleConfig.style.bg.rgb = colorKit.toRgbString();
|
|
417
|
+
} else delete this._ruleConfig.style.bg;
|
|
418
|
+
}
|
|
417
419
|
return this;
|
|
418
420
|
}
|
|
419
421
|
/**
|
|
@@ -466,11 +468,13 @@ var ConditionalFormatHighlightRuleBuilder = class ConditionalFormatHighlightRule
|
|
|
466
468
|
*/
|
|
467
469
|
setFontColor(color) {
|
|
468
470
|
var _this$_ruleConfig3;
|
|
469
|
-
if (((_this$_ruleConfig3 = this._ruleConfig) === null || _this$_ruleConfig3 === void 0 ? void 0 : _this$_ruleConfig3.type) === CFRuleType.highlightCell)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
if (((_this$_ruleConfig3 = this._ruleConfig) === null || _this$_ruleConfig3 === void 0 ? void 0 : _this$_ruleConfig3.type) === CFRuleType.highlightCell) {
|
|
472
|
+
if (color) {
|
|
473
|
+
const colorKit = new ColorKit(color);
|
|
474
|
+
this._ensureAttr(this._ruleConfig, ["style", "cl"]);
|
|
475
|
+
this._ruleConfig.style.cl.rgb = colorKit.toRgbString();
|
|
476
|
+
} else delete this._ruleConfig.style.cl;
|
|
477
|
+
}
|
|
474
478
|
return this;
|
|
475
479
|
}
|
|
476
480
|
/**
|