@univerjs/sheets-conditional-formatting 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +71 -45
- package/lib/es/index.js +974 -851
- package/lib/types/base/const.d.ts +1 -1
- package/lib/types/commands/commands/add-cf.command.d.ts +9 -0
- package/lib/types/commands/commands/clear-range-cf.command.d.ts +7 -0
- package/lib/types/commands/commands/clear-worksheet-cf.command.d.ts +6 -0
- package/lib/types/commands/commands/delete-cf.command.d.ts +7 -0
- package/lib/types/commands/commands/move-cf.command.d.ts +9 -0
- package/lib/types/commands/commands/set-cf.command.d.ts +9 -0
- package/lib/types/facade/conditional-formatting-builder.d.ts +13 -2
- package/lib/types/facade/f-range.d.ts +7 -0
- package/lib/types/facade/f-worksheet.d.ts +14 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/es/facade.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (u, e, t) =>
|
|
4
|
-
import { ColorKit as
|
|
5
|
-
import { CFRuleType as n, EMPTY_ICON_TYPE as
|
|
6
|
-
import { FRange as
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var v = (u, e, t) => e in u ? E(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
|
|
3
|
+
var b = (u, e, t) => v(u, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ColorKit as m, Tools as c, BooleanNumber as a, Rectangle as R, ColorBuilder as F } from "@univerjs/core";
|
|
5
|
+
import { CFRuleType as n, EMPTY_ICON_TYPE as _, CFValueType as C, CFNumberOperator as l, CFTextOperator as g, CFSubRuleType as o, createCfId as T, iconMap as N, ConditionalFormattingRuleModel as x, AddConditionalRuleMutation as U, DeleteConditionalRuleMutation as q, MoveConditionalRuleMutation as B, SetConditionalRuleMutation as M, ClearRangeCfCommand as A, AddCfCommand as D, DeleteCfCommand as V, MoveCfCommand as O, SetCfCommand as W, ClearWorksheetCfCommand as L } from "@univerjs/sheets-conditional-formatting";
|
|
6
|
+
import { FRange as S, FWorkbook as I, FWorksheet as k } from "@univerjs/sheets/facade";
|
|
7
7
|
class d {
|
|
8
8
|
constructor(e = {}) {
|
|
9
9
|
b(this, "_rule", {});
|
|
@@ -18,15 +18,15 @@ class d {
|
|
|
18
18
|
return {
|
|
19
19
|
type: e,
|
|
20
20
|
config: [
|
|
21
|
-
{ index: 0, color: new
|
|
22
|
-
{ index: 0, color: new
|
|
21
|
+
{ index: 0, color: new m("").toRgbString(), value: { type: C.min } },
|
|
22
|
+
{ index: 0, color: new m("green").toRgbString(), value: { type: C.max } }
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
25
|
case n.dataBar:
|
|
26
26
|
return {
|
|
27
27
|
type: e,
|
|
28
28
|
isShowValue: !0,
|
|
29
|
-
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new
|
|
29
|
+
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new m("green").toRgbString(), nativeColor: new m("").toRgbString(), isGradient: !1 }
|
|
30
30
|
};
|
|
31
31
|
case n.highlightCell:
|
|
32
32
|
return {
|
|
@@ -44,19 +44,19 @@ class d {
|
|
|
44
44
|
{
|
|
45
45
|
operator: l.greaterThanOrEqual,
|
|
46
46
|
value: { type: C.min },
|
|
47
|
-
iconType:
|
|
47
|
+
iconType: _,
|
|
48
48
|
iconId: ""
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
operator: l.greaterThanOrEqual,
|
|
52
52
|
value: { type: C.percentile, value: 0.5 },
|
|
53
|
-
iconType:
|
|
53
|
+
iconType: _,
|
|
54
54
|
iconId: ""
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
operator: l.lessThanOrEqual,
|
|
58
58
|
value: { type: C.max },
|
|
59
|
-
iconType:
|
|
59
|
+
iconType: _,
|
|
60
60
|
iconId: ""
|
|
61
61
|
}
|
|
62
62
|
]
|
|
@@ -79,7 +79,7 @@ class d {
|
|
|
79
79
|
* @memberof ConditionalFormatRuleBuilder
|
|
80
80
|
*/
|
|
81
81
|
copy() {
|
|
82
|
-
return new d(
|
|
82
|
+
return new d(c.deepClone(this._rule));
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Gets the scope of the current conditional format
|
|
@@ -93,7 +93,7 @@ class d {
|
|
|
93
93
|
* Get the icon set mapping dictionary
|
|
94
94
|
*/
|
|
95
95
|
getIconMap() {
|
|
96
|
-
return
|
|
96
|
+
return N;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* Create a conditional format ID.
|
|
@@ -118,7 +118,7 @@ class i extends d {
|
|
|
118
118
|
super(e), this._ensureAttr(this._rule, ["rule", "style"]);
|
|
119
119
|
}
|
|
120
120
|
copy() {
|
|
121
|
-
return new i(
|
|
121
|
+
return new i(c.deepClone(this._rule));
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Set average rule
|
|
@@ -168,7 +168,7 @@ class i extends d {
|
|
|
168
168
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
169
169
|
if (e) {
|
|
170
170
|
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
171
|
-
const r = new
|
|
171
|
+
const r = new m(e);
|
|
172
172
|
this._ruleConfig.style.bg.rgb = r.toRgbString();
|
|
173
173
|
} else
|
|
174
174
|
delete this._ruleConfig.style.bg;
|
|
@@ -194,7 +194,7 @@ class i extends d {
|
|
|
194
194
|
var t;
|
|
195
195
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
196
196
|
if (e) {
|
|
197
|
-
const r = new
|
|
197
|
+
const r = new m(e);
|
|
198
198
|
this._ensureAttr(this._ruleConfig, ["style", "cl"]), this._ruleConfig.style.cl.rgb = r.toRgbString();
|
|
199
199
|
} else
|
|
200
200
|
delete this._ruleConfig.style.cl;
|
|
@@ -387,7 +387,7 @@ class i extends d {
|
|
|
387
387
|
}
|
|
388
388
|
class w extends d {
|
|
389
389
|
copy() {
|
|
390
|
-
return new w(
|
|
390
|
+
return new w(c.deepClone(this._rule));
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
* Data bar settings
|
|
@@ -420,7 +420,7 @@ class w extends d {
|
|
|
420
420
|
}
|
|
421
421
|
class p extends d {
|
|
422
422
|
copy() {
|
|
423
|
-
return new p(
|
|
423
|
+
return new p(c.deepClone(this._rule));
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Color scale set
|
|
@@ -434,7 +434,7 @@ class p extends d {
|
|
|
434
434
|
}
|
|
435
435
|
class y extends d {
|
|
436
436
|
copy() {
|
|
437
|
-
return new y(
|
|
437
|
+
return new y(c.deepClone(this._rule));
|
|
438
438
|
}
|
|
439
439
|
/**
|
|
440
440
|
*
|
|
@@ -449,10 +449,21 @@ class y extends d {
|
|
|
449
449
|
return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
class
|
|
452
|
+
class f {
|
|
453
453
|
constructor(e = {}) {
|
|
454
454
|
this._initConfig = e;
|
|
455
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Constructs a conditional format rule from the settings applied to the builder.
|
|
458
|
+
* @returns {IConditionFormattingRule} The conditional format rule.
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
462
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
463
|
+
* const rule = fWorksheet.newConditionalFormattingRule().build();
|
|
464
|
+
* fWorksheet.setConditionalFormattingRules([rule]);
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
456
467
|
build() {
|
|
457
468
|
return new d(this._initConfig).build();
|
|
458
469
|
}
|
|
@@ -721,15 +732,15 @@ class m {
|
|
|
721
732
|
return new i(this._initConfig).whenTextStartsWith(e);
|
|
722
733
|
}
|
|
723
734
|
}
|
|
724
|
-
class
|
|
735
|
+
class G extends S {
|
|
725
736
|
_getConditionalFormattingRuleModel() {
|
|
726
737
|
return this._injector.get(x);
|
|
727
738
|
}
|
|
728
739
|
getConditionalFormattingRules() {
|
|
729
|
-
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) =>
|
|
740
|
+
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => R.intersects(r, this._range)));
|
|
730
741
|
}
|
|
731
742
|
createConditionalFormattingRule() {
|
|
732
|
-
return new
|
|
743
|
+
return new f({ ranges: [this._range] });
|
|
733
744
|
}
|
|
734
745
|
addConditionalFormattingRule(e) {
|
|
735
746
|
const t = {
|
|
@@ -737,7 +748,7 @@ class A extends k {
|
|
|
737
748
|
unitId: this._workbook.getUnitId(),
|
|
738
749
|
subUnitId: this._worksheet.getSheetId()
|
|
739
750
|
};
|
|
740
|
-
return this._commandService.syncExecuteCommand(
|
|
751
|
+
return this._commandService.syncExecuteCommand(U.id, t), this;
|
|
741
752
|
}
|
|
742
753
|
deleteConditionalFormattingRule(e) {
|
|
743
754
|
const t = {
|
|
@@ -745,7 +756,7 @@ class A extends k {
|
|
|
745
756
|
subUnitId: this._worksheet.getSheetId(),
|
|
746
757
|
cfId: e
|
|
747
758
|
};
|
|
748
|
-
return this._commandService.syncExecuteCommand(
|
|
759
|
+
return this._commandService.syncExecuteCommand(q.id, t), this;
|
|
749
760
|
}
|
|
750
761
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
751
762
|
const s = {
|
|
@@ -754,7 +765,7 @@ class A extends k {
|
|
|
754
765
|
start: { id: e, type: "self" },
|
|
755
766
|
end: { id: t, type: r }
|
|
756
767
|
};
|
|
757
|
-
return this._commandService.syncExecuteCommand(
|
|
768
|
+
return this._commandService.syncExecuteCommand(B.id, s), this;
|
|
758
769
|
}
|
|
759
770
|
setConditionalFormattingRule(e, t) {
|
|
760
771
|
const r = {
|
|
@@ -763,17 +774,25 @@ class A extends k {
|
|
|
763
774
|
rule: t,
|
|
764
775
|
cfId: e
|
|
765
776
|
};
|
|
766
|
-
return this._commandService.syncExecuteCommand(
|
|
777
|
+
return this._commandService.syncExecuteCommand(M.id, r), this;
|
|
778
|
+
}
|
|
779
|
+
clearConditionalFormatRules() {
|
|
780
|
+
const e = {
|
|
781
|
+
unitId: this._workbook.getUnitId(),
|
|
782
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
783
|
+
ranges: [this._range]
|
|
784
|
+
};
|
|
785
|
+
return this._commandService.syncExecuteCommand(A.id, e), this;
|
|
767
786
|
}
|
|
768
787
|
}
|
|
769
|
-
|
|
770
|
-
class
|
|
788
|
+
S.extend(G);
|
|
789
|
+
class P extends I {
|
|
771
790
|
newColor() {
|
|
772
|
-
return new
|
|
791
|
+
return new F();
|
|
773
792
|
}
|
|
774
793
|
}
|
|
775
|
-
|
|
776
|
-
class
|
|
794
|
+
I.extend(P);
|
|
795
|
+
class K extends k {
|
|
777
796
|
_getConditionalFormattingRuleModel() {
|
|
778
797
|
return this._injector.get(x);
|
|
779
798
|
}
|
|
@@ -781,18 +800,18 @@ class V extends R {
|
|
|
781
800
|
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
|
|
782
801
|
}
|
|
783
802
|
createConditionalFormattingRule() {
|
|
784
|
-
return new
|
|
803
|
+
return new f();
|
|
785
804
|
}
|
|
786
805
|
newConditionalFormattingRule() {
|
|
787
|
-
return new
|
|
806
|
+
return new f();
|
|
788
807
|
}
|
|
789
808
|
addConditionalFormattingRule(e) {
|
|
790
809
|
const t = {
|
|
791
|
-
rule: e,
|
|
792
810
|
unitId: this._workbook.getUnitId(),
|
|
793
|
-
subUnitId: this._worksheet.getSheetId()
|
|
811
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
812
|
+
rule: e
|
|
794
813
|
};
|
|
795
|
-
return this._commandService.syncExecuteCommand(
|
|
814
|
+
return this._commandService.syncExecuteCommand(D.id, t), this;
|
|
796
815
|
}
|
|
797
816
|
deleteConditionalFormattingRule(e) {
|
|
798
817
|
const t = {
|
|
@@ -800,7 +819,7 @@ class V extends R {
|
|
|
800
819
|
subUnitId: this._worksheet.getSheetId(),
|
|
801
820
|
cfId: e
|
|
802
821
|
};
|
|
803
|
-
return this._commandService.syncExecuteCommand(
|
|
822
|
+
return this._commandService.syncExecuteCommand(V.id, t), this;
|
|
804
823
|
}
|
|
805
824
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
806
825
|
const s = {
|
|
@@ -809,19 +828,26 @@ class V extends R {
|
|
|
809
828
|
start: { id: e, type: "self" },
|
|
810
829
|
end: { id: t, type: r }
|
|
811
830
|
};
|
|
812
|
-
return this._commandService.syncExecuteCommand(
|
|
831
|
+
return this._commandService.syncExecuteCommand(O.id, s), this;
|
|
813
832
|
}
|
|
814
833
|
setConditionalFormattingRule(e, t) {
|
|
815
834
|
const r = {
|
|
816
835
|
unitId: this._workbook.getUnitId(),
|
|
817
836
|
subUnitId: this._worksheet.getSheetId(),
|
|
818
|
-
|
|
819
|
-
|
|
837
|
+
cfId: e,
|
|
838
|
+
rule: t
|
|
839
|
+
};
|
|
840
|
+
return this._commandService.syncExecuteCommand(W.id, r), this;
|
|
841
|
+
}
|
|
842
|
+
clearConditionalFormatRules() {
|
|
843
|
+
const e = {
|
|
844
|
+
unitId: this._workbook.getUnitId(),
|
|
845
|
+
subUnitId: this._worksheet.getSheetId()
|
|
820
846
|
};
|
|
821
|
-
return this._commandService.syncExecuteCommand(
|
|
847
|
+
return this._commandService.syncExecuteCommand(L.id, e), this;
|
|
822
848
|
}
|
|
823
849
|
}
|
|
824
|
-
|
|
850
|
+
k.extend(K);
|
|
825
851
|
export {
|
|
826
|
-
|
|
852
|
+
f as FConditionalFormattingBuilder
|
|
827
853
|
};
|