@univerjs/sheets-conditional-formatting 0.24.0 → 0.25.0
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 +142 -73
- package/lib/cjs/index.js +7 -7
- package/lib/es/facade.js +142 -73
- package/lib/es/index.js +7 -7
- package/lib/facade.js +142 -73
- package/lib/index.js +7 -7
- package/lib/types/facade/f-conditional-formatting-builder.d.ts +138 -69
- package/lib/types/facade/f-range.d.ts +6 -3
- package/lib/types/facade/f-worksheet.d.ts +14 -7
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
|
@@ -26,7 +26,8 @@ export interface IFRangeSheetsConditionalFormattingMixin {
|
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|
|
28
28
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
29
|
-
* const fWorksheet = fWorkbook.
|
|
29
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
30
|
+
* if (!fWorksheet) return;
|
|
30
31
|
*
|
|
31
32
|
* // Create a conditional formatting rule that sets the cell format to italic, red background, and green font color when the cell is not empty.
|
|
32
33
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
@@ -52,7 +53,8 @@ export interface IFRangeSheetsConditionalFormattingMixin {
|
|
|
52
53
|
* @example
|
|
53
54
|
* ```ts
|
|
54
55
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
55
|
-
* const fWorksheet = fWorkbook.
|
|
56
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
57
|
+
* if (!fWorksheet) return;
|
|
56
58
|
*
|
|
57
59
|
* // Create a conditional formatting rule that sets the cell format to italic, red background, and green font color when the cell is not empty.
|
|
58
60
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
@@ -109,7 +111,8 @@ export interface IFRangeSheetsConditionalFormattingMixin {
|
|
|
109
111
|
* @example
|
|
110
112
|
* ```ts
|
|
111
113
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
112
|
-
* const fWorksheet = fWorkbook.
|
|
114
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
115
|
+
* if (!fWorksheet) return;
|
|
113
116
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
114
117
|
*
|
|
115
118
|
* // Clear all conditional format rules for the range
|
|
@@ -27,7 +27,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
29
29
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
30
|
-
* const fWorksheet = fWorkbook.
|
|
30
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
31
|
+
* if (!fWorksheet) return;
|
|
31
32
|
* const rules = fWorksheet.getConditionalFormattingRules();
|
|
32
33
|
* console.log(rules);
|
|
33
34
|
* ```
|
|
@@ -47,7 +48,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
50
|
-
* const fWorksheet = fWorkbook.
|
|
51
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
52
|
+
* if (!fWorksheet) return;
|
|
51
53
|
*
|
|
52
54
|
* // Create a conditional formatting rule that sets the cell format to italic, red background, and green font color when the cell is not empty.
|
|
53
55
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
@@ -70,7 +72,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
70
72
|
* @example
|
|
71
73
|
* ```ts
|
|
72
74
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
73
|
-
* const fWorksheet = fWorkbook.
|
|
75
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
76
|
+
* if (!fWorksheet) return;
|
|
74
77
|
*
|
|
75
78
|
* // Create a conditional formatting rule that sets the cell format to italic, red background, and green font color when the cell is not empty.
|
|
76
79
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
@@ -93,7 +96,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
93
96
|
* @example
|
|
94
97
|
* ```ts
|
|
95
98
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
96
|
-
* const fWorksheet = fWorkbook.
|
|
99
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
100
|
+
* if (!fWorksheet) return;
|
|
97
101
|
* const rules = fWorksheet.getConditionalFormattingRules();
|
|
98
102
|
*
|
|
99
103
|
* // Delete the first rule
|
|
@@ -111,7 +115,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
111
115
|
* @example
|
|
112
116
|
* ```ts
|
|
113
117
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
114
|
-
* const fWorksheet = fWorkbook.
|
|
118
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
119
|
+
* if (!fWorksheet) return;
|
|
115
120
|
* const rules = fWorksheet.getConditionalFormattingRules();
|
|
116
121
|
*
|
|
117
122
|
* // Move the third rule before the first rule
|
|
@@ -130,7 +135,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
130
135
|
* @example
|
|
131
136
|
* ```ts
|
|
132
137
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
133
|
-
* const fWorksheet = fWorkbook.
|
|
138
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
139
|
+
* if (!fWorksheet) return;
|
|
134
140
|
*
|
|
135
141
|
* // Create a conditional formatting rule that sets the cell format to italic, red background, and green font color when the cell is not empty.
|
|
136
142
|
* const fRange = fWorksheet.getRange('A1:T100');
|
|
@@ -157,7 +163,8 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
157
163
|
* @example
|
|
158
164
|
* ```ts
|
|
159
165
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
160
|
-
* const fWorksheet = fWorkbook.
|
|
166
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
167
|
+
* if (!fWorksheet) return;
|
|
161
168
|
* fWorksheet.clearConditionalFormatRules();
|
|
162
169
|
* console.log(fWorksheet.getConditionalFormattingRules()); // []
|
|
163
170
|
* ```
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets-conditional-formatting`),require(`@univerjs/sheets/facade`),require(`@univerjs/core/facade`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new m}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new m}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|