@univerjs/sheets-conditional-formatting 0.5.2-nightly.202501031606 → 0.5.3-experimental.20250106-e3b7a39

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var c=(l,e,t)=>e in l?y(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var T=(l,e,t)=>c(l,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),n=require("@univerjs/sheets-conditional-formatting"),a=require("@univerjs/sheets/facade");class h{constructor(e={}){T(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}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 o.ColorKit("").toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new o.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 o.ColorKit("green").toRgbString(),nativeColor:new o.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.EMPTY_ICON_TYPE,iconId:""},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.EMPTY_ICON_TYPE,iconId:""},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((r,u)=>(r[u]||(r[u]={}),r[u]),e),e}build(){var r;this._rule.cfId||(this._rule.cfId=n.createCfId()),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.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){return new h(o.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return n.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class i extends h{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new i(o.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){const 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 t;if(((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const r=new o.ColorKit(e);this._ruleConfig.style.bg.rgb=r.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell)if(e){const r=new o.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=r.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value="",e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value="",e.operator=n.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const r=Math.min(e,t),u=Math.max(e,t),s=this._ruleConfig;return s.type=n.CFRuleType.highlightCell,s.subType=n.CFSubRuleType.number,s.value=[r,u],s.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){const 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){const 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){const 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){const 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){const 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){const r=Math.min(e,t),u=Math.max(e,t),s=this._ruleConfig;return s.type=n.CFRuleType.highlightCell,s.subType=n.CFSubRuleType.number,s.value=[r,u],s.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const 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){const 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){const 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){const 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){const 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){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}}class C extends h{copy(){return new C(o.Tools.deepClone(this._rule))}setDataBar(e){const 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}}class g extends h{copy(){return new g(o.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}}class p extends h{copy(){return new p(o.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class d{constructor(e={}){this._initConfig=e}build(){return new h(this._initConfig).build()}setAverage(e){return new i(this._initConfig).setAverage(e)}setUniqueValues(){return new i(this._initConfig).setUniqueValues()}setDuplicateValues(){return new i(this._initConfig).setDuplicateValues()}setRank(e){return new i(this._initConfig).setRank(e)}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new g(this._initConfig).setColorScale(e)}setDataBar(e){return new C(this._initConfig).setDataBar(e)}setBackground(e){return new i(this._initConfig).setBackground(e)}setBold(e){return new i(this._initConfig).setBold(e)}setFontColor(e){return new i(this._initConfig).setFontColor(e)}setItalic(e){return new i(this._initConfig).setItalic(e)}setStrikethrough(e){return new i(this._initConfig).setStrikethrough(e)}setUnderline(e){return new i(this._initConfig).setUnderline(e)}whenCellEmpty(){return new i(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new i(this._initConfig).whenCellNotEmpty()}whenDate(e){return new i(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new i(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new i(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new i(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new i(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new i(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new i(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new i(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new i(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new i(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new i(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new i(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new i(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new i(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new i(this._initConfig).whenTextStartsWith(e)}}class m extends a.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(r=>o.Rectangle.intersects(r,this._range)))}createConditionalFormattingRule(){return new d({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,r="after"){const u={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveConditionalRuleMutation.id,u),this}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetConditionalRuleMutation.id,r),this}}a.FRange.extend(m);class _ extends a.FWorkbook{newColor(){return new o.ColorBuilder}}a.FWorkbook.extend(_);class f extends a.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new d}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,r="after"){const u={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveConditionalRuleMutation.id,u),this}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetConditionalRuleMutation.id,r),this}}a.FWorksheet.extend(f);exports.FConditionalFormattingBuilder=d;
1
+ "use strict";var y=Object.defineProperty;var c=(l,e,t)=>e in l?y(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var T=(l,e,t)=>c(l,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),n=require("@univerjs/sheets-conditional-formatting"),a=require("@univerjs/sheets/facade");class h{constructor(e={}){T(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}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 o.ColorKit("").toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new o.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 o.ColorKit("green").toRgbString(),nativeColor:new o.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.EMPTY_ICON_TYPE,iconId:""},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.EMPTY_ICON_TYPE,iconId:""},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((r,u)=>(r[u]||(r[u]={}),r[u]),e),e}build(){var r;this._rule.cfId||(this._rule.cfId=n.createCfId()),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.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){return new h(o.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return n.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class i extends h{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new i(o.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){const 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 t;if(((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const r=new o.ColorKit(e);this._ruleConfig.style.bg.rgb=r.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell)if(e){const r=new o.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=r.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?o.BooleanNumber.TRUE:o.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value="",e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value="",e.operator=n.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const r=Math.min(e,t),u=Math.max(e,t),s=this._ruleConfig;return s.type=n.CFRuleType.highlightCell,s.subType=n.CFSubRuleType.number,s.value=[r,u],s.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){const 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){const 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){const 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){const 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){const 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){const r=Math.min(e,t),u=Math.max(e,t),s=this._ruleConfig;return s.type=n.CFRuleType.highlightCell,s.subType=n.CFSubRuleType.number,s.value=[r,u],s.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const 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){const 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){const 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){const 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){const 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){const t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}}class g extends h{copy(){return new g(o.Tools.deepClone(this._rule))}setDataBar(e){const 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}}class p extends h{copy(){return new p(o.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}}class d extends h{copy(){return new d(o.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class C{constructor(e={}){this._initConfig=e}build(){return new h(this._initConfig).build()}setAverage(e){return new i(this._initConfig).setAverage(e)}setUniqueValues(){return new i(this._initConfig).setUniqueValues()}setDuplicateValues(){return new i(this._initConfig).setDuplicateValues()}setRank(e){return new i(this._initConfig).setRank(e)}setIconSet(e){return new d(this._initConfig).setIconSet(e)}setColorScale(e){return new p(this._initConfig).setColorScale(e)}setDataBar(e){return new g(this._initConfig).setDataBar(e)}setBackground(e){return new i(this._initConfig).setBackground(e)}setBold(e){return new i(this._initConfig).setBold(e)}setFontColor(e){return new i(this._initConfig).setFontColor(e)}setItalic(e){return new i(this._initConfig).setItalic(e)}setStrikethrough(e){return new i(this._initConfig).setStrikethrough(e)}setUnderline(e){return new i(this._initConfig).setUnderline(e)}whenCellEmpty(){return new i(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new i(this._initConfig).whenCellNotEmpty()}whenDate(e){return new i(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new i(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new i(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new i(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new i(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new i(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new i(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new i(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new i(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new i(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new i(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new i(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new i(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new i(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new i(this._initConfig).whenTextStartsWith(e)}}class m extends a.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(r=>o.Rectangle.intersects(r,this._range)))}createConditionalFormattingRule(){return new C({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,r="after"){const u={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveConditionalRuleMutation.id,u),this}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetConditionalRuleMutation.id,r),this}}a.FRange.extend(m);class _ extends a.FWorkbook{newColor(){return new o.ColorBuilder}}a.FWorkbook.extend(_);class f extends a.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new C}newConditionalFormattingRule(){return new C}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,r="after"){const u={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveConditionalRuleMutation.id,u),this}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetConditionalRuleMutation.id,r),this}}a.FWorksheet.extend(f);exports.FConditionalFormattingBuilder=C;
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 v } from "@univerjs/sheets-conditional-formatting";
6
+ import { FRange as k, 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) {
@@ -712,15 +721,15 @@ class R {
712
721
  return new i(this._initConfig).whenTextStartsWith(e);
713
722
  }
714
723
  }
715
- class A extends v {
724
+ class A extends k {
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(v.id, r), this;
758
767
  }
759
768
  }
760
- v.extend(A);
761
- class D extends k {
769
+ k.extend(A);
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(v.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
  };
@@ -8,15 +8,14 @@ declare class ConditionalFormatRuleBaseBuilder {
8
8
  protected _ensureAttr(obj: Record<string, any>, keys: string[]): Record<string, any>;
9
9
  build(): IConditionFormattingRule<IConditionalFormattingRuleConfig>;
10
10
  /**
11
- * deep clone a current builder.
12
- *
13
- * @return {*}
11
+ * Deep clone a current builder.
12
+ * @returns {*}
14
13
  * @memberof ConditionalFormatRuleBuilder
15
14
  */
16
15
  copy(): ConditionalFormatRuleBaseBuilder;
17
16
  /**
18
17
  * Gets the scope of the current conditional format
19
- * @return {*}
18
+ * @returns {*}
20
19
  * @memberof ConditionalFormatRuleBuilder
21
20
  */
22
21
  getRanges(): IRange[];
@@ -25,15 +24,15 @@ declare class ConditionalFormatRuleBaseBuilder {
25
24
  */
26
25
  getIconMap(): Record<string, string[]>;
27
26
  /**
28
- * create a conditional format ID.
29
- * @return {*}
27
+ * Create a conditional format ID.
28
+ * @returns {*}
30
29
  * @memberof ConditionalFormatRuleBuilder
31
30
  */
32
31
  createCfId(): string;
33
32
  /**
34
33
  * Sets the scope for conditional formatting
35
34
  * @param {IRange[]} ranges
36
- * @return {*}
35
+ * @returns {*}
37
36
  * @memberof ConditionalFormatRuleBuilder
38
37
  */
39
38
  setRanges(ranges: IRange[]): this;
@@ -43,27 +42,26 @@ declare class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRul
43
42
  copy(): ConditionalFormatHighlightRuleBuilder;
44
43
  /**
45
44
  * Set average rule
46
- *
47
45
  * @param {IAverageHighlightCell['operator']} operator
48
46
  * @memberof ConditionalFormatHighlightRuleBuilder
49
47
  */
50
48
  setAverage(operator: IAverageHighlightCell['operator']): this;
51
49
  /**
52
50
  * Set uniqueValues rule
53
- *
54
51
  * @memberof ConditionalFormatHighlightRuleBuilder
55
52
  */
56
53
  setUniqueValues(): this;
57
54
  /**
58
55
  * Set duplicateValues rule
59
- *
60
56
  * @memberof ConditionalFormatHighlightRuleBuilder
61
57
  */
62
58
  setDuplicateValues(): this;
63
59
  /**
64
60
  * Set rank rule
65
- *
66
61
  * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
62
+ * @param config.isBottom
63
+ * @param config.isPercent
64
+ * @param config.value
67
65
  * @memberof ConditionalFormatHighlightRuleBuilder
68
66
  */
69
67
  setRank(config: {
@@ -74,42 +72,42 @@ declare class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRul
74
72
  /**
75
73
  * Sets the background color
76
74
  * @param {string} [color]
77
- * @return {*}
75
+ * @returns {*}
78
76
  * @memberof ConditionalFormatRuleBuilder
79
77
  */
80
78
  setBackground(color?: string): this;
81
79
  /**
82
80
  * Set Bold
83
81
  * @param {boolean} isBold
84
- * @return {*}
82
+ * @returns {*}
85
83
  * @memberof ConditionalFormatRuleBuilder
86
84
  */
87
85
  setBold(isBold: boolean): this;
88
86
  /**
89
87
  * Sets the font color
90
88
  * @param {string} [color]
91
- * @return {*}
89
+ * @returns {*}
92
90
  * @memberof ConditionalFormatRuleBuilder
93
91
  */
94
92
  setFontColor(color?: string): this;
95
93
  /**
96
94
  * Set the text to italic
97
95
  * @param {boolean} isItalic
98
- * @return {*}
96
+ * @returns {*}
99
97
  * @memberof ConditionalFormatRuleBuilder
100
98
  */
101
99
  setItalic(isItalic: boolean): this;
102
100
  /**
103
101
  * Set the strikethrough
104
102
  * @param {boolean} isStrikethrough
105
- * @return {*}
103
+ * @returns {*}
106
104
  * @memberof ConditionalFormatRuleBuilder
107
105
  */
108
106
  setStrikethrough(isStrikethrough: boolean): this;
109
107
  /**
110
108
  * Set the underscore
111
109
  * @param {boolean} isUnderline
112
- * @return {*}
110
+ * @returns {*}
113
111
  * @memberof ConditionalFormatRuleBuilder
114
112
  */
115
113
  setUnderline(isUnderline: boolean): this;
@@ -119,15 +117,14 @@ declare class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRul
119
117
  whenCellEmpty(): this;
120
118
  /**
121
119
  * Sets the conditional formatting rule to fire when the cell is not empty
122
- * @return {*}
120
+ * @returns {*}
123
121
  * @memberof ConditionalFormatRuleBuilder
124
122
  */
125
123
  whenCellNotEmpty(): this;
126
124
  /**
127
125
  * Highlight when the date is in a time period, custom time is not supported.
128
- *
129
126
  * @param {CFTimePeriodOperator} date
130
- * @return {*}
127
+ * @returns {*}
131
128
  * @memberof ConditionalFormatRuleBuilder
132
129
  */
133
130
  whenDate(date: CFTimePeriodOperator): this;
@@ -146,7 +143,6 @@ declare class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRul
146
143
  whenNumberBetween(start: number, end: number): this;
147
144
  /**
148
145
  * Sets the conditional formatting rule to fire when the number equals the given value
149
- *
150
146
  * @param {number} value
151
147
  * @memberof ConditionalFormatRuleBuilder
152
148
  */
@@ -184,6 +180,7 @@ declare class ConditionalFormatHighlightRuleBuilder extends ConditionalFormatRul
184
180
  whenNumberNotBetween(start: number, end: number): this;
185
181
  /**
186
182
  * Sets the conditional formatting rule to fire when a number does not equal a given value.
183
+ * @param value
187
184
  * @memberof ConditionalFormatRuleBuilder
188
185
  */
189
186
  whenNumberNotEqualTo(value: number): this;
@@ -222,7 +219,6 @@ declare class ConditionalFormatDataBarRuleBuilder extends ConditionalFormatRuleB
222
219
  copy(): ConditionalFormatDataBarRuleBuilder;
223
220
  /**
224
221
  * Data bar settings
225
- *
226
222
  * @param {{
227
223
  * min: IValueConfig;
228
224
  * max: IValueConfig;
@@ -231,6 +227,12 @@ declare class ConditionalFormatDataBarRuleBuilder extends ConditionalFormatRuleB
231
227
  * nativeColor: string;
232
228
  * isShowValue?: boolean;
233
229
  * }} config
230
+ * @param config.min
231
+ * @param config.max
232
+ * @param config.isGradient
233
+ * @param config.positiveColor
234
+ * @param config.nativeColor
235
+ * @param config.isShowValue
234
236
  * @memberof ConditionalFormatRuleBuilder
235
237
  */
236
238
  setDataBar(config: {
@@ -257,6 +259,8 @@ declare class ConditionalFormatIconSetRuleBuilder extends ConditionalFormatRuleB
257
259
  *
258
260
  * Icon Set
259
261
  * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
262
+ * @param config.iconConfigs
263
+ * @param config.isShowValue
260
264
  * @memberof ConditionalFormatRuleBuilder
261
265
  */
262
266
  setIconSet(config: {
@@ -272,27 +276,26 @@ export declare class FConditionalFormattingBuilder {
272
276
  build(): IConditionFormattingRule<IConditionalFormattingRuleConfig>;
273
277
  /**
274
278
  * Set average rule
275
- *
276
279
  * @param {IAverageHighlightCell['operator']} operator
277
280
  * @memberof ConditionalFormatHighlightRuleBuilder
278
281
  */
279
282
  setAverage(operator: IAverageHighlightCell['operator']): ConditionalFormatHighlightRuleBuilder;
280
283
  /**
281
284
  * Set uniqueValues rule
282
- *
283
285
  * @memberof ConditionalFormatHighlightRuleBuilder
284
286
  */
285
287
  setUniqueValues(): ConditionalFormatHighlightRuleBuilder;
286
288
  /**
287
289
  * Set duplicateValues rule
288
- *
289
290
  * @memberof ConditionalFormatHighlightRuleBuilder
290
291
  */
291
292
  setDuplicateValues(): ConditionalFormatHighlightRuleBuilder;
292
293
  /**
293
294
  * Set rank rule
294
- *
295
295
  * @param {{ isBottom: boolean, isPercent: boolean, value: number }} config
296
+ * @param config.isBottom
297
+ * @param config.isPercent
298
+ * @param config.value
296
299
  * @memberof ConditionalFormatHighlightRuleBuilder
297
300
  */
298
301
  setRank(config: {
@@ -304,6 +307,8 @@ export declare class FConditionalFormattingBuilder {
304
307
  *
305
308
  * Set iconSet rule
306
309
  * @param {{ iconConfigs: IIconSet['config'], isShowValue: boolean }} config
310
+ * @param config.iconConfigs
311
+ * @param config.isShowValue
307
312
  * @memberof ConditionalFormatRuleBuilder
308
313
  */
309
314
  setIconSet(config: {
@@ -318,7 +323,6 @@ export declare class FConditionalFormattingBuilder {
318
323
  setColorScale(config: IColorScale['config']): ConditionalFormatColorScaleRuleBuilder;
319
324
  /**
320
325
  * Set dataBar rule
321
- *
322
326
  * @param {{
323
327
  * min: IValueConfig;
324
328
  * max: IValueConfig;
@@ -327,6 +331,12 @@ export declare class FConditionalFormattingBuilder {
327
331
  * nativeColor: string;
328
332
  * isShowValue?: boolean;
329
333
  * }} config
334
+ * @param config.min
335
+ * @param config.max
336
+ * @param config.isGradient
337
+ * @param config.positiveColor
338
+ * @param config.nativeColor
339
+ * @param config.isShowValue
330
340
  * @memberof ConditionalFormatRuleBuilder
331
341
  */
332
342
  setDataBar(config: {
@@ -340,42 +350,42 @@ export declare class FConditionalFormattingBuilder {
340
350
  /**
341
351
  * Sets the background color
342
352
  * @param {string} [color]
343
- * @return {*}
353
+ * @returns {*}
344
354
  * @memberof ConditionalFormatRuleBuilder
345
355
  */
346
356
  setBackground(color?: string): ConditionalFormatHighlightRuleBuilder;
347
357
  /**
348
358
  * Set Bold
349
359
  * @param {boolean} isBold
350
- * @return {*}
360
+ * @returns {*}
351
361
  * @memberof ConditionalFormatRuleBuilder
352
362
  */
353
363
  setBold(isBold: boolean): ConditionalFormatHighlightRuleBuilder;
354
364
  /**
355
365
  * Sets the font color
356
366
  * @param {string} [color]
357
- * @return {*}
367
+ * @returns {*}
358
368
  * @memberof ConditionalFormatRuleBuilder
359
369
  */
360
370
  setFontColor(color?: string): ConditionalFormatHighlightRuleBuilder;
361
371
  /**
362
372
  * Set the text to italic
363
373
  * @param {boolean} isItalic
364
- * @return {*}
374
+ * @returns {*}
365
375
  * @memberof ConditionalFormatRuleBuilder
366
376
  */
367
377
  setItalic(isItalic: boolean): ConditionalFormatHighlightRuleBuilder;
368
378
  /**
369
379
  * Set the strikethrough
370
380
  * @param {boolean} isStrikethrough
371
- * @return {*}
381
+ * @returns {*}
372
382
  * @memberof ConditionalFormatRuleBuilder
373
383
  */
374
384
  setStrikethrough(isStrikethrough: boolean): ConditionalFormatHighlightRuleBuilder;
375
385
  /**
376
386
  * Set the underscore
377
387
  * @param {boolean} isUnderline
378
- * @return {*}
388
+ * @returns {*}
379
389
  * @memberof ConditionalFormatRuleBuilder
380
390
  */
381
391
  setUnderline(isUnderline: boolean): ConditionalFormatHighlightRuleBuilder;
@@ -385,15 +395,14 @@ export declare class FConditionalFormattingBuilder {
385
395
  whenCellEmpty(): ConditionalFormatHighlightRuleBuilder;
386
396
  /**
387
397
  * Sets the conditional formatting rule to fire when the cell is not empty
388
- * @return {*}
398
+ * @returns {*}
389
399
  * @memberof ConditionalFormatRuleBuilder
390
400
  */
391
401
  whenCellNotEmpty(): ConditionalFormatHighlightRuleBuilder;
392
402
  /**
393
403
  * Highlight when the date is in a time period, custom time is not supported.
394
- *
395
404
  * @param {CFTimePeriodOperator} date
396
- * @return {*}
405
+ * @returns {*}
397
406
  * @memberof ConditionalFormatRuleBuilder
398
407
  */
399
408
  whenDate(date: CFTimePeriodOperator): ConditionalFormatHighlightRuleBuilder;
@@ -412,7 +421,6 @@ export declare class FConditionalFormattingBuilder {
412
421
  whenNumberBetween(start: number, end: number): ConditionalFormatHighlightRuleBuilder;
413
422
  /**
414
423
  * Sets the conditional formatting rule to fire when the number equals the given value
415
- *
416
424
  * @param {number} value
417
425
  * @memberof ConditionalFormatRuleBuilder
418
426
  */
@@ -450,6 +458,7 @@ export declare class FConditionalFormattingBuilder {
450
458
  whenNumberNotBetween(start: number, end: number): ConditionalFormatHighlightRuleBuilder;
451
459
  /**
452
460
  * Sets the conditional formatting rule to fire when a number does not equal a given value.
461
+ * @param value
453
462
  * @memberof ConditionalFormatRuleBuilder
454
463
  */
455
464
  whenNumberNotEqualTo(value: number): ConditionalFormatHighlightRuleBuilder;
@@ -4,7 +4,7 @@ import { FConditionalFormattingBuilder } from './conditional-formatting-builder'
4
4
  export interface IFWorksheetConditionalFormattingMixin {
5
5
  /**
6
6
  * Gets all the conditional formatting for the current sheet
7
- * @return {*} {IConditionFormattingRule[]}
7
+ * @returns {*} {IConditionFormattingRule[]}
8
8
  * @memberof IFWorksheetConditionalFormattingMixin
9
9
  * @example
10
10
  * ```ts
@@ -13,8 +13,9 @@ export interface IFWorksheetConditionalFormattingMixin {
13
13
  */
14
14
  getConditionalFormattingRules(): IConditionFormattingRule[];
15
15
  /**
16
+ * @deprecated use newConditionalFormattingRule instead.
16
17
  * Creates a constructor for conditional formatting
17
- * @return {*} {ConditionalFormatRuleBuilder}
18
+ * @returns {ConditionalFormatRuleBuilder}
18
19
  * @memberof IFWorksheetConditionalFormattingMixin
19
20
  * @example
20
21
  * ```ts
@@ -31,6 +32,25 @@ export interface IFWorksheetConditionalFormattingMixin {
31
32
  * ```
32
33
  */
33
34
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
35
+ /**
36
+ * Creates a constructor for conditional formatting
37
+ * @returns {ConditionalFormatRuleBuilder}@example
38
+ * @memberof IFWorksheetConditionalFormattingMixin
39
+ * @example
40
+ * ```ts
41
+ * const workbook = univerAPI.getActiveWorkbook();
42
+ * const worksheet = workbook?.getActiveSheet();
43
+ * const rule = worksheet?.createConditionalFormattingRule()
44
+ * .whenCellNotEmpty()
45
+ * .setRanges([{ startRow: 0, endRow: 100, startColumn: 0, endColumn: 100 }])
46
+ * .setItalic(true)
47
+ * .setItalic(true)
48
+ * .setBackground('red')
49
+ * .setFontColor('green')
50
+ * .build();
51
+ * ```
52
+ */
53
+ newConditionalFormattingRule(): FConditionalFormattingBuilder;
34
54
  /**
35
55
  * Add a new conditional format
36
56
  * @param {IConditionFormattingRule} rule
@@ -54,7 +74,6 @@ export interface IFWorksheetConditionalFormattingMixin {
54
74
  addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
55
75
  /**
56
76
  * Delete conditional format according to `cfId`
57
- *
58
77
  * @param {string} cfId
59
78
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
60
79
  * @memberof IFWorksheetConditionalFormattingMixin
@@ -106,6 +125,7 @@ export declare class FWorksheetConditionalFormattingMixin extends FWorksheet imp
106
125
  private _getConditionalFormattingRuleModel;
107
126
  getConditionalFormattingRules(): IConditionFormattingRule[];
108
127
  createConditionalFormattingRule(): FConditionalFormattingBuilder;
128
+ newConditionalFormattingRule(): FConditionalFormattingBuilder;
109
129
  addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
110
130
  deleteConditionalFormattingRule(cfId: string): FWorksheet;
111
131
  moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FWorksheet;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets/facade"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.UniverSheetsConditionalFormattingFacade={},i.UniverCore,i.UniverSheetsConditionalFormatting,i.UniverSheetsFacade))})(this,function(i,r,u,p){"use strict";var w=Object.defineProperty;var R=(i,r,u)=>r in i?w(i,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[r]=u;var _=(i,r,u)=>R(i,typeof r!="symbol"?r+"":r,u);class o{constructor(e={}){_(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=u.CFRuleType.highlightCell){switch(e){case u.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new r.ColorKit("").toRgbString(),value:{type:u.CFValueType.min}},{index:0,color:new r.ColorKit("green").toRgbString(),value:{type:u.CFValueType.max}}]};case u.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:u.CFValueType.min},max:{type:u.CFValueType.max},positiveColor:new r.ColorKit("green").toRgbString(),nativeColor:new r.ColorKit("").toRgbString(),isGradient:!1}};case u.CFRuleType.highlightCell:return{type:e,subType:u.CFSubRuleType.text,operator:u.CFTextOperator.containsText,value:"abc",style:{}};case u.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:u.CFNumberOperator.greaterThanOrEqual,value:{type:u.CFValueType.min},iconType:u.EMPTY_ICON_TYPE,iconId:""},{operator:u.CFNumberOperator.greaterThanOrEqual,value:{type:u.CFValueType.percentile,value:.5},iconType:u.EMPTY_ICON_TYPE,iconId:""},{operator:u.CFNumberOperator.lessThanOrEqual,value:{type:u.CFValueType.max},iconType:u.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((l,s)=>(l[s]||(l[s]={}),l[s]),e),e}build(){var l;this._rule.cfId||(this._rule.cfId=u.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(l=this._rule.rule)!=null&&l.type||(this._rule.rule.type=u.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){return new o(r.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return u.iconMap}createCfId(){return u.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class n extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new n(r.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.duplicateValues,this}setRank(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const l=new r.ColorKit(e);this._ruleConfig.style.bg.rgb=l.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell)if(e){const l=new r.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=l.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.text,e.value="",e.operator=u.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.text,e.value="",e.operator=u.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const l=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=u.CFRuleType.highlightCell,h.subType=u.CFSubRuleType.number,h.value=[l,s],h.operator=u.CFNumberOperator.between,this}whenNumberEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){const l=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=u.CFRuleType.highlightCell,h.subType=u.CFSubRuleType.number,h.value=[l,s],h.operator=u.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.notEqual,this}whenTextContains(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.endsWith,this}whenTextEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.equal,this}whenTextStartsWith(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.beginsWith,this}}class C extends o{copy(){return new C(r.Tools.deepClone(this._rule))}setDataBar(e){const t=this._ruleConfig;return t.type=u.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}}class a extends o{copy(){return new a(r.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=u.CFRuleType.colorScale,t.config=e,this}}class g extends o{copy(){return new g(r.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=u.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class T{constructor(e={}){this._initConfig=e}build(){return new o(this._initConfig).build()}setAverage(e){return new n(this._initConfig).setAverage(e)}setUniqueValues(){return new n(this._initConfig).setUniqueValues()}setDuplicateValues(){return new n(this._initConfig).setDuplicateValues()}setRank(e){return new n(this._initConfig).setRank(e)}setIconSet(e){return new g(this._initConfig).setIconSet(e)}setColorScale(e){return new a(this._initConfig).setColorScale(e)}setDataBar(e){return new C(this._initConfig).setDataBar(e)}setBackground(e){return new n(this._initConfig).setBackground(e)}setBold(e){return new n(this._initConfig).setBold(e)}setFontColor(e){return new n(this._initConfig).setFontColor(e)}setItalic(e){return new n(this._initConfig).setItalic(e)}setStrikethrough(e){return new n(this._initConfig).setStrikethrough(e)}setUnderline(e){return new n(this._initConfig).setUnderline(e)}whenCellEmpty(){return new n(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new n(this._initConfig).whenCellNotEmpty()}whenDate(e){return new n(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new n(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new n(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new n(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new n(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new n(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new n(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new n(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new n(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new n(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new n(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new n(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new n(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new n(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new n(this._initConfig).whenTextStartsWith(e)}}class f extends p.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(u.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(l=>r.Rectangle.intersects(l,this._range)))}createConditionalFormattingRule(){return new T({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(u.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(u.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:l}};return this._commandService.syncExecuteCommand(u.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(u.SetConditionalRuleMutation.id,l),this}}p.FRange.extend(f);class c extends p.FWorkbook{newColor(){return new r.ColorBuilder}}p.FWorkbook.extend(c);class b extends p.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(u.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new T}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(u.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(u.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:l}};return this._commandService.syncExecuteCommand(u.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(u.SetConditionalRuleMutation.id,l),this}}p.FWorksheet.extend(b),i.FConditionalFormattingBuilder=T,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets/facade"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.UniverSheetsConditionalFormattingFacade={},i.UniverCore,i.UniverSheetsConditionalFormatting,i.UniverSheetsFacade))})(this,function(i,r,u,p){"use strict";var w=Object.defineProperty;var R=(i,r,u)=>r in i?w(i,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[r]=u;var _=(i,r,u)=>R(i,typeof r!="symbol"?r+"":r,u);class o{constructor(e={}){_(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=u.CFRuleType.highlightCell){switch(e){case u.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new r.ColorKit("").toRgbString(),value:{type:u.CFValueType.min}},{index:0,color:new r.ColorKit("green").toRgbString(),value:{type:u.CFValueType.max}}]};case u.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:u.CFValueType.min},max:{type:u.CFValueType.max},positiveColor:new r.ColorKit("green").toRgbString(),nativeColor:new r.ColorKit("").toRgbString(),isGradient:!1}};case u.CFRuleType.highlightCell:return{type:e,subType:u.CFSubRuleType.text,operator:u.CFTextOperator.containsText,value:"abc",style:{}};case u.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:u.CFNumberOperator.greaterThanOrEqual,value:{type:u.CFValueType.min},iconType:u.EMPTY_ICON_TYPE,iconId:""},{operator:u.CFNumberOperator.greaterThanOrEqual,value:{type:u.CFValueType.percentile,value:.5},iconType:u.EMPTY_ICON_TYPE,iconId:""},{operator:u.CFNumberOperator.lessThanOrEqual,value:{type:u.CFValueType.max},iconType:u.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((l,s)=>(l[s]||(l[s]={}),l[s]),e),e}build(){var l;this._rule.cfId||(this._rule.cfId=u.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(l=this._rule.rule)!=null&&l.type||(this._rule.rule.type=u.CFRuleType.highlightCell,this._ensureAttr(this._rule,["rule","style"]));const e=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...e,...this._rule.rule}}}copy(){return new o(r.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return u.iconMap}createCfId(){return u.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class n extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new n(r.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.duplicateValues,this}setRank(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const l=new r.ColorKit(e);this._ruleConfig.style.bg.rgb=l.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell)if(e){const l=new r.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=l.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===u.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?r.BooleanNumber.TRUE:r.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.text,e.value="",e.operator=u.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=u.CFRuleType.highlightCell,e.subType=u.CFSubRuleType.text,e.value="",e.operator=u.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const l=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=u.CFRuleType.highlightCell,h.subType=u.CFSubRuleType.number,h.value=[l,s],h.operator=u.CFNumberOperator.between,this}whenNumberEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){const l=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=u.CFRuleType.highlightCell,h.subType=u.CFSubRuleType.number,h.value=[l,s],h.operator=u.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.number,t.value=e,t.operator=u.CFNumberOperator.notEqual,this}whenTextContains(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.endsWith,this}whenTextEqualTo(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.equal,this}whenTextStartsWith(e){const t=this._ruleConfig;return t.type=u.CFRuleType.highlightCell,t.subType=u.CFSubRuleType.text,t.value=e,t.operator=u.CFTextOperator.beginsWith,this}}class a extends o{copy(){return new a(r.Tools.deepClone(this._rule))}setDataBar(e){const t=this._ruleConfig;return t.type=u.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}}class g extends o{copy(){return new g(r.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=u.CFRuleType.colorScale,t.config=e,this}}class T extends o{copy(){return new T(r.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=u.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class C{constructor(e={}){this._initConfig=e}build(){return new o(this._initConfig).build()}setAverage(e){return new n(this._initConfig).setAverage(e)}setUniqueValues(){return new n(this._initConfig).setUniqueValues()}setDuplicateValues(){return new n(this._initConfig).setDuplicateValues()}setRank(e){return new n(this._initConfig).setRank(e)}setIconSet(e){return new T(this._initConfig).setIconSet(e)}setColorScale(e){return new g(this._initConfig).setColorScale(e)}setDataBar(e){return new a(this._initConfig).setDataBar(e)}setBackground(e){return new n(this._initConfig).setBackground(e)}setBold(e){return new n(this._initConfig).setBold(e)}setFontColor(e){return new n(this._initConfig).setFontColor(e)}setItalic(e){return new n(this._initConfig).setItalic(e)}setStrikethrough(e){return new n(this._initConfig).setStrikethrough(e)}setUnderline(e){return new n(this._initConfig).setUnderline(e)}whenCellEmpty(){return new n(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new n(this._initConfig).whenCellNotEmpty()}whenDate(e){return new n(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new n(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new n(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new n(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new n(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new n(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new n(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new n(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new n(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new n(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new n(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new n(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new n(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new n(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new n(this._initConfig).whenTextStartsWith(e)}}class f extends p.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(u.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(l=>r.Rectangle.intersects(l,this._range)))}createConditionalFormattingRule(){return new C({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(u.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(u.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:l}};return this._commandService.syncExecuteCommand(u.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(u.SetConditionalRuleMutation.id,l),this}}p.FRange.extend(f);class c extends p.FWorkbook{newColor(){return new r.ColorBuilder}}p.FWorkbook.extend(c);class b extends p.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(u.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new C}newConditionalFormattingRule(){return new C}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(u.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(u.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:l}};return this._commandService.syncExecuteCommand(u.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(u.SetConditionalRuleMutation.id,l),this}}p.FWorksheet.extend(b),i.FConditionalFormattingBuilder=C,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting",
3
- "version": "0.5.2-nightly.202501031606",
3
+ "version": "0.5.3-experimental.20250106-e3b7a39",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,10 +53,10 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/core": "0.5.2-nightly.202501031606",
57
- "@univerjs/engine-formula": "0.5.2-nightly.202501031606",
58
- "@univerjs/engine-render": "0.5.2-nightly.202501031606",
59
- "@univerjs/sheets": "0.5.2-nightly.202501031606"
56
+ "@univerjs/core": "0.5.3-experimental.20250106-e3b7a39",
57
+ "@univerjs/engine-formula": "0.5.3-experimental.20250106-e3b7a39",
58
+ "@univerjs/engine-render": "0.5.3-experimental.20250106-e3b7a39",
59
+ "@univerjs/sheets": "0.5.3-experimental.20250106-e3b7a39"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@univerjs/icons-svg": "^0.2.10",
@@ -64,7 +64,7 @@
64
64
  "typescript": "^5.7.2",
65
65
  "vite": "^6.0.6",
66
66
  "vitest": "^2.1.8",
67
- "@univerjs-infra/shared": "0.5.2"
67
+ "@univerjs-infra/shared": "0.5.3"
68
68
  },
69
69
  "scripts": {
70
70
  "test": "vitest run",