@univerjs/sheets-conditional-formatting-ui 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/index.js +72 -66
- 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/index.js +72 -66
- package/lib/index.js +72 -66
- package/lib/umd/index.js +1 -1
- package/package.json +15 -15
package/lib/es/index.js
CHANGED
|
@@ -23,7 +23,8 @@ const AddAverageCfCommand = {
|
|
|
23
23
|
const { ranges, style, stopIfTrue, operator } = params;
|
|
24
24
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
25
25
|
const commandService = accessor.get(ICommandService);
|
|
26
|
-
const
|
|
26
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
27
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
27
28
|
if (!target) return false;
|
|
28
29
|
const { unitId, subUnitId } = target;
|
|
29
30
|
const rule = {
|
|
@@ -55,7 +56,8 @@ const AddColorScaleConditionalRuleCommand = {
|
|
|
55
56
|
const { ranges, config, stopIfTrue } = params;
|
|
56
57
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
57
58
|
const commandService = accessor.get(ICommandService);
|
|
58
|
-
const
|
|
59
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
60
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
59
61
|
if (!target) return false;
|
|
60
62
|
const { unitId, subUnitId } = target;
|
|
61
63
|
const rule = {
|
|
@@ -86,7 +88,8 @@ const AddDataBarConditionalRuleCommand = {
|
|
|
86
88
|
const ranges = params.ranges ?? accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
|
|
87
89
|
if (!ranges.length) return false;
|
|
88
90
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
89
|
-
const
|
|
91
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
92
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
90
93
|
if (!target) return false;
|
|
91
94
|
const { unitId, subUnitId } = target;
|
|
92
95
|
const commandService = accessor.get(ICommandService);
|
|
@@ -124,7 +127,8 @@ const AddDuplicateValuesCfCommand = {
|
|
|
124
127
|
const { ranges, style, stopIfTrue } = params;
|
|
125
128
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
126
129
|
const commandService = accessor.get(ICommandService);
|
|
127
|
-
const
|
|
130
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
131
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
128
132
|
if (!target) return false;
|
|
129
133
|
const { unitId, subUnitId } = target;
|
|
130
134
|
const rule = {
|
|
@@ -185,7 +189,8 @@ const AddNumberCfCommand = {
|
|
|
185
189
|
const { ranges, style, stopIfTrue, operator, value } = params;
|
|
186
190
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
187
191
|
const commandService = accessor.get(ICommandService);
|
|
188
|
-
const
|
|
192
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
193
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
189
194
|
if (!target) return false;
|
|
190
195
|
const { unitId, subUnitId } = target;
|
|
191
196
|
const cfId = conditionalFormattingRuleModel.createCfId(unitId, subUnitId);
|
|
@@ -273,7 +278,8 @@ const AddTextCfCommand = {
|
|
|
273
278
|
if (!params) return false;
|
|
274
279
|
const { ranges, style, stopIfTrue, operator, value } = params;
|
|
275
280
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
276
|
-
const
|
|
281
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
282
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
277
283
|
if (!target) return false;
|
|
278
284
|
const { unitId, subUnitId } = target;
|
|
279
285
|
const commandService = accessor.get(ICommandService);
|
|
@@ -382,7 +388,7 @@ const AddUniqueValuesCfCommand = {
|
|
|
382
388
|
const CF_PANEL_KEY = "sheet.conditional.formatting.panel";
|
|
383
389
|
|
|
384
390
|
//#endregion
|
|
385
|
-
//#region \0@oxc-project+runtime@0.
|
|
391
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
386
392
|
function _typeof(o) {
|
|
387
393
|
"@babel/helpers - typeof";
|
|
388
394
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -393,7 +399,7 @@ function _typeof(o) {
|
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
//#endregion
|
|
396
|
-
//#region \0@oxc-project+runtime@0.
|
|
402
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
397
403
|
function toPrimitive(t, r) {
|
|
398
404
|
if ("object" != _typeof(t) || !t) return t;
|
|
399
405
|
var e = t[Symbol.toPrimitive];
|
|
@@ -406,14 +412,14 @@ function toPrimitive(t, r) {
|
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
//#endregion
|
|
409
|
-
//#region \0@oxc-project+runtime@0.
|
|
415
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
410
416
|
function toPropertyKey(t) {
|
|
411
417
|
var i = toPrimitive(t, "string");
|
|
412
418
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
413
419
|
}
|
|
414
420
|
|
|
415
421
|
//#endregion
|
|
416
|
-
//#region \0@oxc-project+runtime@0.
|
|
422
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
417
423
|
function _defineProperty(e, r, t) {
|
|
418
424
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
419
425
|
value: t,
|
|
@@ -424,7 +430,7 @@ function _defineProperty(e, r, t) {
|
|
|
424
430
|
}
|
|
425
431
|
|
|
426
432
|
//#endregion
|
|
427
|
-
//#region \0@oxc-project+runtime@0.
|
|
433
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
428
434
|
function __decorateParam(paramIndex, decorator) {
|
|
429
435
|
return function(target, key) {
|
|
430
436
|
decorator(target, key, paramIndex);
|
|
@@ -432,7 +438,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
432
438
|
}
|
|
433
439
|
|
|
434
440
|
//#endregion
|
|
435
|
-
//#region \0@oxc-project+runtime@0.
|
|
441
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
436
442
|
function __decorate(decorators, target, key, desc) {
|
|
437
443
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
438
444
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -573,9 +579,7 @@ const OpenConditionalFormattingOperator = {
|
|
|
573
579
|
case 9:
|
|
574
580
|
commandService.executeCommand(ClearRangeCfCommand.id, { ranges });
|
|
575
581
|
break;
|
|
576
|
-
case 10:
|
|
577
|
-
commandService.executeCommand(ClearWorksheetCfCommand.id);
|
|
578
|
-
break;
|
|
582
|
+
case 10: commandService.executeCommand(ClearWorksheetCfCommand.id);
|
|
579
583
|
}
|
|
580
584
|
return true;
|
|
581
585
|
}
|
|
@@ -1003,7 +1007,7 @@ const menuSchema = {
|
|
|
1003
1007
|
//#endregion
|
|
1004
1008
|
//#region package.json
|
|
1005
1009
|
var name = "@univerjs/sheets-conditional-formatting-ui";
|
|
1006
|
-
var version = "1.0.
|
|
1010
|
+
var version = "1.0.1";
|
|
1007
1011
|
|
|
1008
1012
|
//#endregion
|
|
1009
1013
|
//#region src/config/config.ts
|
|
@@ -1043,11 +1047,9 @@ let ConditionalFormattingFormulaRefRangeController = class ConditionalFormatting
|
|
|
1043
1047
|
if (item.value.type === CFValueType.formula) formulas.push(item.value.value);
|
|
1044
1048
|
});
|
|
1045
1049
|
break;
|
|
1046
|
-
case CFRuleType.iconSet:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
});
|
|
1050
|
-
break;
|
|
1050
|
+
case CFRuleType.iconSet: ruleConfig.config.forEach((item) => {
|
|
1051
|
+
if (item.value.type === CFValueType.formula) formulas.push(item.value.value);
|
|
1052
|
+
});
|
|
1051
1053
|
}
|
|
1052
1054
|
return formulas;
|
|
1053
1055
|
}
|
|
@@ -1070,11 +1072,9 @@ let ConditionalFormattingFormulaRefRangeController = class ConditionalFormatting
|
|
|
1070
1072
|
if (item.value.type === CFValueType.formula) item.value.value = formulas[formulaIndex++];
|
|
1071
1073
|
});
|
|
1072
1074
|
break;
|
|
1073
|
-
case CFRuleType.iconSet:
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
});
|
|
1077
|
-
break;
|
|
1075
|
+
case CFRuleType.iconSet: ruleConfig.config.forEach((item) => {
|
|
1076
|
+
if (item.value.type === CFValueType.formula) item.value.value = formulas[formulaIndex++];
|
|
1077
|
+
});
|
|
1078
1078
|
}
|
|
1079
1079
|
return newRule;
|
|
1080
1080
|
}
|
|
@@ -1725,12 +1725,13 @@ function Preview(props) {
|
|
|
1725
1725
|
case CFRuleType.dataBar: {
|
|
1726
1726
|
const { isGradient } = rule.config;
|
|
1727
1727
|
const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
|
|
1728
|
+
const nativeColor = isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || defaultDataBarNativeColor})` : rule.config.nativeColor;
|
|
1728
1729
|
return /* @__PURE__ */ jsxs("div", {
|
|
1729
1730
|
className: previewClassName,
|
|
1730
1731
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1731
1732
|
className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
|
|
1732
1733
|
style: {
|
|
1733
|
-
background:
|
|
1734
|
+
background: nativeColor,
|
|
1734
1735
|
borderColor: rule.config.nativeColor ?? defaultDataBarNativeColor
|
|
1735
1736
|
}
|
|
1736
1737
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -2888,7 +2889,6 @@ function HighlightCellInput(props) {
|
|
|
2888
2889
|
CFNumberOperator.lessThanOrEqual
|
|
2889
2890
|
].includes(operator)) onChange(inputNumberValue);
|
|
2890
2891
|
if ([CFNumberOperator.between, CFNumberOperator.notBetween].includes(operator)) onChange([inputNumberMin, inputNumberMax]);
|
|
2891
|
-
break;
|
|
2892
2892
|
}
|
|
2893
2893
|
}, [type]);
|
|
2894
2894
|
useEffect(() => {
|
|
@@ -3577,12 +3577,13 @@ const IconSet = (props) => {
|
|
|
3577
3577
|
return !!rule.isShowValue;
|
|
3578
3578
|
});
|
|
3579
3579
|
const previewIcon = useMemo(() => {
|
|
3580
|
+
const list = configList.map((item) => {
|
|
3581
|
+
return getIcon(item.iconType, item.iconId);
|
|
3582
|
+
});
|
|
3580
3583
|
return /* @__PURE__ */ jsx("div", {
|
|
3581
3584
|
"data-u-comp": "cf-icon-set-preview",
|
|
3582
3585
|
className: "univer-flex univer-items-center rtl:univer-flex-row-reverse",
|
|
3583
|
-
children:
|
|
3584
|
-
return getIcon(item.iconType, item.iconId);
|
|
3585
|
-
}).map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
3586
|
+
children: list.map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
3586
3587
|
className: "univer-size-5",
|
|
3587
3588
|
src: icon
|
|
3588
3589
|
}, index) : /* @__PURE__ */ jsx(SlashDoubleIcon, { className: "univer-size-5" }, index))
|
|
@@ -4113,9 +4114,10 @@ const RuleEdit = (props) => {
|
|
|
4113
4114
|
setErrorText(void 0);
|
|
4114
4115
|
return;
|
|
4115
4116
|
}
|
|
4116
|
-
if (v)
|
|
4117
|
-
|
|
4118
|
-
|
|
4117
|
+
if (v) {
|
|
4118
|
+
if (rangeText.length < 1) setErrorText(localeService.t("sheets-conditional-formatting-ui.errorMessage.rangeError"));
|
|
4119
|
+
else setErrorText(void 0);
|
|
4120
|
+
} else setErrorText(localeService.t("sheets-conditional-formatting-ui.errorMessage.rangeError"));
|
|
4119
4121
|
};
|
|
4120
4122
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4121
4123
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -4195,9 +4197,10 @@ const getRuleDescribe = (rule, localeService) => {
|
|
|
4195
4197
|
const operator = ruleConfig.operator;
|
|
4196
4198
|
return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`);
|
|
4197
4199
|
}
|
|
4198
|
-
case CFSubRuleType.rank: if (ruleConfig.isPercent)
|
|
4199
|
-
|
|
4200
|
-
|
|
4200
|
+
case CFSubRuleType.rank: if (ruleConfig.isPercent) {
|
|
4201
|
+
if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomNPercent", String(ruleConfig.value));
|
|
4202
|
+
else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
|
|
4203
|
+
} else if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomN", String(ruleConfig.value));
|
|
4201
4204
|
else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
|
|
4202
4205
|
case CFSubRuleType.formula: return localeService.t("sheets-conditional-formatting-ui.ruleType.formula");
|
|
4203
4206
|
}
|
|
@@ -4524,7 +4527,10 @@ MobileComponentsController = __decorate([__decorateParam(0, Inject(ComponentMana
|
|
|
4524
4527
|
|
|
4525
4528
|
//#endregion
|
|
4526
4529
|
//#region src/menu/mobile-schema.ts
|
|
4527
|
-
const mobileMenuSchema = {
|
|
4530
|
+
const mobileMenuSchema = { [RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
|
|
4531
|
+
order: 1,
|
|
4532
|
+
menuItemFactory: FactoryManageConditionalFormattingRule
|
|
4533
|
+
} } };
|
|
4528
4534
|
|
|
4529
4535
|
//#endregion
|
|
4530
4536
|
//#region src/menu/mobile-cf.menu.controller.ts
|
|
@@ -4992,31 +4998,33 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
|
|
|
4992
4998
|
return;
|
|
4993
4999
|
}
|
|
4994
5000
|
const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
|
|
4995
|
-
if (rule)
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5001
|
+
if (rule) {
|
|
5002
|
+
if (ranges.length) {
|
|
5003
|
+
const params = {
|
|
5004
|
+
unitId: targetUnitId,
|
|
5005
|
+
subUnitId: targetSubUnitId,
|
|
5006
|
+
rule: {
|
|
5007
|
+
...rule,
|
|
5008
|
+
ranges
|
|
5009
|
+
}
|
|
5010
|
+
};
|
|
5011
|
+
redos.push({
|
|
5012
|
+
id: SetConditionalRuleMutation.id,
|
|
5013
|
+
params
|
|
5014
|
+
});
|
|
5015
|
+
undos.push(...setConditionalRuleMutationUndoFactory(this._injector, params));
|
|
5016
|
+
} else {
|
|
5017
|
+
const params = {
|
|
5018
|
+
unitId: targetUnitId,
|
|
5019
|
+
subUnitId: targetSubUnitId,
|
|
5020
|
+
cfId: rule.cfId
|
|
5021
|
+
};
|
|
5022
|
+
redos.push({
|
|
5023
|
+
id: DeleteConditionalRuleMutation.id,
|
|
5024
|
+
params
|
|
5025
|
+
});
|
|
5026
|
+
undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, params));
|
|
5027
|
+
}
|
|
5020
5028
|
}
|
|
5021
5029
|
}
|
|
5022
5030
|
});
|
|
@@ -5043,9 +5051,7 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
|
|
|
5043
5051
|
};
|
|
5044
5052
|
break;
|
|
5045
5053
|
}
|
|
5046
|
-
case FormatPainterStatus.OFF:
|
|
5047
|
-
this._painterConfig = null;
|
|
5048
|
-
break;
|
|
5054
|
+
case FormatPainterStatus.OFF: this._painterConfig = null;
|
|
5049
5055
|
}
|
|
5050
5056
|
},
|
|
5051
5057
|
onApply: (unitId, subUnitId, targetRange) => {
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,8 @@ const AddAverageCfCommand = {
|
|
|
23
23
|
const { ranges, style, stopIfTrue, operator } = params;
|
|
24
24
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
25
25
|
const commandService = accessor.get(ICommandService);
|
|
26
|
-
const
|
|
26
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
27
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
27
28
|
if (!target) return false;
|
|
28
29
|
const { unitId, subUnitId } = target;
|
|
29
30
|
const rule = {
|
|
@@ -55,7 +56,8 @@ const AddColorScaleConditionalRuleCommand = {
|
|
|
55
56
|
const { ranges, config, stopIfTrue } = params;
|
|
56
57
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
57
58
|
const commandService = accessor.get(ICommandService);
|
|
58
|
-
const
|
|
59
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
60
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
59
61
|
if (!target) return false;
|
|
60
62
|
const { unitId, subUnitId } = target;
|
|
61
63
|
const rule = {
|
|
@@ -86,7 +88,8 @@ const AddDataBarConditionalRuleCommand = {
|
|
|
86
88
|
const ranges = params.ranges ?? accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
|
|
87
89
|
if (!ranges.length) return false;
|
|
88
90
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
89
|
-
const
|
|
91
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
92
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
90
93
|
if (!target) return false;
|
|
91
94
|
const { unitId, subUnitId } = target;
|
|
92
95
|
const commandService = accessor.get(ICommandService);
|
|
@@ -124,7 +127,8 @@ const AddDuplicateValuesCfCommand = {
|
|
|
124
127
|
const { ranges, style, stopIfTrue } = params;
|
|
125
128
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
126
129
|
const commandService = accessor.get(ICommandService);
|
|
127
|
-
const
|
|
130
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
131
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
128
132
|
if (!target) return false;
|
|
129
133
|
const { unitId, subUnitId } = target;
|
|
130
134
|
const rule = {
|
|
@@ -185,7 +189,8 @@ const AddNumberCfCommand = {
|
|
|
185
189
|
const { ranges, style, stopIfTrue, operator, value } = params;
|
|
186
190
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
187
191
|
const commandService = accessor.get(ICommandService);
|
|
188
|
-
const
|
|
192
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
193
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
189
194
|
if (!target) return false;
|
|
190
195
|
const { unitId, subUnitId } = target;
|
|
191
196
|
const cfId = conditionalFormattingRuleModel.createCfId(unitId, subUnitId);
|
|
@@ -273,7 +278,8 @@ const AddTextCfCommand = {
|
|
|
273
278
|
if (!params) return false;
|
|
274
279
|
const { ranges, style, stopIfTrue, operator, value } = params;
|
|
275
280
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
276
|
-
const
|
|
281
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
282
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
277
283
|
if (!target) return false;
|
|
278
284
|
const { unitId, subUnitId } = target;
|
|
279
285
|
const commandService = accessor.get(ICommandService);
|
|
@@ -382,7 +388,7 @@ const AddUniqueValuesCfCommand = {
|
|
|
382
388
|
const CF_PANEL_KEY = "sheet.conditional.formatting.panel";
|
|
383
389
|
|
|
384
390
|
//#endregion
|
|
385
|
-
//#region \0@oxc-project+runtime@0.
|
|
391
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
386
392
|
function _typeof(o) {
|
|
387
393
|
"@babel/helpers - typeof";
|
|
388
394
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -393,7 +399,7 @@ function _typeof(o) {
|
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
//#endregion
|
|
396
|
-
//#region \0@oxc-project+runtime@0.
|
|
402
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
397
403
|
function toPrimitive(t, r) {
|
|
398
404
|
if ("object" != _typeof(t) || !t) return t;
|
|
399
405
|
var e = t[Symbol.toPrimitive];
|
|
@@ -406,14 +412,14 @@ function toPrimitive(t, r) {
|
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
//#endregion
|
|
409
|
-
//#region \0@oxc-project+runtime@0.
|
|
415
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
410
416
|
function toPropertyKey(t) {
|
|
411
417
|
var i = toPrimitive(t, "string");
|
|
412
418
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
413
419
|
}
|
|
414
420
|
|
|
415
421
|
//#endregion
|
|
416
|
-
//#region \0@oxc-project+runtime@0.
|
|
422
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
417
423
|
function _defineProperty(e, r, t) {
|
|
418
424
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
419
425
|
value: t,
|
|
@@ -424,7 +430,7 @@ function _defineProperty(e, r, t) {
|
|
|
424
430
|
}
|
|
425
431
|
|
|
426
432
|
//#endregion
|
|
427
|
-
//#region \0@oxc-project+runtime@0.
|
|
433
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
428
434
|
function __decorateParam(paramIndex, decorator) {
|
|
429
435
|
return function(target, key) {
|
|
430
436
|
decorator(target, key, paramIndex);
|
|
@@ -432,7 +438,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
432
438
|
}
|
|
433
439
|
|
|
434
440
|
//#endregion
|
|
435
|
-
//#region \0@oxc-project+runtime@0.
|
|
441
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
436
442
|
function __decorate(decorators, target, key, desc) {
|
|
437
443
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
438
444
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -573,9 +579,7 @@ const OpenConditionalFormattingOperator = {
|
|
|
573
579
|
case 9:
|
|
574
580
|
commandService.executeCommand(ClearRangeCfCommand.id, { ranges });
|
|
575
581
|
break;
|
|
576
|
-
case 10:
|
|
577
|
-
commandService.executeCommand(ClearWorksheetCfCommand.id);
|
|
578
|
-
break;
|
|
582
|
+
case 10: commandService.executeCommand(ClearWorksheetCfCommand.id);
|
|
579
583
|
}
|
|
580
584
|
return true;
|
|
581
585
|
}
|
|
@@ -1003,7 +1007,7 @@ const menuSchema = {
|
|
|
1003
1007
|
//#endregion
|
|
1004
1008
|
//#region package.json
|
|
1005
1009
|
var name = "@univerjs/sheets-conditional-formatting-ui";
|
|
1006
|
-
var version = "1.0.
|
|
1010
|
+
var version = "1.0.1";
|
|
1007
1011
|
|
|
1008
1012
|
//#endregion
|
|
1009
1013
|
//#region src/config/config.ts
|
|
@@ -1043,11 +1047,9 @@ let ConditionalFormattingFormulaRefRangeController = class ConditionalFormatting
|
|
|
1043
1047
|
if (item.value.type === CFValueType.formula) formulas.push(item.value.value);
|
|
1044
1048
|
});
|
|
1045
1049
|
break;
|
|
1046
|
-
case CFRuleType.iconSet:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
});
|
|
1050
|
-
break;
|
|
1050
|
+
case CFRuleType.iconSet: ruleConfig.config.forEach((item) => {
|
|
1051
|
+
if (item.value.type === CFValueType.formula) formulas.push(item.value.value);
|
|
1052
|
+
});
|
|
1051
1053
|
}
|
|
1052
1054
|
return formulas;
|
|
1053
1055
|
}
|
|
@@ -1070,11 +1072,9 @@ let ConditionalFormattingFormulaRefRangeController = class ConditionalFormatting
|
|
|
1070
1072
|
if (item.value.type === CFValueType.formula) item.value.value = formulas[formulaIndex++];
|
|
1071
1073
|
});
|
|
1072
1074
|
break;
|
|
1073
|
-
case CFRuleType.iconSet:
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
});
|
|
1077
|
-
break;
|
|
1075
|
+
case CFRuleType.iconSet: ruleConfig.config.forEach((item) => {
|
|
1076
|
+
if (item.value.type === CFValueType.formula) item.value.value = formulas[formulaIndex++];
|
|
1077
|
+
});
|
|
1078
1078
|
}
|
|
1079
1079
|
return newRule;
|
|
1080
1080
|
}
|
|
@@ -1725,12 +1725,13 @@ function Preview(props) {
|
|
|
1725
1725
|
case CFRuleType.dataBar: {
|
|
1726
1726
|
const { isGradient } = rule.config;
|
|
1727
1727
|
const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
|
|
1728
|
+
const nativeColor = isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || defaultDataBarNativeColor})` : rule.config.nativeColor;
|
|
1728
1729
|
return /* @__PURE__ */ jsxs("div", {
|
|
1729
1730
|
className: previewClassName,
|
|
1730
1731
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1731
1732
|
className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
|
|
1732
1733
|
style: {
|
|
1733
|
-
background:
|
|
1734
|
+
background: nativeColor,
|
|
1734
1735
|
borderColor: rule.config.nativeColor ?? defaultDataBarNativeColor
|
|
1735
1736
|
}
|
|
1736
1737
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -2888,7 +2889,6 @@ function HighlightCellInput(props) {
|
|
|
2888
2889
|
CFNumberOperator.lessThanOrEqual
|
|
2889
2890
|
].includes(operator)) onChange(inputNumberValue);
|
|
2890
2891
|
if ([CFNumberOperator.between, CFNumberOperator.notBetween].includes(operator)) onChange([inputNumberMin, inputNumberMax]);
|
|
2891
|
-
break;
|
|
2892
2892
|
}
|
|
2893
2893
|
}, [type]);
|
|
2894
2894
|
useEffect(() => {
|
|
@@ -3577,12 +3577,13 @@ const IconSet = (props) => {
|
|
|
3577
3577
|
return !!rule.isShowValue;
|
|
3578
3578
|
});
|
|
3579
3579
|
const previewIcon = useMemo(() => {
|
|
3580
|
+
const list = configList.map((item) => {
|
|
3581
|
+
return getIcon(item.iconType, item.iconId);
|
|
3582
|
+
});
|
|
3580
3583
|
return /* @__PURE__ */ jsx("div", {
|
|
3581
3584
|
"data-u-comp": "cf-icon-set-preview",
|
|
3582
3585
|
className: "univer-flex univer-items-center rtl:univer-flex-row-reverse",
|
|
3583
|
-
children:
|
|
3584
|
-
return getIcon(item.iconType, item.iconId);
|
|
3585
|
-
}).map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
3586
|
+
children: list.map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
3586
3587
|
className: "univer-size-5",
|
|
3587
3588
|
src: icon
|
|
3588
3589
|
}, index) : /* @__PURE__ */ jsx(SlashDoubleIcon, { className: "univer-size-5" }, index))
|
|
@@ -4113,9 +4114,10 @@ const RuleEdit = (props) => {
|
|
|
4113
4114
|
setErrorText(void 0);
|
|
4114
4115
|
return;
|
|
4115
4116
|
}
|
|
4116
|
-
if (v)
|
|
4117
|
-
|
|
4118
|
-
|
|
4117
|
+
if (v) {
|
|
4118
|
+
if (rangeText.length < 1) setErrorText(localeService.t("sheets-conditional-formatting-ui.errorMessage.rangeError"));
|
|
4119
|
+
else setErrorText(void 0);
|
|
4120
|
+
} else setErrorText(localeService.t("sheets-conditional-formatting-ui.errorMessage.rangeError"));
|
|
4119
4121
|
};
|
|
4120
4122
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4121
4123
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -4195,9 +4197,10 @@ const getRuleDescribe = (rule, localeService) => {
|
|
|
4195
4197
|
const operator = ruleConfig.operator;
|
|
4196
4198
|
return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`);
|
|
4197
4199
|
}
|
|
4198
|
-
case CFSubRuleType.rank: if (ruleConfig.isPercent)
|
|
4199
|
-
|
|
4200
|
-
|
|
4200
|
+
case CFSubRuleType.rank: if (ruleConfig.isPercent) {
|
|
4201
|
+
if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomNPercent", String(ruleConfig.value));
|
|
4202
|
+
else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
|
|
4203
|
+
} else if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomN", String(ruleConfig.value));
|
|
4201
4204
|
else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
|
|
4202
4205
|
case CFSubRuleType.formula: return localeService.t("sheets-conditional-formatting-ui.ruleType.formula");
|
|
4203
4206
|
}
|
|
@@ -4524,7 +4527,10 @@ MobileComponentsController = __decorate([__decorateParam(0, Inject(ComponentMana
|
|
|
4524
4527
|
|
|
4525
4528
|
//#endregion
|
|
4526
4529
|
//#region src/menu/mobile-schema.ts
|
|
4527
|
-
const mobileMenuSchema = {
|
|
4530
|
+
const mobileMenuSchema = { [RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
|
|
4531
|
+
order: 1,
|
|
4532
|
+
menuItemFactory: FactoryManageConditionalFormattingRule
|
|
4533
|
+
} } };
|
|
4528
4534
|
|
|
4529
4535
|
//#endregion
|
|
4530
4536
|
//#region src/menu/mobile-cf.menu.controller.ts
|
|
@@ -4992,31 +4998,33 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
|
|
|
4992
4998
|
return;
|
|
4993
4999
|
}
|
|
4994
5000
|
const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
|
|
4995
|
-
if (rule)
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5001
|
+
if (rule) {
|
|
5002
|
+
if (ranges.length) {
|
|
5003
|
+
const params = {
|
|
5004
|
+
unitId: targetUnitId,
|
|
5005
|
+
subUnitId: targetSubUnitId,
|
|
5006
|
+
rule: {
|
|
5007
|
+
...rule,
|
|
5008
|
+
ranges
|
|
5009
|
+
}
|
|
5010
|
+
};
|
|
5011
|
+
redos.push({
|
|
5012
|
+
id: SetConditionalRuleMutation.id,
|
|
5013
|
+
params
|
|
5014
|
+
});
|
|
5015
|
+
undos.push(...setConditionalRuleMutationUndoFactory(this._injector, params));
|
|
5016
|
+
} else {
|
|
5017
|
+
const params = {
|
|
5018
|
+
unitId: targetUnitId,
|
|
5019
|
+
subUnitId: targetSubUnitId,
|
|
5020
|
+
cfId: rule.cfId
|
|
5021
|
+
};
|
|
5022
|
+
redos.push({
|
|
5023
|
+
id: DeleteConditionalRuleMutation.id,
|
|
5024
|
+
params
|
|
5025
|
+
});
|
|
5026
|
+
undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, params));
|
|
5027
|
+
}
|
|
5020
5028
|
}
|
|
5021
5029
|
}
|
|
5022
5030
|
});
|
|
@@ -5043,9 +5051,7 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
|
|
|
5043
5051
|
};
|
|
5044
5052
|
break;
|
|
5045
5053
|
}
|
|
5046
|
-
case FormatPainterStatus.OFF:
|
|
5047
|
-
this._painterConfig = null;
|
|
5048
|
-
break;
|
|
5054
|
+
case FormatPainterStatus.OFF: this._painterConfig = null;
|
|
5049
5055
|
}
|
|
5050
5056
|
},
|
|
5051
5057
|
onApply: (unitId, subUnitId, targetRange) => {
|