@univerjs/sheets-conditional-formatting 0.5.3 → 0.5.4

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,12 +1,12 @@
1
1
  var N = Object.defineProperty;
2
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 y = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
3
+ var b = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ColorKit as c, Tools as _, BooleanNumber as a, Rectangle as U, ColorBuilder as B } from "@univerjs/core";
5
- import { CFRuleType as n, CFNumberOperator as l, CFValueType as C, EMPTY_ICON_TYPE as f, CFSubRuleType as o, CFTextOperator as g, createCfId as b, iconMap as M, ConditionalFormattingRuleModel as T, AddConditionalRuleMutation as x, DeleteConditionalRuleMutation as S, MoveConditionalRuleMutation as I, SetConditionalRuleMutation as E } from "@univerjs/sheets-conditional-formatting";
6
- import { FRange as v, FWorkbook as k, FWorksheet as F } from "@univerjs/sheets/facade";
5
+ import { CFRuleType as n, CFNumberOperator as l, CFValueType as C, EMPTY_ICON_TYPE as f, CFSubRuleType as o, CFTextOperator as g, createCfId as T, iconMap as M, ConditionalFormattingRuleModel as x, AddConditionalRuleMutation as S, DeleteConditionalRuleMutation as I, MoveConditionalRuleMutation as E, SetConditionalRuleMutation as k } from "@univerjs/sheets-conditional-formatting";
6
+ import { FRange as v, FWorkbook as F, FWorksheet as R } from "@univerjs/sheets/facade";
7
7
  class d {
8
8
  constructor(e = {}) {
9
- y(this, "_rule", {});
9
+ b(this, "_rule", {});
10
10
  this._rule = e, this._ensureAttr(this._rule, ["rule"]);
11
11
  }
12
12
  get _ruleConfig() {
@@ -69,14 +69,13 @@ class d {
69
69
  }
70
70
  build() {
71
71
  var r;
72
- this._rule.cfId || (this._rule.cfId = b()), this._rule.ranges || (this._rule.ranges = []), this._rule.stopIfTrue === void 0 && (this._rule.stopIfTrue = !1), (r = this._rule.rule) != null && r.type || (this._rule.rule.type = n.highlightCell, this._ensureAttr(this._rule, ["rule", "style"]));
72
+ this._rule.cfId || (this._rule.cfId = T()), this._rule.ranges || (this._rule.ranges = []), this._rule.stopIfTrue === void 0 && (this._rule.stopIfTrue = !1), (r = this._rule.rule) != null && r.type || (this._rule.rule.type = n.highlightCell, this._ensureAttr(this._rule, ["rule", "style"]));
73
73
  const e = this._getDefaultConfig(this._rule.rule.type);
74
74
  return { ...this._rule, rule: { ...e, ...this._rule.rule } };
75
75
  }
76
76
  /**
77
- * deep clone a current builder.
78
- *
79
- * @return {*}
77
+ * Deep clone a current builder.
78
+ * @returns {*}
80
79
  * @memberof ConditionalFormatRuleBuilder
81
80
  */
82
81
  copy() {
@@ -84,7 +83,7 @@ class d {
84
83
  }
85
84
  /**
86
85
  * Gets the scope of the current conditional format
87
- * @return {*}
86
+ * @returns {*}
88
87
  * @memberof ConditionalFormatRuleBuilder
89
88
  */
90
89
  getRanges() {
@@ -97,17 +96,17 @@ class d {
97
96
  return M;
98
97
  }
99
98
  /**
100
- * create a conditional format ID.
101
- * @return {*}
99
+ * Create a conditional format ID.
100
+ * @returns {*}
102
101
  * @memberof ConditionalFormatRuleBuilder
103
102
  */
104
103
  createCfId() {
105
- return b();
104
+ return T();
106
105
  }
107
106
  /**
108
107
  * Sets the scope for conditional formatting
109
108
  * @param {IRange[]} ranges
110
- * @return {*}
109
+ * @returns {*}
111
110
  * @memberof ConditionalFormatRuleBuilder
112
111
  */
113
112
  setRanges(e) {
@@ -123,7 +122,6 @@ class i extends d {
123
122
  }
124
123
  /**
125
124
  * Set average rule
126
- *
127
125
  * @param {IAverageHighlightCell['operator']} operator
128
126
  * @memberof ConditionalFormatHighlightRuleBuilder
129
127
  */
@@ -133,7 +131,6 @@ class i extends d {
133
131
  }
134
132
  /**
135
133
  * Set uniqueValues rule
136
- *
137
134
  * @memberof ConditionalFormatHighlightRuleBuilder
138
135
  */
139
136
  setUniqueValues() {
@@ -142,7 +139,6 @@ class i extends d {
142
139
  }
143
140
  /**
144
141
  * Set duplicateValues rule
145
- *
146
142
  * @memberof ConditionalFormatHighlightRuleBuilder
147
143
  */
148
144
  setDuplicateValues() {
@@ -151,8 +147,10 @@ class i extends d {
151
147
  }
152
148
  /**
153
149
  * Set rank rule
154
- *
155
150
  * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
151
+ * @param config.isBottom
152
+ * @param config.isPercent
153
+ * @param config.value
156
154
  * @memberof ConditionalFormatHighlightRuleBuilder
157
155
  */
158
156
  setRank(e) {
@@ -162,7 +160,7 @@ class i extends d {
162
160
  /**
163
161
  * Sets the background color
164
162
  * @param {string} [color]
165
- * @return {*}
163
+ * @returns {*}
166
164
  * @memberof ConditionalFormatRuleBuilder
167
165
  */
168
166
  setBackground(e) {
@@ -179,7 +177,7 @@ class i extends d {
179
177
  /**
180
178
  * Set Bold
181
179
  * @param {boolean} isBold
182
- * @return {*}
180
+ * @returns {*}
183
181
  * @memberof ConditionalFormatRuleBuilder
184
182
  */
185
183
  setBold(e) {
@@ -189,7 +187,7 @@ class i extends d {
189
187
  /**
190
188
  * Sets the font color
191
189
  * @param {string} [color]
192
- * @return {*}
190
+ * @returns {*}
193
191
  * @memberof ConditionalFormatRuleBuilder
194
192
  */
195
193
  setFontColor(e) {
@@ -205,7 +203,7 @@ class i extends d {
205
203
  /**
206
204
  * Set the text to italic
207
205
  * @param {boolean} isItalic
208
- * @return {*}
206
+ * @returns {*}
209
207
  * @memberof ConditionalFormatRuleBuilder
210
208
  */
211
209
  setItalic(e) {
@@ -215,7 +213,7 @@ class i extends d {
215
213
  /**
216
214
  * Set the strikethrough
217
215
  * @param {boolean} isStrikethrough
218
- * @return {*}
216
+ * @returns {*}
219
217
  * @memberof ConditionalFormatRuleBuilder
220
218
  */
221
219
  setStrikethrough(e) {
@@ -225,7 +223,7 @@ class i extends d {
225
223
  /**
226
224
  * Set the underscore
227
225
  * @param {boolean} isUnderline
228
- * @return {*}
226
+ * @returns {*}
229
227
  * @memberof ConditionalFormatRuleBuilder
230
228
  */
231
229
  setUnderline(e) {
@@ -241,7 +239,7 @@ class i extends d {
241
239
  }
242
240
  /**
243
241
  * Sets the conditional formatting rule to fire when the cell is not empty
244
- * @return {*}
242
+ * @returns {*}
245
243
  * @memberof ConditionalFormatRuleBuilder
246
244
  */
247
245
  whenCellNotEmpty() {
@@ -250,9 +248,8 @@ class i extends d {
250
248
  }
251
249
  /**
252
250
  * Highlight when the date is in a time period, custom time is not supported.
253
- *
254
251
  * @param {CFTimePeriodOperator} date
255
- * @return {*}
252
+ * @returns {*}
256
253
  * @memberof ConditionalFormatRuleBuilder
257
254
  */
258
255
  whenDate(e) {
@@ -280,7 +277,6 @@ class i extends d {
280
277
  }
281
278
  /**
282
279
  * Sets the conditional formatting rule to fire when the number equals the given value
283
- *
284
280
  * @param {number} value
285
281
  * @memberof ConditionalFormatRuleBuilder
286
282
  */
@@ -336,6 +332,7 @@ class i extends d {
336
332
  }
337
333
  /**
338
334
  * Sets the conditional formatting rule to fire when a number does not equal a given value.
335
+ * @param value
339
336
  * @memberof ConditionalFormatRuleBuilder
340
337
  */
341
338
  whenNumberNotEqualTo(e) {
@@ -388,13 +385,12 @@ class i extends d {
388
385
  return t.type = n.highlightCell, t.subType = o.text, t.value = e, t.operator = g.beginsWith, this;
389
386
  }
390
387
  }
391
- class m extends d {
388
+ class w extends d {
392
389
  copy() {
393
- return new m(_.deepClone(this._rule));
390
+ return new w(_.deepClone(this._rule));
394
391
  }
395
392
  /**
396
393
  * Data bar settings
397
- *
398
394
  * @param {{
399
395
  * min: IValueConfig;
400
396
  * max: IValueConfig;
@@ -403,6 +399,12 @@ class m extends d {
403
399
  * nativeColor: string;
404
400
  * isShowValue?: boolean;
405
401
  * }} config
402
+ * @param config.min
403
+ * @param config.max
404
+ * @param config.isGradient
405
+ * @param config.positiveColor
406
+ * @param config.nativeColor
407
+ * @param config.isShowValue
406
408
  * @memberof ConditionalFormatRuleBuilder
407
409
  */
408
410
  setDataBar(e) {
@@ -416,9 +418,9 @@ class m extends d {
416
418
  }, this;
417
419
  }
418
420
  }
419
- class w extends d {
421
+ class p extends d {
420
422
  copy() {
421
- return new w(_.deepClone(this._rule));
423
+ return new p(_.deepClone(this._rule));
422
424
  }
423
425
  /**
424
426
  * Color scale set
@@ -430,14 +432,16 @@ class w extends d {
430
432
  return t.type = n.colorScale, t.config = e, this;
431
433
  }
432
434
  }
433
- class p extends d {
435
+ class y extends d {
434
436
  copy() {
435
- return new p(_.deepClone(this._rule));
437
+ return new y(_.deepClone(this._rule));
436
438
  }
437
439
  /**
438
440
  *
439
441
  * Icon Set
440
442
  * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
443
+ * @param config.iconConfigs
444
+ * @param config.isShowValue
441
445
  * @memberof ConditionalFormatRuleBuilder
442
446
  */
443
447
  setIconSet(e) {
@@ -445,7 +449,7 @@ class p extends d {
445
449
  return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
446
450
  }
447
451
  }
448
- class R {
452
+ class m {
449
453
  constructor(e = {}) {
450
454
  this._initConfig = e;
451
455
  }
@@ -454,7 +458,6 @@ class R {
454
458
  }
455
459
  /**
456
460
  * Set average rule
457
- *
458
461
  * @param {IAverageHighlightCell['operator']} operator
459
462
  * @memberof ConditionalFormatHighlightRuleBuilder
460
463
  */
@@ -463,7 +466,6 @@ class R {
463
466
  }
464
467
  /**
465
468
  * Set uniqueValues rule
466
- *
467
469
  * @memberof ConditionalFormatHighlightRuleBuilder
468
470
  */
469
471
  setUniqueValues() {
@@ -471,7 +473,6 @@ class R {
471
473
  }
472
474
  /**
473
475
  * Set duplicateValues rule
474
- *
475
476
  * @memberof ConditionalFormatHighlightRuleBuilder
476
477
  */
477
478
  setDuplicateValues() {
@@ -479,8 +480,10 @@ class R {
479
480
  }
480
481
  /**
481
482
  * Set rank rule
482
- *
483
483
  * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
484
+ * @param config.isBottom
485
+ * @param config.isPercent
486
+ * @param config.value
484
487
  * @memberof ConditionalFormatHighlightRuleBuilder
485
488
  */
486
489
  setRank(e) {
@@ -490,10 +493,12 @@ class R {
490
493
  *
491
494
  * Set iconSet rule
492
495
  * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
496
+ * @param config.iconConfigs
497
+ * @param config.isShowValue
493
498
  * @memberof ConditionalFormatRuleBuilder
494
499
  */
495
500
  setIconSet(e) {
496
- return new p(this._initConfig).setIconSet(e);
501
+ return new y(this._initConfig).setIconSet(e);
497
502
  }
498
503
  /**
499
504
  * Set colorScale rule
@@ -501,11 +506,10 @@ class R {
501
506
  * @memberof ConditionalFormatRuleBuilder
502
507
  */
503
508
  setColorScale(e) {
504
- return new w(this._initConfig).setColorScale(e);
509
+ return new p(this._initConfig).setColorScale(e);
505
510
  }
506
511
  /**
507
512
  * Set dataBar rule
508
- *
509
513
  * @param {{
510
514
  * min: IValueConfig;
511
515
  * max: IValueConfig;
@@ -514,15 +518,21 @@ class R {
514
518
  * nativeColor: string;
515
519
  * isShowValue?: boolean;
516
520
  * }} config
521
+ * @param config.min
522
+ * @param config.max
523
+ * @param config.isGradient
524
+ * @param config.positiveColor
525
+ * @param config.nativeColor
526
+ * @param config.isShowValue
517
527
  * @memberof ConditionalFormatRuleBuilder
518
528
  */
519
529
  setDataBar(e) {
520
- return new m(this._initConfig).setDataBar(e);
530
+ return new w(this._initConfig).setDataBar(e);
521
531
  }
522
532
  /**
523
533
  * Sets the background color
524
534
  * @param {string} [color]
525
- * @return {*}
535
+ * @returns {*}
526
536
  * @memberof ConditionalFormatRuleBuilder
527
537
  */
528
538
  setBackground(e) {
@@ -531,7 +541,7 @@ class R {
531
541
  /**
532
542
  * Set Bold
533
543
  * @param {boolean} isBold
534
- * @return {*}
544
+ * @returns {*}
535
545
  * @memberof ConditionalFormatRuleBuilder
536
546
  */
537
547
  setBold(e) {
@@ -540,7 +550,7 @@ class R {
540
550
  /**
541
551
  * Sets the font color
542
552
  * @param {string} [color]
543
- * @return {*}
553
+ * @returns {*}
544
554
  * @memberof ConditionalFormatRuleBuilder
545
555
  */
546
556
  setFontColor(e) {
@@ -549,7 +559,7 @@ class R {
549
559
  /**
550
560
  * Set the text to italic
551
561
  * @param {boolean} isItalic
552
- * @return {*}
562
+ * @returns {*}
553
563
  * @memberof ConditionalFormatRuleBuilder
554
564
  */
555
565
  setItalic(e) {
@@ -558,7 +568,7 @@ class R {
558
568
  /**
559
569
  * Set the strikethrough
560
570
  * @param {boolean} isStrikethrough
561
- * @return {*}
571
+ * @returns {*}
562
572
  * @memberof ConditionalFormatRuleBuilder
563
573
  */
564
574
  setStrikethrough(e) {
@@ -567,7 +577,7 @@ class R {
567
577
  /**
568
578
  * Set the underscore
569
579
  * @param {boolean} isUnderline
570
- * @return {*}
580
+ * @returns {*}
571
581
  * @memberof ConditionalFormatRuleBuilder
572
582
  */
573
583
  setUnderline(e) {
@@ -581,7 +591,7 @@ class R {
581
591
  }
582
592
  /**
583
593
  * Sets the conditional formatting rule to fire when the cell is not empty
584
- * @return {*}
594
+ * @returns {*}
585
595
  * @memberof ConditionalFormatRuleBuilder
586
596
  */
587
597
  whenCellNotEmpty() {
@@ -589,9 +599,8 @@ class R {
589
599
  }
590
600
  /**
591
601
  * Highlight when the date is in a time period, custom time is not supported.
592
- *
593
602
  * @param {CFTimePeriodOperator} date
594
- * @return {*}
603
+ * @returns {*}
595
604
  * @memberof ConditionalFormatRuleBuilder
596
605
  */
597
606
  whenDate(e) {
@@ -616,7 +625,6 @@ class R {
616
625
  }
617
626
  /**
618
627
  * Sets the conditional formatting rule to fire when the number equals the given value
619
- *
620
628
  * @param {number} value
621
629
  * @memberof ConditionalFormatRuleBuilder
622
630
  */
@@ -666,6 +674,7 @@ class R {
666
674
  }
667
675
  /**
668
676
  * Sets the conditional formatting rule to fire when a number does not equal a given value.
677
+ * @param value
669
678
  * @memberof ConditionalFormatRuleBuilder
670
679
  */
671
680
  whenNumberNotEqualTo(e) {
@@ -714,13 +723,13 @@ class R {
714
723
  }
715
724
  class A extends v {
716
725
  _getConditionalFormattingRuleModel() {
717
- return this._injector.get(T);
726
+ return this._injector.get(x);
718
727
  }
719
728
  getConditionalFormattingRules() {
720
729
  return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => U.intersects(r, this._range)));
721
730
  }
722
731
  createConditionalFormattingRule() {
723
- return new R({ ranges: [this._range] });
732
+ return new m({ ranges: [this._range] });
724
733
  }
725
734
  addConditionalFormattingRule(e) {
726
735
  const t = {
@@ -728,7 +737,7 @@ class A extends v {
728
737
  unitId: this._workbook.getUnitId(),
729
738
  subUnitId: this._worksheet.getSheetId()
730
739
  };
731
- return this._commandService.syncExecuteCommand(x.id, t), this;
740
+ return this._commandService.syncExecuteCommand(S.id, t), this;
732
741
  }
733
742
  deleteConditionalFormattingRule(e) {
734
743
  const t = {
@@ -736,7 +745,7 @@ class A extends v {
736
745
  subUnitId: this._worksheet.getSheetId(),
737
746
  cfId: e
738
747
  };
739
- return this._commandService.syncExecuteCommand(S.id, t), this;
748
+ return this._commandService.syncExecuteCommand(I.id, t), this;
740
749
  }
741
750
  moveConditionalFormattingRule(e, t, r = "after") {
742
751
  const s = {
@@ -745,7 +754,7 @@ class A extends v {
745
754
  start: { id: e, type: "self" },
746
755
  end: { id: t, type: r }
747
756
  };
748
- return this._commandService.syncExecuteCommand(I.id, s), this;
757
+ return this._commandService.syncExecuteCommand(E.id, s), this;
749
758
  }
750
759
  setConditionalFormattingRule(e, t) {
751
760
  const r = {
@@ -754,25 +763,28 @@ class A extends v {
754
763
  rule: t,
755
764
  cfId: e
756
765
  };
757
- return this._commandService.syncExecuteCommand(E.id, r), this;
766
+ return this._commandService.syncExecuteCommand(k.id, r), this;
758
767
  }
759
768
  }
760
769
  v.extend(A);
761
- class D extends k {
770
+ class D extends F {
762
771
  newColor() {
763
772
  return new B();
764
773
  }
765
774
  }
766
- k.extend(D);
767
- class V extends F {
775
+ F.extend(D);
776
+ class V extends R {
768
777
  _getConditionalFormattingRuleModel() {
769
- return this._injector.get(T);
778
+ return this._injector.get(x);
770
779
  }
771
780
  getConditionalFormattingRules() {
772
781
  return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
773
782
  }
774
783
  createConditionalFormattingRule() {
775
- return new R();
784
+ return new m();
785
+ }
786
+ newConditionalFormattingRule() {
787
+ return new m();
776
788
  }
777
789
  addConditionalFormattingRule(e) {
778
790
  const t = {
@@ -780,7 +792,7 @@ class V extends F {
780
792
  unitId: this._workbook.getUnitId(),
781
793
  subUnitId: this._worksheet.getSheetId()
782
794
  };
783
- return this._commandService.syncExecuteCommand(x.id, t), this;
795
+ return this._commandService.syncExecuteCommand(S.id, t), this;
784
796
  }
785
797
  deleteConditionalFormattingRule(e) {
786
798
  const t = {
@@ -788,7 +800,7 @@ class V extends F {
788
800
  subUnitId: this._worksheet.getSheetId(),
789
801
  cfId: e
790
802
  };
791
- return this._commandService.syncExecuteCommand(S.id, t), this;
803
+ return this._commandService.syncExecuteCommand(I.id, t), this;
792
804
  }
793
805
  moveConditionalFormattingRule(e, t, r = "after") {
794
806
  const s = {
@@ -797,7 +809,7 @@ class V extends F {
797
809
  start: { id: e, type: "self" },
798
810
  end: { id: t, type: r }
799
811
  };
800
- return this._commandService.syncExecuteCommand(I.id, s), this;
812
+ return this._commandService.syncExecuteCommand(E.id, s), this;
801
813
  }
802
814
  setConditionalFormattingRule(e, t) {
803
815
  const r = {
@@ -806,10 +818,10 @@ class V extends F {
806
818
  rule: t,
807
819
  cfId: e
808
820
  };
809
- return this._commandService.syncExecuteCommand(E.id, r), this;
821
+ return this._commandService.syncExecuteCommand(k.id, r), this;
810
822
  }
811
823
  }
812
- F.extend(V);
824
+ R.extend(V);
813
825
  export {
814
- R as FConditionalFormattingBuilder
826
+ m as FConditionalFormattingBuilder
815
827
  };