@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/es/facade.js CHANGED
@@ -1,9 +1,9 @@
1
- var N = Object.defineProperty;
2
- var q = (u, e, t) => e in u ? N(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
- var b = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
4
- import { ColorKit as c, Tools as _, BooleanNumber as a, Rectangle as U, ColorBuilder as B } from "@univerjs/core";
5
- import { CFRuleType as n, EMPTY_ICON_TYPE as f, CFValueType as C, CFNumberOperator as l, CFTextOperator as g, CFSubRuleType as o, createCfId as T, iconMap as M, ConditionalFormattingRuleModel as x, AddConditionalRuleMutation as S, DeleteConditionalRuleMutation as I, MoveConditionalRuleMutation as E, SetConditionalRuleMutation as v } from "@univerjs/sheets-conditional-formatting";
6
- import { FRange as k, FWorkbook as F, FWorksheet as R } from "@univerjs/sheets/facade";
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 c("").toRgbString(), value: { type: C.min } },
22
- { index: 0, color: new c("green").toRgbString(), value: { type: C.max } }
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 c("green").toRgbString(), nativeColor: new c("").toRgbString(), isGradient: !1 }
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: f,
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: f,
53
+ iconType: _,
54
54
  iconId: ""
55
55
  },
56
56
  {
57
57
  operator: l.lessThanOrEqual,
58
58
  value: { type: C.max },
59
- iconType: f,
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(_.deepClone(this._rule));
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 M;
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(_.deepClone(this._rule));
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 c(e);
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 c(e);
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(_.deepClone(this._rule));
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(_.deepClone(this._rule));
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(_.deepClone(this._rule));
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 m {
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 A extends k {
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) => U.intersects(r, this._range)));
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 m({ ranges: [this._range] });
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(S.id, t), this;
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(I.id, t), this;
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(E.id, s), this;
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(v.id, r), this;
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
- k.extend(A);
770
- class D extends F {
788
+ S.extend(G);
789
+ class P extends I {
771
790
  newColor() {
772
- return new B();
791
+ return new F();
773
792
  }
774
793
  }
775
- F.extend(D);
776
- class V extends R {
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 m();
803
+ return new f();
785
804
  }
786
805
  newConditionalFormattingRule() {
787
- return new m();
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(S.id, t), this;
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(I.id, t), this;
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(E.id, s), this;
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
- rule: t,
819
- cfId: e
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(v.id, r), this;
847
+ return this._commandService.syncExecuteCommand(L.id, e), this;
822
848
  }
823
849
  }
824
- R.extend(V);
850
+ k.extend(K);
825
851
  export {
826
- m as FConditionalFormattingBuilder
852
+ f as FConditionalFormattingBuilder
827
853
  };