@univerjs/sheets-conditional-formatting 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/es/facade.js +35 -35
- package/lib/types/facade/f-range.d.ts +16 -15
- package/lib/types/facade/f-workbook.d.ts +3 -0
- package/lib/types/facade/f-worksheet.d.ts +12 -11
- package/lib/umd/facade.js +1 -1
- package/package.json +8 -26
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var m=(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)=>m(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 _ 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.executeCommand(n.AddConditionalRuleMutation.id,t)}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.executeCommand(n.DeleteConditionalRuleMutation.id,t)}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.executeCommand(n.MoveConditionalRuleMutation.id,u)}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.executeCommand(n.SetConditionalRuleMutation.id,r)}}a.FRange.extend(_);class c extends a.FWorkbook{newColor(){return new o.ColorBuilder}}a.FWorkbook.extend(c);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.executeCommand(n.AddConditionalRuleMutation.id,t)}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.executeCommand(n.DeleteConditionalRuleMutation.id,t)}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.executeCommand(n.MoveConditionalRuleMutation.id,u)}setConditionalFormattingRule(e,t){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.executeCommand(n.SetConditionalRuleMutation.id,r)}}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 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;
|
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
|
|
4
|
-
import { ColorKit as
|
|
5
|
-
import { CFRuleType as n, CFNumberOperator as l, CFValueType as C, EMPTY_ICON_TYPE as f, CFSubRuleType as o, CFTextOperator as g, createCfId as
|
|
6
|
-
import { FRange as
|
|
3
|
+
var y = (u, e, t) => q(u, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ColorKit as c, Tools as _, BooleanNumber as a, Rectangle as U, ColorBuilder as B } from "@univerjs/core";
|
|
5
|
+
import { CFRuleType as n, 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";
|
|
7
7
|
class d {
|
|
8
8
|
constructor(e = {}) {
|
|
9
|
-
|
|
9
|
+
y(this, "_rule", {});
|
|
10
10
|
this._rule = e, this._ensureAttr(this._rule, ["rule"]);
|
|
11
11
|
}
|
|
12
12
|
get _ruleConfig() {
|
|
@@ -18,15 +18,15 @@ class d {
|
|
|
18
18
|
return {
|
|
19
19
|
type: e,
|
|
20
20
|
config: [
|
|
21
|
-
{ index: 0, color: new
|
|
22
|
-
{ index: 0, color: new
|
|
21
|
+
{ index: 0, color: new c("").toRgbString(), value: { type: C.min } },
|
|
22
|
+
{ index: 0, color: new c("green").toRgbString(), value: { type: C.max } }
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
25
|
case n.dataBar:
|
|
26
26
|
return {
|
|
27
27
|
type: e,
|
|
28
28
|
isShowValue: !0,
|
|
29
|
-
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new
|
|
29
|
+
config: { min: { type: C.min }, max: { type: C.max }, positiveColor: new c("green").toRgbString(), nativeColor: new c("").toRgbString(), isGradient: !1 }
|
|
30
30
|
};
|
|
31
31
|
case n.highlightCell:
|
|
32
32
|
return {
|
|
@@ -69,7 +69,7 @@ class d {
|
|
|
69
69
|
}
|
|
70
70
|
build() {
|
|
71
71
|
var r;
|
|
72
|
-
this._rule.cfId || (this._rule.cfId =
|
|
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"]));
|
|
73
73
|
const e = this._getDefaultConfig(this._rule.rule.type);
|
|
74
74
|
return { ...this._rule, rule: { ...e, ...this._rule.rule } };
|
|
75
75
|
}
|
|
@@ -80,7 +80,7 @@ class d {
|
|
|
80
80
|
* @memberof ConditionalFormatRuleBuilder
|
|
81
81
|
*/
|
|
82
82
|
copy() {
|
|
83
|
-
return new d(
|
|
83
|
+
return new d(_.deepClone(this._rule));
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Gets the scope of the current conditional format
|
|
@@ -102,7 +102,7 @@ class d {
|
|
|
102
102
|
* @memberof ConditionalFormatRuleBuilder
|
|
103
103
|
*/
|
|
104
104
|
createCfId() {
|
|
105
|
-
return
|
|
105
|
+
return b();
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Sets the scope for conditional formatting
|
|
@@ -119,7 +119,7 @@ class i extends d {
|
|
|
119
119
|
super(e), this._ensureAttr(this._rule, ["rule", "style"]);
|
|
120
120
|
}
|
|
121
121
|
copy() {
|
|
122
|
-
return new i(
|
|
122
|
+
return new i(_.deepClone(this._rule));
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Set average rule
|
|
@@ -170,7 +170,7 @@ class i extends d {
|
|
|
170
170
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
171
171
|
if (e) {
|
|
172
172
|
this._ensureAttr(this._ruleConfig, ["style", "bg"]);
|
|
173
|
-
const r = new
|
|
173
|
+
const r = new c(e);
|
|
174
174
|
this._ruleConfig.style.bg.rgb = r.toRgbString();
|
|
175
175
|
} else
|
|
176
176
|
delete this._ruleConfig.style.bg;
|
|
@@ -196,7 +196,7 @@ class i extends d {
|
|
|
196
196
|
var t;
|
|
197
197
|
if (((t = this._ruleConfig) == null ? void 0 : t.type) === n.highlightCell)
|
|
198
198
|
if (e) {
|
|
199
|
-
const r = new
|
|
199
|
+
const r = new c(e);
|
|
200
200
|
this._ensureAttr(this._ruleConfig, ["style", "cl"]), this._ruleConfig.style.cl.rgb = r.toRgbString();
|
|
201
201
|
} else
|
|
202
202
|
delete this._ruleConfig.style.cl;
|
|
@@ -390,7 +390,7 @@ class i extends d {
|
|
|
390
390
|
}
|
|
391
391
|
class m extends d {
|
|
392
392
|
copy() {
|
|
393
|
-
return new m(
|
|
393
|
+
return new m(_.deepClone(this._rule));
|
|
394
394
|
}
|
|
395
395
|
/**
|
|
396
396
|
* Data bar settings
|
|
@@ -418,7 +418,7 @@ class m extends d {
|
|
|
418
418
|
}
|
|
419
419
|
class w extends d {
|
|
420
420
|
copy() {
|
|
421
|
-
return new w(
|
|
421
|
+
return new w(_.deepClone(this._rule));
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
424
424
|
* Color scale set
|
|
@@ -432,7 +432,7 @@ class w extends d {
|
|
|
432
432
|
}
|
|
433
433
|
class p extends d {
|
|
434
434
|
copy() {
|
|
435
|
-
return new p(
|
|
435
|
+
return new p(_.deepClone(this._rule));
|
|
436
436
|
}
|
|
437
437
|
/**
|
|
438
438
|
*
|
|
@@ -445,7 +445,7 @@ class p extends d {
|
|
|
445
445
|
return t.type = n.iconSet, t.config = e.iconConfigs, t.isShowValue = e.isShowValue, this;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
class
|
|
448
|
+
class R {
|
|
449
449
|
constructor(e = {}) {
|
|
450
450
|
this._initConfig = e;
|
|
451
451
|
}
|
|
@@ -712,7 +712,7 @@ class E {
|
|
|
712
712
|
return new i(this._initConfig).whenTextStartsWith(e);
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
class A extends
|
|
715
|
+
class A extends v {
|
|
716
716
|
_getConditionalFormattingRuleModel() {
|
|
717
717
|
return this._injector.get(T);
|
|
718
718
|
}
|
|
@@ -720,7 +720,7 @@ class A extends k {
|
|
|
720
720
|
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []].filter((t) => t.ranges.some((r) => U.intersects(r, this._range)));
|
|
721
721
|
}
|
|
722
722
|
createConditionalFormattingRule() {
|
|
723
|
-
return new
|
|
723
|
+
return new R({ ranges: [this._range] });
|
|
724
724
|
}
|
|
725
725
|
addConditionalFormattingRule(e) {
|
|
726
726
|
const t = {
|
|
@@ -728,7 +728,7 @@ class A extends k {
|
|
|
728
728
|
unitId: this._workbook.getUnitId(),
|
|
729
729
|
subUnitId: this._worksheet.getSheetId()
|
|
730
730
|
};
|
|
731
|
-
return this._commandService.
|
|
731
|
+
return this._commandService.syncExecuteCommand(x.id, t), this;
|
|
732
732
|
}
|
|
733
733
|
deleteConditionalFormattingRule(e) {
|
|
734
734
|
const t = {
|
|
@@ -736,7 +736,7 @@ class A extends k {
|
|
|
736
736
|
subUnitId: this._worksheet.getSheetId(),
|
|
737
737
|
cfId: e
|
|
738
738
|
};
|
|
739
|
-
return this._commandService.
|
|
739
|
+
return this._commandService.syncExecuteCommand(S.id, t), this;
|
|
740
740
|
}
|
|
741
741
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
742
742
|
const s = {
|
|
@@ -745,7 +745,7 @@ class A extends k {
|
|
|
745
745
|
start: { id: e, type: "self" },
|
|
746
746
|
end: { id: t, type: r }
|
|
747
747
|
};
|
|
748
|
-
return this._commandService.
|
|
748
|
+
return this._commandService.syncExecuteCommand(I.id, s), this;
|
|
749
749
|
}
|
|
750
750
|
setConditionalFormattingRule(e, t) {
|
|
751
751
|
const r = {
|
|
@@ -754,17 +754,17 @@ class A extends k {
|
|
|
754
754
|
rule: t,
|
|
755
755
|
cfId: e
|
|
756
756
|
};
|
|
757
|
-
return this._commandService.
|
|
757
|
+
return this._commandService.syncExecuteCommand(E.id, r), this;
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
|
-
|
|
761
|
-
class D extends
|
|
760
|
+
v.extend(A);
|
|
761
|
+
class D extends k {
|
|
762
762
|
newColor() {
|
|
763
763
|
return new B();
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
|
-
|
|
767
|
-
class V extends
|
|
766
|
+
k.extend(D);
|
|
767
|
+
class V extends F {
|
|
768
768
|
_getConditionalFormattingRuleModel() {
|
|
769
769
|
return this._injector.get(T);
|
|
770
770
|
}
|
|
@@ -772,7 +772,7 @@ class V extends R {
|
|
|
772
772
|
return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
|
|
773
773
|
}
|
|
774
774
|
createConditionalFormattingRule() {
|
|
775
|
-
return new
|
|
775
|
+
return new R();
|
|
776
776
|
}
|
|
777
777
|
addConditionalFormattingRule(e) {
|
|
778
778
|
const t = {
|
|
@@ -780,7 +780,7 @@ class V extends R {
|
|
|
780
780
|
unitId: this._workbook.getUnitId(),
|
|
781
781
|
subUnitId: this._worksheet.getSheetId()
|
|
782
782
|
};
|
|
783
|
-
return this._commandService.
|
|
783
|
+
return this._commandService.syncExecuteCommand(x.id, t), this;
|
|
784
784
|
}
|
|
785
785
|
deleteConditionalFormattingRule(e) {
|
|
786
786
|
const t = {
|
|
@@ -788,7 +788,7 @@ class V extends R {
|
|
|
788
788
|
subUnitId: this._worksheet.getSheetId(),
|
|
789
789
|
cfId: e
|
|
790
790
|
};
|
|
791
|
-
return this._commandService.
|
|
791
|
+
return this._commandService.syncExecuteCommand(S.id, t), this;
|
|
792
792
|
}
|
|
793
793
|
moveConditionalFormattingRule(e, t, r = "after") {
|
|
794
794
|
const s = {
|
|
@@ -797,7 +797,7 @@ class V extends R {
|
|
|
797
797
|
start: { id: e, type: "self" },
|
|
798
798
|
end: { id: t, type: r }
|
|
799
799
|
};
|
|
800
|
-
return this._commandService.
|
|
800
|
+
return this._commandService.syncExecuteCommand(I.id, s), this;
|
|
801
801
|
}
|
|
802
802
|
setConditionalFormattingRule(e, t) {
|
|
803
803
|
const r = {
|
|
@@ -806,10 +806,10 @@ class V extends R {
|
|
|
806
806
|
rule: t,
|
|
807
807
|
cfId: e
|
|
808
808
|
};
|
|
809
|
-
return this._commandService.
|
|
809
|
+
return this._commandService.syncExecuteCommand(E.id, r), this;
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
|
-
|
|
812
|
+
F.extend(V);
|
|
813
813
|
export {
|
|
814
|
-
|
|
814
|
+
R as FConditionalFormattingBuilder
|
|
815
815
|
};
|
|
@@ -38,16 +38,16 @@ export interface IFRangeConditionalFormattingMixin {
|
|
|
38
38
|
/**
|
|
39
39
|
* Add a new conditional format
|
|
40
40
|
* @param {IConditionFormattingRule} rule
|
|
41
|
-
* @
|
|
42
|
-
* @memberof
|
|
41
|
+
* @returns {FRange} Returns the current range instance for method chaining
|
|
42
|
+
* @memberof IFRangeConditionalFormattingMixin
|
|
43
43
|
*/
|
|
44
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule):
|
|
44
|
+
addConditionalFormattingRule(rule: IConditionFormattingRule): FRange;
|
|
45
45
|
/**
|
|
46
46
|
* Delete conditional format according to `cfId`
|
|
47
47
|
*
|
|
48
48
|
* @param {string} cfId
|
|
49
|
-
* @
|
|
50
|
-
* @memberof
|
|
49
|
+
* @returns {FRange} Returns the current range instance for method chaining
|
|
50
|
+
* @memberof IFRangeConditionalFormattingMixin
|
|
51
51
|
* @example
|
|
52
52
|
* ```ts
|
|
53
53
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -56,13 +56,14 @@ export interface IFRangeConditionalFormattingMixin {
|
|
|
56
56
|
* worksheet?.deleteConditionalFormattingRule(rules![0].cfId);
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
deleteConditionalFormattingRule(cfId: string):
|
|
59
|
+
deleteConditionalFormattingRule(cfId: string): FRange;
|
|
60
60
|
/**
|
|
61
61
|
* Modify the priority of the conditional format
|
|
62
62
|
* @param {string} cfId Rules that need to be moved
|
|
63
63
|
* @param {string} toCfId Target rule
|
|
64
64
|
* @param {IAnchor['type']} [type] After the default move to the destination rule, if type = before moves to the front, the default value is after
|
|
65
|
-
* @
|
|
65
|
+
* @returns {FRange} Returns the current range instance for method chaining
|
|
66
|
+
* @memberof FRangeConditionalFormattingMixin
|
|
66
67
|
* @example
|
|
67
68
|
* ```ts
|
|
68
69
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -73,13 +74,13 @@ export interface IFRangeConditionalFormattingMixin {
|
|
|
73
74
|
* worksheet?.moveConditionalFormattingRule(rule.cfId, targetRule.cfId, 'before');
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']):
|
|
77
|
+
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FRange;
|
|
77
78
|
/**
|
|
78
79
|
* Set the conditional format according to `cfId`
|
|
79
80
|
* @param {string} cfId
|
|
80
81
|
* @param {IConditionFormattingRule} rule
|
|
81
|
-
* @
|
|
82
|
-
* @memberof
|
|
82
|
+
* @returns {FRange} Returns the current range instance for method chaining
|
|
83
|
+
* @memberof IFRangeConditionalFormattingMixin
|
|
83
84
|
* @example
|
|
84
85
|
* ```ts
|
|
85
86
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -89,16 +90,16 @@ export interface IFRangeConditionalFormattingMixin {
|
|
|
89
90
|
* worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });
|
|
90
91
|
* ```
|
|
91
92
|
*/
|
|
92
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule):
|
|
93
|
+
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FRange;
|
|
93
94
|
}
|
|
94
95
|
export declare class FRangeConditionalFormattingMixin extends FRange implements IFRangeConditionalFormattingMixin {
|
|
95
96
|
private _getConditionalFormattingRuleModel;
|
|
96
97
|
getConditionalFormattingRules(): IConditionFormattingRule[];
|
|
97
98
|
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
98
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule):
|
|
99
|
-
deleteConditionalFormattingRule(cfId: string):
|
|
100
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']):
|
|
101
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule):
|
|
99
|
+
addConditionalFormattingRule(rule: IConditionFormattingRule): FRange;
|
|
100
|
+
deleteConditionalFormattingRule(cfId: string): FRange;
|
|
101
|
+
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FRange;
|
|
102
|
+
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FRange;
|
|
102
103
|
}
|
|
103
104
|
declare module '@univerjs/sheets/facade' {
|
|
104
105
|
interface FRange extends IFRangeConditionalFormattingMixin {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ColorBuilder } from '@univerjs/core';
|
|
2
2
|
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
3
3
|
export interface IFWorkbookConditionalFormattingMixin {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use `univerAPI.newColor()` as instead.
|
|
6
|
+
*/
|
|
4
7
|
newColor(): ColorBuilder;
|
|
5
8
|
}
|
|
6
9
|
export declare class FWorkbookConditionalFormattingMixin extends FWorkbook implements IFWorkbookConditionalFormattingMixin {
|
|
@@ -34,7 +34,7 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
34
34
|
/**
|
|
35
35
|
* Add a new conditional format
|
|
36
36
|
* @param {IConditionFormattingRule} rule
|
|
37
|
-
* @
|
|
37
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
38
38
|
* @memberof IFWorksheetConditionalFormattingMixin
|
|
39
39
|
* @example
|
|
40
40
|
* ```ts
|
|
@@ -51,12 +51,12 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
51
51
|
* worksheet?.addConditionalFormattingRule(rule!);
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule):
|
|
54
|
+
addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
|
|
55
55
|
/**
|
|
56
56
|
* Delete conditional format according to `cfId`
|
|
57
57
|
*
|
|
58
58
|
* @param {string} cfId
|
|
59
|
-
* @
|
|
59
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
60
60
|
* @memberof IFWorksheetConditionalFormattingMixin
|
|
61
61
|
* @example
|
|
62
62
|
* ```ts
|
|
@@ -66,12 +66,13 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
66
66
|
* worksheet?.deleteConditionalFormattingRule(rules![0].cfId);
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
deleteConditionalFormattingRule(cfId: string):
|
|
69
|
+
deleteConditionalFormattingRule(cfId: string): FWorksheet;
|
|
70
70
|
/**
|
|
71
71
|
* Modify the priority of the conditional format
|
|
72
72
|
* @param {string} cfId Rules that need to be moved
|
|
73
73
|
* @param {string} toCfId Target rule
|
|
74
74
|
* @param {IAnchor['type']} [type] After the default move to the destination rule, if type = before moves to the front, the default value is after
|
|
75
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
75
76
|
* @memberof FWorksheetConditionalFormattingMixin
|
|
76
77
|
* @example
|
|
77
78
|
* ```ts
|
|
@@ -83,12 +84,12 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
83
84
|
* worksheet?.moveConditionalFormattingRule(rule.cfId, targetRule.cfId, 'before');
|
|
84
85
|
* ```
|
|
85
86
|
*/
|
|
86
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']):
|
|
87
|
+
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FWorksheet;
|
|
87
88
|
/**
|
|
88
89
|
* Set the conditional format according to `cfId`
|
|
89
90
|
* @param {string} cfId
|
|
90
91
|
* @param {IConditionFormattingRule} rule
|
|
91
|
-
* @
|
|
92
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
92
93
|
* @memberof IFWorksheetConditionalFormattingMixin
|
|
93
94
|
* @example
|
|
94
95
|
* ```ts
|
|
@@ -99,16 +100,16 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
99
100
|
* worksheet?.setConditionalFormattingRule(rule.cfId, { ...rule, ranges: [] });
|
|
100
101
|
* ```
|
|
101
102
|
*/
|
|
102
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule):
|
|
103
|
+
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FWorksheet;
|
|
103
104
|
}
|
|
104
105
|
export declare class FWorksheetConditionalFormattingMixin extends FWorksheet implements IFWorksheetConditionalFormattingMixin {
|
|
105
106
|
private _getConditionalFormattingRuleModel;
|
|
106
107
|
getConditionalFormattingRules(): IConditionFormattingRule[];
|
|
107
108
|
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
108
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule):
|
|
109
|
-
deleteConditionalFormattingRule(cfId: string):
|
|
110
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']):
|
|
111
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule):
|
|
109
|
+
addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
|
|
110
|
+
deleteConditionalFormattingRule(cfId: string): FWorksheet;
|
|
111
|
+
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FWorksheet;
|
|
112
|
+
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FWorksheet;
|
|
112
113
|
}
|
|
113
114
|
declare module '@univerjs/sheets/facade' {
|
|
114
115
|
interface FWorksheet extends IFWorksheetConditionalFormattingMixin {
|
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 c=Object.defineProperty;var R=(i,r,u)=>r in i?c(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((n,s)=>(n[s]||(n[s]={}),n[s]),e),e}build(){var n;this._rule.cfId||(this._rule.cfId=u.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(n=this._rule.rule)!=null&&n.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 l extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){return new l(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 n=new r.ColorKit(e);this._ruleConfig.style.bg.rgb=n.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 n=new r.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 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 n=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=[n,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 n=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=[n,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 l(this._initConfig).setAverage(e)}setUniqueValues(){return new l(this._initConfig).setUniqueValues()}setDuplicateValues(){return new l(this._initConfig).setDuplicateValues()}setRank(e){return new l(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 l(this._initConfig).setBackground(e)}setBold(e){return new l(this._initConfig).setBold(e)}setFontColor(e){return new l(this._initConfig).setFontColor(e)}setItalic(e){return new l(this._initConfig).setItalic(e)}setStrikethrough(e){return new l(this._initConfig).setStrikethrough(e)}setUnderline(e){return new l(this._initConfig).setUnderline(e)}whenCellEmpty(){return new l(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new l(this._initConfig).whenCellNotEmpty()}whenDate(e){return new l(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new l(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new l(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new l(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new l(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new l(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new l(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new l(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new l(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new l(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new l(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new l(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new l(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new l(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new l(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(n=>r.Rectangle.intersects(n,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.executeCommand(u.AddConditionalRuleMutation.id,t)}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.executeCommand(u.DeleteConditionalRuleMutation.id,t)}moveConditionalFormattingRule(e,t,n="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:n}};return this._commandService.executeCommand(u.MoveConditionalRuleMutation.id,s)}setConditionalFormattingRule(e,t){const n={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.executeCommand(u.SetConditionalRuleMutation.id,n)}}p.FRange.extend(f);class b extends p.FWorkbook{newColor(){return new r.ColorBuilder}}p.FWorkbook.extend(b);class w 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.executeCommand(u.AddConditionalRuleMutation.id,t)}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.executeCommand(u.DeleteConditionalRuleMutation.id,t)}moveConditionalFormattingRule(e,t,n="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:n}};return this._commandService.executeCommand(u.MoveConditionalRuleMutation.id,s)}setConditionalFormattingRule(e,t){const n={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.executeCommand(u.SetConditionalRuleMutation.id,n)}}p.FWorksheet.extend(w),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 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"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-conditional-formatting",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Conditional formatting plugin for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,36 +53,18 @@
|
|
|
53
53
|
"rxjs": ">=7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@univerjs/core": "0.5.
|
|
57
|
-
"@univerjs/engine-formula": "0.5.
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
56
|
+
"@univerjs/core": "0.5.3",
|
|
57
|
+
"@univerjs/engine-formula": "0.5.3",
|
|
58
|
+
"@univerjs/engine-render": "0.5.3",
|
|
59
|
+
"@univerjs/sheets": "0.5.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@univerjs/icons-svg": "^0.2.
|
|
62
|
+
"@univerjs/icons-svg": "^0.2.10",
|
|
63
63
|
"rxjs": "^7.8.1",
|
|
64
64
|
"typescript": "^5.7.2",
|
|
65
|
-
"vite": "^6.0.
|
|
65
|
+
"vite": "^6.0.6",
|
|
66
66
|
"vitest": "^2.1.8",
|
|
67
|
-
"@univerjs-infra/shared": "0.5.
|
|
68
|
-
},
|
|
69
|
-
"space": {
|
|
70
|
-
".": {
|
|
71
|
-
"import": "./lib/es/index.js",
|
|
72
|
-
"require": "./lib/cjs/index.js",
|
|
73
|
-
"types": "./lib/types/index.d.ts"
|
|
74
|
-
},
|
|
75
|
-
"./*": {
|
|
76
|
-
"import": "./lib/es/*",
|
|
77
|
-
"require": "./lib/cjs/*",
|
|
78
|
-
"types": "./lib/types/index.d.ts"
|
|
79
|
-
},
|
|
80
|
-
"./facade": {
|
|
81
|
-
"import": "./lib/es/facade.js",
|
|
82
|
-
"require": "./lib/cjs/facade.js",
|
|
83
|
-
"types": "./lib/types/facade/index.d.ts"
|
|
84
|
-
},
|
|
85
|
-
"./lib/*": "./lib/*"
|
|
67
|
+
"@univerjs-infra/shared": "0.5.3"
|
|
86
68
|
},
|
|
87
69
|
"scripts": {
|
|
88
70
|
"test": "vitest run",
|