@univerjs/preset-sheets-conditional-formatting 0.6.2 → 0.6.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.
Files changed (2) hide show
  1. package/lib/umd/index.js +50 -50
  2. package/package.json +5 -5
package/lib/umd/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-conditional-formatting/facade
6
- (function(l,u){typeof exports=="object"&&typeof module<"u"?u(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"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.UniverSheetsConditionalFormattingFacade={},l.UniverCore,l.UniverSheetsConditionalFormatting,l.UniverSheetsFacade))})(this,function(l,u,r,C){"use strict";var w=Object.defineProperty;var R=(l,u,r)=>u in l?w(l,u,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[u]=r;var _=(l,u,r)=>R(l,typeof u!="symbol"?u+"":u,r);class o{constructor(e={}){_(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=r.CFRuleType.highlightCell){switch(e){case r.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new u.ColorKit("").toRgbString(),value:{type:r.CFValueType.min}},{index:0,color:new u.ColorKit("green").toRgbString(),value:{type:r.CFValueType.max}}]};case r.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:r.CFValueType.min},max:{type:r.CFValueType.max},positiveColor:new u.ColorKit("green").toRgbString(),nativeColor:new u.ColorKit("").toRgbString(),isGradient:!1}};case r.CFRuleType.highlightCell:return{type:e,subType:r.CFSubRuleType.text,operator:r.CFTextOperator.containsText,value:"abc",style:{}};case r.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:r.CFNumberOperator.greaterThanOrEqual,value:{type:r.CFValueType.min},iconType:r.EMPTY_ICON_TYPE,iconId:""},{operator:r.CFNumberOperator.greaterThanOrEqual,value:{type:r.CFValueType.percentile,value:.5},iconType:r.EMPTY_ICON_TYPE,iconId:""},{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.max},iconType:r.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,t){return t.reduce((i,s)=>(i[s]||(i[s]={}),i[s]),e),e}build(){var i;this._rule.cfId||(this._rule.cfId=r.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(i=this._rule.rule)!=null&&i.type||(this._rule.rule.type=r.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(u.Tools.deepClone(this._rule))}getRanges(){return this._rule.ranges||[]}getIconMap(){return r.iconMap}createCfId(){return r.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(u.Tools.deepClone(this._rule))}setAverage(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.duplicateValues,this}setRank(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.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)===r.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const i=new u.ColorKit(e);this._ruleConfig.style.bg.rgb=i.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setFontColor(e){var t;if(((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell)if(e){const i=new u.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=i.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setStrikethrough(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setUnderline(e){var t;return((t=this._ruleConfig)==null?void 0:t.type)===r.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.text,e.value="",e.operator=r.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=r.CFRuleType.highlightCell,e.subType=r.CFSubRuleType.text,e.value="",e.operator=r.CFTextOperator.notEqual,this}whenDate(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){const i=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=r.CFRuleType.highlightCell,h.subType=r.CFSubRuleType.number,h.value=[i,s],h.operator=r.CFNumberOperator.between,this}whenNumberEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){const i=Math.min(e,t),s=Math.max(e,t),h=this._ruleConfig;return h.type=r.CFRuleType.highlightCell,h.subType=r.CFSubRuleType.number,h.value=[i,s],h.operator=r.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.number,t.value=e,t.operator=r.CFNumberOperator.notEqual,this}whenTextContains(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.endsWith,this}whenTextEqualTo(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.equal,this}whenTextStartsWith(e){const t=this._ruleConfig;return t.type=r.CFRuleType.highlightCell,t.subType=r.CFSubRuleType.text,t.value=e,t.operator=r.CFTextOperator.beginsWith,this}}class a extends o{copy(){return new a(u.Tools.deepClone(this._rule))}setDataBar(e){const t=this._ruleConfig;return t.type=r.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(u.Tools.deepClone(this._rule))}setColorScale(e){const t=this._ruleConfig;return t.type=r.CFRuleType.colorScale,t.config=e,this}}class y extends o{copy(){return new y(u.Tools.deepClone(this._rule))}setIconSet(e){const t=this._ruleConfig;return t.type=r.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}}class p{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 y(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 C.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(r.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(t=>t.ranges.some(i=>u.Rectangle.intersects(i,this._range)))}createConditionalFormattingRule(){return new p({ranges:[this._range]})}addConditionalFormattingRule(e){const t={rule:e,unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(r.AddConditionalRuleMutation.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(r.DeleteConditionalRuleMutation.id,t),this}moveConditionalFormattingRule(e,t,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:i}};return this._commandService.syncExecuteCommand(r.MoveConditionalRuleMutation.id,s),this}setConditionalFormattingRule(e,t){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(r.SetConditionalRuleMutation.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(r.ClearRangeCfCommand.id,e),this}}C.FRange.extend(f);class c extends C.FWorkbook{newColor(){return new u.ColorBuilder}}C.FWorkbook.extend(c);class b extends C.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(r.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new p}newConditionalFormattingRule(){return new p}addConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(r.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){const t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(r.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:t,type:i}};return this._commandService.syncExecuteCommand(r.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,t){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(r.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(r.ClearWorksheetCfCommand.id,e),this}}C.FWorksheet.extend(b),l.FConditionalFormattingBuilder=p,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
6
+ (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-conditional-formatting","@univerjs/sheets/facade","@univerjs/core/facade"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.UniverSheetsConditionalFormattingFacade={},l.UniverCore,l.UniverSheetsConditionalFormatting,l.UniverSheetsFacade,l.UniverCoreFacade))})(this,function(l,u,t,C,y){"use strict";var R=Object.defineProperty;var m=(l,u,t)=>u in l?R(l,u,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[u]=t;var T=(l,u,t)=>m(l,typeof u!="symbol"?u+"":u,t);class o{constructor(e={}){T(this,"_rule",{});this._rule=e,this._ensureAttr(this._rule,["rule"])}get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=t.CFRuleType.highlightCell){switch(e){case t.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new u.ColorKit("").toRgbString(),value:{type:t.CFValueType.min}},{index:0,color:new u.ColorKit("green").toRgbString(),value:{type:t.CFValueType.max}}]};case t.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:t.CFValueType.min},max:{type:t.CFValueType.max},positiveColor:new u.ColorKit("green").toRgbString(),nativeColor:new u.ColorKit("").toRgbString(),isGradient:!1}};case t.CFRuleType.highlightCell:return{type:e,subType:t.CFSubRuleType.text,operator:t.CFTextOperator.containsText,value:"abc",style:{}};case t.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:t.CFNumberOperator.greaterThanOrEqual,value:{type:t.CFValueType.min},iconType:t.EMPTY_ICON_TYPE,iconId:""},{operator:t.CFNumberOperator.greaterThanOrEqual,value:{type:t.CFValueType.percentile,value:.5},iconType:t.EMPTY_ICON_TYPE,iconId:""},{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.max},iconType:t.EMPTY_ICON_TYPE,iconId:""}]}}}_ensureAttr(e,r){return r.reduce((i,s)=>(i[s]||(i[s]={}),i[s]),e),e}build(){var i;this._rule.cfId||(this._rule.cfId=t.createCfId()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(i=this._rule.rule)!=null&&i.type||(this._rule.rule.type=t.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(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new o(e)}getRanges(){return this._rule.ranges||[]}getIconMap(){return t.iconMap}createCfId(){return t.createCfId()}setRanges(e){return this._rule.ranges=e,this}}class n extends o{constructor(e={}){super(e),this._ensureAttr(this._rule,["rule","style"])}copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new n(e)}setAverage(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.average,r.operator=e,this}setUniqueValues(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.uniqueValues,this}setDuplicateValues(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.duplicateValues,this}setRank(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.rank,r.isBottom=e.isBottom,r.isPercent=e.isPercent,r.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,["style","bg"]);const i=new u.ColorKit(e);this._ruleConfig.style.bg.rgb=i.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.bl=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell)if(e){const i=new u.ColorKit(e);this._ensureAttr(this._ruleConfig,["style","cl"]),this._ruleConfig.style.cl.rgb=i.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style"]),this._ruleConfig.style.it=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","st"]),this._ruleConfig.style.st.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===t.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,["style","ul"]),this._ruleConfig.style.ul.s=e?u.BooleanNumber.TRUE:u.BooleanNumber.FALSE),this}whenCellEmpty(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.text,e.value="",e.operator=t.CFTextOperator.equal,this}whenCellNotEmpty(){const e=this._ruleConfig;return e.type=t.CFRuleType.highlightCell,e.subType=t.CFSubRuleType.text,e.value="",e.operator=t.CFTextOperator.notEqual,this}whenDate(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.timePeriod,r.operator=e,this}whenFormulaSatisfied(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.formula,r.value=e,this}whenNumberBetween(e,r){const i=Math.min(e,r),s=Math.max(e,r),h=this._ruleConfig;return h.type=t.CFRuleType.highlightCell,h.subType=t.CFSubRuleType.number,h.value=[i,s],h.operator=t.CFNumberOperator.between,this}whenNumberEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.equal,this}whenNumberGreaterThan(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,r){const i=Math.min(e,r),s=Math.max(e,r),h=this._ruleConfig;return h.type=t.CFRuleType.highlightCell,h.subType=t.CFSubRuleType.number,h.value=[i,s],h.operator=t.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.number,r.value=e,r.operator=t.CFNumberOperator.notEqual,this}whenTextContains(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.containsText,this}whenTextDoesNotContain(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.notContainsText,this}whenTextEndsWith(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.endsWith,this}whenTextEqualTo(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.equal,this}whenTextStartsWith(e){const r=this._ruleConfig;return r.type=t.CFRuleType.highlightCell,r.subType=t.CFSubRuleType.text,r.value=e,r.operator=t.CFTextOperator.beginsWith,this}}class f extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new f(e)}setDataBar(e){const r=this._ruleConfig;return r.type=t.CFRuleType.dataBar,r.isShowValue=!!e.isShowValue,r.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}}class c extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new c(e)}setColorScale(e){const r=this._ruleConfig;return r.type=t.CFRuleType.colorScale,r.config=e,this}}class g extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new g(e)}setIconSet(e){const r=this._ruleConfig;return r.type=t.CFRuleType.iconSet,r.config=e.iconConfigs,r.isShowValue=e.isShowValue,this}}class p{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)}getIconMap(){return t.iconMap}setIconSet(e){return new g(this._initConfig).setIconSet(e)}setColorScale(e){return new c(this._initConfig).setColorScale(e)}setDataBar(e){return new f(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,r){return new n(this._initConfig).whenNumberBetween(e,r)}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,r){return new n(this._initConfig).whenNumberNotBetween(e,r)}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 _ extends C.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(t.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(r=>r.ranges.some(i=>u.Rectangle.intersects(i,this._range)))}createConditionalFormattingRule(){return new p({ranges:[this._range]})}addConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(t.AddCfCommand.id,r),this}deleteConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(t.DeleteCfCommand.id,r),this}moveConditionalFormattingRule(e,r,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:i}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:r,cfId:e};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(t.ClearRangeCfCommand.id,e),this}}C.FRange.extend(_);class w extends C.FWorkbook{newColor(){return new u.ColorBuilder}}C.FWorkbook.extend(w);class b extends C.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(t.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new p}newConditionalFormattingRule(){return new p}addConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(t.AddCfCommand.id,r),this}deleteConditionalFormattingRule(e){const r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(t.DeleteCfCommand.id,r),this}moveConditionalFormattingRule(e,r,i="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:i}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:r};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,i),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(t.ClearWorksheetCfCommand.id,e),this}}C.FWorksheet.extend(b);class d{get ConditionFormatNumberOperatorEnum(){return t.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return t.CFTimePeriodOperator}}y.FEnum.extend(d),l.FConditionalFormattingBuilder=p,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
7
7
 
8
8
 
9
9
  // @univerjs/sheets-conditional-formatting-ui/index
@@ -47,34 +47,34 @@
47
47
  `,"univer-box-border univer-h-7"),children:[R.jsx(ee.Select,{style:{flexShrink:0},options:y,value:E,onChange:O=>{I(O);const L=c.createDefaultValueByValueType(O,90);f(L),z({minType:p,medianType:m,maxType:O,minValue:S,medianValue:h,maxValue:L,minColor:b,medianColor:g,maxColor:v})}}),R.jsx(ir,{id:"max",className:`
48
48
  ${A.mLXxs}
49
49
  `,value:s,type:E,onChange:O=>{f(O),z({minType:p,medianType:m,maxType:E,minValue:S,medianValue:h,maxValue:O,minColor:b,medianColor:g,maxColor:v})}}),R.jsx(Me,{className:A.mLXxs,color:v,onChange:O=>{x(O),z({minType:p,medianType:m,maxType:E,minValue:S,medianValue:h,maxValue:s,minColor:b,medianColor:g,maxColor:O})}})]})]})},je=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),dn=t=>{var T;const{onChange:e,className:n,value:r,type:a,id:o,disabled:u=!1}=t,y=te.useDependency(_.IUniverInstanceService),p=y.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId(),C=(T=y.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.getSheetId(),m=V.useRef({}),[w,E]=V.useState(!1);te.useSidebarClick(h=>{var s;const i=(s=m.current)==null?void 0:s.handleOutClick;i&&i(h,()=>E(!1))});const I=V.useRef(r),S=V.useMemo(()=>[c.CFValueType.percentile,c.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===c.CFValueType.formula){const h=String(I.current).startsWith("=")?String(I.current)||"":"=";return R.jsx("div",{style:{width:"100%",marginLeft:12},children:R.jsx(Ge.FormulaEditor,{initValue:h,unitId:p,subUnitId:C,isFocus:w,onChange:(i="")=>{e(i||"")},onFocus:()=>E(!0),actions:m.current})})}return R.jsx(ee.InputNumber,{className:n,value:Number(r)||0,disabled:u,onChange:h=>{e(h||0)},...S})},wa=t=>{var U;const{interceptorManager:e}=t,n=te.useDependency(_.LocaleService),r=((U=t.rule)==null?void 0:U.type)===c.CFRuleType.dataBar?t.rule:void 0,[a,o]=V.useState(()=>{var L;const O="0";return r?(L=r.config)!=null&&L.isGradient?"1":"0":O}),[u,y]=V.useState(()=>{var O;return r&&((O=r.config)==null?void 0:O.positiveColor)||c.defaultDataBarPositiveColor}),[p,C]=V.useState(()=>{var O;return r&&((O=r.config)==null?void 0:O.nativeColor)||c.defaultDataBarNativeColor}),m=[je(c.CFValueType.num,n),je(c.CFValueType.percent,n),je(c.CFValueType.percentile,n),je(c.CFValueType.formula,n)],w=[je(c.CFValueType.min,n),...m],E=[je(c.CFValueType.max,n),...m],[I,S]=V.useState(()=>{var L;const O=w[0].value;return r&&((L=r.config)==null?void 0:L.min.type)||O}),[T,h]=V.useState(()=>{var L;const O=E[0].value;return r&&((L=r.config)==null?void 0:L.max.type)||O}),[i,s]=V.useState(()=>{var F;if(!r)return 0;const L=((F=r.config)==null?void 0:F.min)||{};return L.type===c.CFValueType.formula?L.value||"=":L.value||0}),[f,b]=V.useState(()=>{var F;if(!r)return 100;const L=((F=r.config)==null?void 0:F.max)||{};return L.type===c.CFValueType.formula?L.value||"=":L.value===void 0?100:L.value}),[l,g]=V.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),d=O=>({config:{min:{type:O.minValueType,value:O.minValue},max:{type:O.maxValueType,value:O.maxValue},isGradient:O.isGradient==="1",positiveColor:O.positiveColor||c.defaultDataBarPositiveColor,nativeColor:O.nativeColor||c.defaultDataBarNativeColor},type:c.CFRuleType.dataBar,isShowValue:O.isShowValue});V.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return d({isGradient:a,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}}),[a,i,I,f,T,u,p,e,l]);const v=O=>{t.onChange(d(O))},x=O=>{y(O),v({isGradient:a,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:O,nativeColor:p,isShowValue:l})},M=O=>{C(O),v({isGradient:a,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:O,isShowValue:l})},z=O=>m.map(L=>L.value).includes(O);return R.jsxs("div",{children:[R.jsx("div",{className:A.title,children:n.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:`
50
- ${G.cfPreviewWrap}
51
- `,children:R.jsx(We,{rule:d({isGradient:a,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})})}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.panel.fillType")}),R.jsxs("div",{className:`
52
- ${A.mTSm}
53
- ${A.mLXxs}
54
- ${A.labelContainer}
55
- `,children:[R.jsxs(ee.RadioGroup,{value:a,onChange:O=>{o(O),v({isGradient:O,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})},children:[R.jsx(ee.Radio,{value:"0",children:R.jsx("span",{className:G.text,children:n.t("sheet.cf.panel.pureColor")})}),R.jsx(ee.Radio,{value:"1",children:R.jsx("span",{className:G.text,children:n.t("sheet.cf.panel.gradient")})})]}),R.jsxs("div",{className:`
56
- ${G.utilItem}
57
- ${A.mLXl}
58
- `,children:[R.jsx(ee.Checkbox,{checked:!l,onChange:O=>{g(!O),v({isGradient:O,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:!O})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.panel.colorSet")}),R.jsxs("div",{className:`
59
- ${A.labelContainer}
60
- ${A.mTSm}
61
- ${A.mLXxs}
62
- `,children:[R.jsxs("div",{className:`
50
+ ${G.cfPreviewWrap}
51
+ `,children:R.jsx(We,{rule:d({isGradient:a,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})})}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.panel.fillType")}),R.jsxs("div",{className:`
52
+ ${A.mTSm}
53
+ ${A.mLXxs}
63
54
  ${A.labelContainer}
64
- `,children:[R.jsx("div",{className:`
65
- ${G.text}
66
- `,children:n.t("sheet.cf.panel.native")}),R.jsx(Me,{color:p,onChange:M})]}),R.jsxs("div",{className:`
55
+ `,children:[R.jsxs(ee.RadioGroup,{value:a,onChange:O=>{o(O),v({isGradient:O,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})},children:[R.jsx(ee.Radio,{value:"0",children:R.jsx("span",{className:G.text,children:n.t("sheet.cf.panel.pureColor")})}),R.jsx(ee.Radio,{value:"1",children:R.jsx("span",{className:G.text,children:n.t("sheet.cf.panel.gradient")})})]}),R.jsxs("div",{className:`
56
+ ${G.utilItem}
57
+ ${A.mLXl}
58
+ `,children:[R.jsx(ee.Checkbox,{checked:!l,onChange:O=>{g(!O),v({isGradient:O,minValue:i,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:!O})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.panel.colorSet")}),R.jsxs("div",{className:`
67
59
  ${A.labelContainer}
68
- ${A.mLSm}
69
- `,children:[R.jsx("div",{className:`
70
- ${G.text}
71
- `,children:n.t("sheet.cf.panel.positive")}),R.jsx(Me,{color:u,onChange:x})]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.valueType.min")}),R.jsxs("div",{className:`
72
- ${A.mTSm}
73
- ${A.labelContainer}
74
- `,children:[R.jsx(ee.Select,{style:{width:"50%",flexShrink:0},options:w,value:I,onChange:O=>{S(O);const L=c.createDefaultValueByValueType(O,10);s(L),v({isGradient:a,minValue:L,minValueType:O,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}}),R.jsx(dn,{disabled:!z(I),id:"min",type:I,className:A.mLSm,value:i,onChange:O=>{s(O||0),v({isGradient:a,minValue:O||0,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}})]}),R.jsx("div",{className:A.label,children:n.t("sheet.cf.valueType.max")}),R.jsxs("div",{className:`
75
- ${A.mTSm}
76
- ${A.labelContainer}
77
- `,children:[R.jsx(ee.Select,{style:{width:"50%",flexShrink:0},options:E,value:T,onChange:O=>{h(O);const L=c.createDefaultValueByValueType(O,90);b(L),v({isGradient:a,minValue:i,minValueType:I,maxValue:L,maxValueType:O,positiveColor:u,nativeColor:p,isShowValue:l})}}),R.jsx(dn,{disabled:!z(T),id:"max",type:T,className:A.mLSm,value:f,onChange:O=>{b(O||0),v({isGradient:a,minValue:i,minValueType:I,maxValue:O||0,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}})]})]})]})},Re={cfStyleEdit:"univer-cf-style-edit",buttonItem:"univer-button-item",isActive:"univer-isActive"},Rt=t=>[_.BooleanNumber.FALSE,void 0].includes(t)?_.BooleanNumber.TRUE:_.BooleanNumber.FALSE,Et=t=>t!==_.BooleanNumber.FALSE,sr=t=>{const{style:e,onChange:n,className:r}=t,a=te.useDependency(te.ComponentManager),[o,u]=V.useState(()=>{if(e!=null&&e.bl)return e.bl}),[y,p]=V.useState(()=>{if(e!=null&&e.it)return e.it}),[C,m]=V.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[w,E]=V.useState(()=>{if(e!=null&&e.st)return e.st.s}),[I,S]=V.useState(()=>{var g;const l="#2f56ef";return(g=e==null?void 0:e.cl)!=null&&g.rgb?e.cl.rgb:l}),[T,h]=V.useState(()=>{var g;const l="#e8ecfc";return(g=e==null?void 0:e.bg)!=null&&g.rgb?e.bg.rgb:l}),i=a.get("BoldSingle"),s=a.get("ItalicSingle"),f=a.get("UnderlineSingle"),b=a.get("StrikethroughSingle");return V.useEffect(()=>{const l={bl:o,it:y};I!==void 0&&(l.cl={rgb:I}),T!==void 0&&(l.bg={rgb:T}),w!==void 0&&(l.st={s:w}),C!==void 0&&(l.ul={s:C}),n(c.removeUndefinedAttr(l))},[o,y,C,w,I,T]),R.jsxs("div",{className:ee.clsx(Re.cfStyleEdit,r),children:[i&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(o||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>u(Rt(o)),children:R.jsx(i,{})}),s&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(y||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>p(Rt(y)),children:R.jsx(s,{})}),f&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(C||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>m(Rt(C)),children:R.jsx(f,{})}),b&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(w||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>E(Rt(w)),children:R.jsx(b,{})}),R.jsx(Me,{color:I,onChange:S,iconId:"FontColor"}),R.jsx(Me,{color:T,onChange:h,iconId:"PaintBucket"})]})},Ia=t=>{var b;const{onChange:e,interceptorManager:n}=t,r=te.useDependency(_.LocaleService),o=te.useDependency(_.IUniverInstanceService).getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),u=o.getActiveSheet(),y=((b=t.rule)==null?void 0:b.type)===c.CFRuleType.highlightCell?t.rule:void 0,p=V.useRef(null),[C,m]=V.useState(!1),w=V.useRef({}),[E,I]=V.useState({}),[S,T]=V.useState(()=>(y==null?void 0:y.subType)===c.CFSubRuleType.formula?y.value:"="),[h,i]=V.useState(void 0),s=l=>({style:l.style,value:S,type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula});V.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return s({style:E})}}),[E,S,n]),V.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(g,d,v)=>h||S.length===1||!S.startsWith("=")?(i(r.t("sheet.cf.errorMessage.formulaError")),!1):v(g)}),[h,S]);const f=l=>{e(s(l))};return te.useSidebarClick(l=>{var d;const g=(d=w.current)==null?void 0:d.handleOutClick;g&&g(l,()=>m(!1))}),R.jsxs("div",{ref:p,children:[R.jsx("div",{className:`
60
+ ${A.mTSm}
61
+ ${A.mLXxs}
62
+ `,children:[R.jsxs("div",{className:`
63
+ ${A.labelContainer}
64
+ `,children:[R.jsx("div",{className:`
65
+ ${G.text}
66
+ `,children:n.t("sheet.cf.panel.native")}),R.jsx(Me,{color:p,onChange:M})]}),R.jsxs("div",{className:`
67
+ ${A.labelContainer}
68
+ ${A.mLSm}
69
+ `,children:[R.jsx("div",{className:`
70
+ ${G.text}
71
+ `,children:n.t("sheet.cf.panel.positive")}),R.jsx(Me,{color:u,onChange:x})]})]})]}),R.jsxs("div",{children:[R.jsx("div",{className:A.label,children:n.t("sheet.cf.valueType.min")}),R.jsxs("div",{className:`
72
+ ${A.mTSm}
73
+ ${A.labelContainer}
74
+ `,children:[R.jsx(ee.Select,{style:{width:"50%",flexShrink:0},options:w,value:I,onChange:O=>{S(O);const L=c.createDefaultValueByValueType(O,10);s(L),v({isGradient:a,minValue:L,minValueType:O,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}}),R.jsx(dn,{disabled:!z(I),id:"min",type:I,className:A.mLSm,value:i,onChange:O=>{s(O||0),v({isGradient:a,minValue:O||0,minValueType:I,maxValue:f,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}})]}),R.jsx("div",{className:A.label,children:n.t("sheet.cf.valueType.max")}),R.jsxs("div",{className:`
75
+ ${A.mTSm}
76
+ ${A.labelContainer}
77
+ `,children:[R.jsx(ee.Select,{style:{width:"50%",flexShrink:0},options:E,value:T,onChange:O=>{h(O);const L=c.createDefaultValueByValueType(O,90);b(L),v({isGradient:a,minValue:i,minValueType:I,maxValue:L,maxValueType:O,positiveColor:u,nativeColor:p,isShowValue:l})}}),R.jsx(dn,{disabled:!z(T),id:"max",type:T,className:A.mLSm,value:f,onChange:O=>{b(O||0),v({isGradient:a,minValue:i,minValueType:I,maxValue:O||0,maxValueType:T,positiveColor:u,nativeColor:p,isShowValue:l})}})]})]})]})},Re={cfStyleEdit:"univer-cf-style-edit",buttonItem:"univer-button-item",isActive:"univer-isActive"},Rt=t=>[_.BooleanNumber.FALSE,void 0].includes(t)?_.BooleanNumber.TRUE:_.BooleanNumber.FALSE,Et=t=>t!==_.BooleanNumber.FALSE,sr=t=>{const{style:e,onChange:n,className:r}=t,a=te.useDependency(te.ComponentManager),[o,u]=V.useState(()=>{if(e!=null&&e.bl)return e.bl}),[y,p]=V.useState(()=>{if(e!=null&&e.it)return e.it}),[C,m]=V.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[w,E]=V.useState(()=>{if(e!=null&&e.st)return e.st.s}),[I,S]=V.useState(()=>{var g;const l="#2f56ef";return(g=e==null?void 0:e.cl)!=null&&g.rgb?e.cl.rgb:l}),[T,h]=V.useState(()=>{var g;const l="#e8ecfc";return(g=e==null?void 0:e.bg)!=null&&g.rgb?e.bg.rgb:l}),i=a.get("BoldSingle"),s=a.get("ItalicSingle"),f=a.get("UnderlineSingle"),b=a.get("StrikethroughSingle");return V.useEffect(()=>{const l={bl:o,it:y};I!==void 0&&(l.cl={rgb:I}),T!==void 0&&(l.bg={rgb:T}),w!==void 0&&(l.st={s:w}),C!==void 0&&(l.ul={s:C}),n(c.removeUndefinedAttr(l))},[o,y,C,w,I,T]),R.jsxs("div",{className:ee.clsx(Re.cfStyleEdit,r),children:[i&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(o||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>u(Rt(o)),children:R.jsx(i,{})}),s&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(y||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>p(Rt(y)),children:R.jsx(s,{})}),f&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(C||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>m(Rt(C)),children:R.jsx(f,{})}),b&&R.jsx("div",{className:ee.clsx({[Re.isActive]:Et(w||_.BooleanNumber.FALSE)},Re.buttonItem),onClick:()=>E(Rt(w)),children:R.jsx(b,{})}),R.jsx(Me,{color:I,onChange:S,iconId:"FontColor"}),R.jsx(Me,{color:T,onChange:h,iconId:"PaintBucket"})]})},Ia=t=>{var b;const{onChange:e,interceptorManager:n}=t,r=te.useDependency(_.LocaleService),o=te.useDependency(_.IUniverInstanceService).getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET),u=o.getActiveSheet(),y=((b=t.rule)==null?void 0:b.type)===c.CFRuleType.highlightCell?t.rule:void 0,p=V.useRef(null),[C,m]=V.useState(!1),w=V.useRef({}),[E,I]=V.useState({}),[S,T]=V.useState(()=>(y==null?void 0:y.subType)===c.CFSubRuleType.formula?y.value:"="),[h,i]=V.useState(void 0),s=l=>({style:l.style,value:S,type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.formula});V.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return s({style:E})}}),[E,S,n]),V.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(g,d,v)=>h||S.length===1||!S.startsWith("=")?(i(r.t("sheet.cf.errorMessage.formulaError")),!1):v(g)}),[h,S]);const f=l=>{e(s(l))};return te.useSidebarClick(l=>{var d;const g=(d=w.current)==null?void 0:d.handleOutClick;g&&g(l,()=>m(!1))}),R.jsxs("div",{ref:p,children:[R.jsx("div",{className:`
78
78
  ${A.title}
79
79
  ${A.mTBase}
80
80
  `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:`
@@ -84,26 +84,26 @@
84
84
  `,children:R.jsx(We,{rule:s({style:E})})}),R.jsx(sr,{style:y==null?void 0:y.style,className:`
85
85
  ${A.mTSm}
86
86
  `,onChange:l=>{I(l),f({style:l})}})]})},Ot=t=>R.jsxs("div",{style:{position:"relative"},children:[R.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:t.errorText}),t.children]}),ce=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),_a=t=>{const{type:e,operator:n,onChange:r,value:a,interceptorManager:o}=t,u=te.useDependency(_.LocaleService),[y,p]=V.useState(()=>typeof a=="number"?a:0),[C,m]=V.useState(""),[w,E]=V.useState(()=>typeof a=="string"?a:""),[I,S]=V.useState(""),[T,h]=V.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[i,s]=V.useState(""),[f,b]=V.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[l,g]=V.useState("");switch(V.useEffect(()=>{switch(e){case c.CFSubRuleType.text:{[c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(n)&&r(w);break}case c.CFSubRuleType.number:{[c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(n)&&r(y),[c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(n)&&r([T,f]);break}}},[e]),V.useEffect(()=>{const d=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(v,x,M)=>{switch(e){case c.CFSubRuleType.text:if([c.CFTextOperator.beginsWith,c.CFTextOperator.containsText,c.CFTextOperator.endsWith,c.CFTextOperator.notEqual,c.CFTextOperator.notContainsText,c.CFTextOperator.equal].includes(n))return w?M(v):(S(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(v)}});return()=>{d()}},[e,y,w,n]),e){case c.CFSubRuleType.text:{if([c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(n)){const d=v=>{E(v),r(v)};return R.jsx("div",{className:`
87
- ${A.mTSm}
88
- `,children:R.jsx(Ot,{errorText:I,children:R.jsx(ee.Input,{className:G.width100,value:w,onChange:v=>{S(""),d(v)}})})})}break}case c.CFSubRuleType.number:{if([c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(n)){const d=v=>{p(v||0),r(v||0),m("")};return R.jsx("div",{className:`
89
- ${A.mTSm}
90
- `,children:R.jsx(Ot,{errorText:C,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:G.width100,value:y,onChange:d})})})}if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(n)){const d=x=>{h(x||0),r([x||0,f]),s("")},v=x=>{b(x||0),r([T,x||0]),g("")};return R.jsxs("div",{className:`
91
- ${A.mTSm}
92
- ${A.labelContainer}
93
- `,children:[R.jsx(Ot,{errorText:i,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:T,onChange:d})}),R.jsx(Ot,{errorText:l,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:`
87
+ ${A.mTSm}
88
+ `,children:R.jsx(Ot,{errorText:I,children:R.jsx(ee.Input,{className:G.width100,value:w,onChange:v=>{S(""),d(v)}})})})}break}case c.CFSubRuleType.number:{if([c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(n)){const d=v=>{p(v||0),r(v||0),m("")};return R.jsx("div",{className:`
89
+ ${A.mTSm}
90
+ `,children:R.jsx(Ot,{errorText:C,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:G.width100,value:y,onChange:d})})})}if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(n)){const d=x=>{h(x||0),r([x||0,f]),s("")},v=x=>{b(x||0),r([T,x||0]),g("")};return R.jsxs("div",{className:`
91
+ ${A.mTSm}
92
+ ${A.labelContainer}
93
+ `,children:[R.jsx(Ot,{errorText:i,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:T,onChange:d})}),R.jsx(Ot,{errorText:l,children:R.jsx(ee.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:`
94
94
  ${A.mLSm}
95
95
  `,value:f,onChange:v})})]})}}}return null},fn=(t,e)=>{switch(t){case c.CFSubRuleType.text:return[ce(c.CFTextOperator.containsText,e),ce(c.CFTextOperator.notContainsText,e),ce(c.CFTextOperator.beginsWith,e),ce(c.CFTextOperator.endsWith,e),ce(c.CFTextOperator.equal,e),ce(c.CFTextOperator.notEqual,e),ce(c.CFTextOperator.containsBlanks,e),ce(c.CFTextOperator.notContainsBlanks,e),ce(c.CFTextOperator.containsErrors,e),ce(c.CFTextOperator.notContainsErrors,e)];case c.CFSubRuleType.number:return[ce(c.CFNumberOperator.between,e),ce(c.CFNumberOperator.notBetween,e),ce(c.CFNumberOperator.equal,e),ce(c.CFNumberOperator.notEqual,e),ce(c.CFNumberOperator.greaterThan,e),ce(c.CFNumberOperator.greaterThanOrEqual,e),ce(c.CFNumberOperator.lessThan,e),ce(c.CFNumberOperator.lessThanOrEqual,e)];case c.CFSubRuleType.timePeriod:return[ce(c.CFTimePeriodOperator.yesterday,e),ce(c.CFTimePeriodOperator.today,e),ce(c.CFTimePeriodOperator.tomorrow,e),ce(c.CFTimePeriodOperator.last7Days,e),ce(c.CFTimePeriodOperator.lastWeek,e),ce(c.CFTimePeriodOperator.thisWeek,e),ce(c.CFTimePeriodOperator.nextWeek,e),ce(c.CFTimePeriodOperator.lastMonth,e),ce(c.CFTimePeriodOperator.thisMonth,e),ce(c.CFTimePeriodOperator.nextMonth,e)]}},pn=t=>{var b;const{interceptorManager:e,onChange:n}=t,r=te.useDependency(_.LocaleService),a=((b=t.rule)==null?void 0:b.type)===c.CFRuleType.highlightCell?t.rule:void 0,[o,u]=V.useState(()=>{const l=c.CFSubRuleType.text;return a&&a.subType||l}),y=[{value:c.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:c.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:c.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:c.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:c.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],p=V.useMemo(()=>fn(o,r),[o]),[C,m]=V.useState(()=>{const l=p?p[0].value:void 0;return a&&a.operator||l}),[w,E]=V.useState(()=>{var d;const l="";return a?(d=a.value)!=null?d:c.createDefaultValue(a.subType,a.operator):l}),[I,S]=V.useState({}),T=V.useMemo(()=>l=>{var g,d,v,x,M,z,U,O,L,F,q,J,le,ae,B;switch(l.subType||o){case c.CFSubRuleType.text:{if([c.CFTextOperator.beginsWith,c.CFTextOperator.endsWith,c.CFTextOperator.containsText,c.CFTextOperator.notContainsText,c.CFTextOperator.equal,c.CFTextOperator.notEqual].includes(C))return{type:c.CFRuleType.highlightCell,subType:(g=l.subType)!=null?g:o,operator:(d=l.operator)!=null?d:C,style:(v=l.style)!=null?v:I,value:(x=l.value)!=null?x:w};break}case c.CFSubRuleType.number:{if([c.CFNumberOperator.equal,c.CFNumberOperator.notEqual,c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual,c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(C))return{type:c.CFRuleType.highlightCell,subType:(M=l.subType)!=null?M:o,operator:(z=l.operator)!=null?z:C,style:(U=l.style)!=null?U:I,value:(O=l.value)!=null?O:w};if([c.CFNumberOperator.between,c.CFNumberOperator.notBetween].includes(C))return{type:c.CFRuleType.highlightCell,subType:(L=l.subType)!=null?L:o,operator:(F=l.operator)!=null?F:C,style:(q=l.style)!=null?q:I,value:(J=l.value)!=null?J:w};break}}return{type:c.CFRuleType.highlightCell,subType:(le=l.subType)!=null?le:o,operator:(ae=l.operator)!=null?ae:C,style:(B=l.style)!=null?B:I}},[o,C,w,I]);V.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({})}}),[T,e]),V.useEffect(()=>{y.some(l=>l.value===o)||u(y[0].value)},[y]);const h=l=>{const g=l,d=fn(g,r),v=d&&d[0].value;u(g),m(v),v&&E(c.createDefaultValue(g,v)),n(T({subType:g,operator:v}))},i=l=>{const g=l;m(g),n(T({operator:g}))},s=l=>{E(l),n(T({value:l}))},f=V.useMemo(()=>`${o}_${C}_${Math.random()}`,[o,C]);return R.jsxs("div",{children:[R.jsx("div",{className:`
96
- ${A.title}
97
- ${A.mTBase}
98
- `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
96
+ ${A.title}
97
+ ${A.mTBase}
98
+ `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
99
99
  ${A.mTSm}
100
100
  ${G.width100}
101
101
  `,onChange:h,value:o,options:y}),(p==null?void 0:p.length)&&R.jsx(ee.Select,{className:`
102
102
  ${A.mTSm}
103
103
  ${G.width100}
104
104
  `,onChange:i,value:C||"",options:p}),R.jsx(_a,{value:w,interceptorManager:e,type:o,operator:C,rule:a,onChange:s},f),R.jsx("div",{className:`
105
- ${G.cfPreviewWrap}
106
- `,children:R.jsx(We,{rule:T({})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
105
+ ${G.cfPreviewWrap}
106
+ `,children:R.jsx(We,{rule:T({})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
107
107
  ${A.mLXxs}
108
108
  `,onChange:l=>{S(l),n(T({style:l}))}})]})},hn=(t,e)=>(c.iconMap[t]||[])[Number(e)]||"",Ra=t=>{var p;const e=te.useDependency(_.IUniverInstanceService),n=e.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId(),r=(p=e.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:p.getSheetId(),a=V.useMemo(()=>t.error?G.errorInput:"",[t.error]),o=V.useRef({}),[u,y]=V.useState(!1);return te.useSidebarClick(C=>{var w;const m=(w=o.current)==null?void 0:w.handleOutClick;m&&m(C,()=>y(!1))}),R.jsx("div",{className:G.positionRelative,children:t.type!==c.CFValueType.formula?R.jsxs(R.Fragment,{children:[R.jsx(ee.InputNumber,{className:a,value:Number(t.value)||0,onChange:C=>t.onChange(C!=null?C:0)}),t.error&&R.jsx("div",{className:G.errorText,children:t.error})]}):R.jsx("div",{style:{width:"100%"},children:R.jsx(Ge.FormulaEditor,{initValue:String(t.value),unitId:n,subUnitId:r,isFocus:u,onChange:(C="")=>{const m=C||"";t.onChange(m)},onFocus:()=>y(!0),actions:o.current})})})},gn=(t,e,n)=>({operator:c.CFNumberOperator.greaterThan,value:{type:c.CFValueType.num,value:(n.length-1-e)*10},iconType:t,iconId:String(e)}),Ea=V.forwardRef((t,e)=>{const n=te.useDependency(_.LocaleService),r=a=>{t.onClick(a)};return R.jsx("div",{ref:e,className:G.iconGroupList,children:c.iconGroup.map((a,o)=>R.jsxs("div",{className:G.group,children:[R.jsx("div",{className:G.title,children:n.t(a.title)}),R.jsx("div",{className:G.itemContent,children:a.group.map(u=>R.jsx("div",{className:G.itemWrap,onClick:()=>{r(u.name)},children:R.jsx("div",{className:G.item,children:u.list.map((y,p)=>R.jsx("img",{className:G.icon,src:y},p))})},u.name))})]},o))})}),Oa=t=>{const e=V.useMemo(()=>{const r=[];for(const a in c.iconMap){const o=c.iconMap[a],u=a;o.forEach((y,p)=>{r.push({iconType:u,base64:y,iconId:String(p)})})}return r},[]),n=r=>{t.onClick(r.iconType,r.iconId)};return R.jsxs("div",{className:G.iconItemListWrap,children:[R.jsxs("div",{className:G.none,onClick:()=>n({iconType:c.EMPTY_ICON_TYPE,iconId:""}),children:[R.jsx(Xe,{className:G.icon}),R.jsx("span",{children:"无单元格图标"})]}),R.jsx("div",{className:G.iconItemList,children:e.map(r=>R.jsx("div",{className:G.item,children:R.jsx("img",{onClick:()=>n(r),className:`
109
109
  ${G.icon}
@@ -155,21 +155,21 @@
155
155
  ${G.utilItem}
156
156
  ${A.mLXl}
157
157
  `,children:[R.jsx(ee.Checkbox,{checked:!m,onChange:l=>{w(!l)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),R.jsx(Pa,{errorMap:a,onChange:S,configList:p})]})},xa=t=>{var h;const{onChange:e,interceptorManager:n}=t,r=te.useDependency(_.LocaleService),a=((h=t.rule)==null?void 0:h.type)===c.CFRuleType.highlightCell?t.rule:void 0,o=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[u,y]=V.useState(()=>{const i=o[0].value,s=a==null?void 0:a.type;if(!a)return i;switch(s){case c.CFRuleType.highlightCell:switch(a.subType){case c.CFSubRuleType.average:return[c.CFNumberOperator.greaterThan,c.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[c.CFNumberOperator.lessThan,c.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":i;case c.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return i}),[p,C]=V.useState(()=>{const s=a==null?void 0:a.type;if(!a)return 10;switch(s){case c.CFRuleType.highlightCell:switch(a.subType){case c.CFSubRuleType.rank:return a.value||10}}return 10}),[m,w]=V.useState(()=>{const s=a==null?void 0:a.type;if(!a)return!1;switch(s){case c.CFRuleType.highlightCell:switch(a.subType){case c.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[E,I]=V.useState({}),S=i=>{const{type:s,isPercent:f,value:b,style:l}=i;if(s==="isNotBottom")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank,isPercent:f,isBottom:!1,value:b,style:l};if(s==="isBottom")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.rank,isPercent:f,isBottom:!0,value:b,style:l};if(s==="greaterThanAverage")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.average,operator:c.CFNumberOperator.greaterThan,style:l};if(s==="lessThanAverage")return{type:c.CFRuleType.highlightCell,subType:c.CFSubRuleType.average,operator:c.CFNumberOperator.lessThan,style:l}};V.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:u,isPercent:m,value:p,style:E})}}),[u,m,p,E,n]);const T=i=>{e(S(i))};return R.jsxs("div",{children:[R.jsx("div",{className:`
158
- ${A.title}
159
- ${A.mTBase}
160
- `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
158
+ ${A.title}
159
+ ${A.mTBase}
160
+ `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
161
161
  ${G.width100}
162
162
  ${A.mTSm}
163
163
  `,value:u,options:o,onChange:i=>{y(i),T({type:i,isPercent:m,value:p,style:E})}}),["isNotBottom","isBottom"].includes(u)&&R.jsxs("div",{className:`
164
- ${A.labelContainer}
165
- ${A.mTSm}
166
- `,children:[R.jsx(ee.InputNumber,{min:1,max:1e3,value:p,onChange:i=>{const s=i||0;C(s),T({type:u,isPercent:m,value:s,style:E})}}),R.jsxs("div",{className:`
167
- ${A.mLSm}
168
164
  ${A.labelContainer}
169
- ${G.text}
170
- `,children:[R.jsx(ee.Checkbox,{checked:m,onChange:i=>{w(!!i),T({type:u,isPercent:!!i,value:p,style:E})}}),r.t("sheet.cf.valueType.percent")]})]}),R.jsx("div",{className:`
171
- ${G.cfPreviewWrap}
172
- `,children:R.jsx(We,{rule:S({type:u,isPercent:m,value:p,style:E})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
165
+ ${A.mTSm}
166
+ `,children:[R.jsx(ee.InputNumber,{min:1,max:1e3,value:p,onChange:i=>{const s=i||0;C(s),T({type:u,isPercent:m,value:s,style:E})}}),R.jsxs("div",{className:`
167
+ ${A.mLSm}
168
+ ${A.labelContainer}
169
+ ${G.text}
170
+ `,children:[R.jsx(ee.Checkbox,{checked:m,onChange:i=>{w(!!i),T({type:u,isPercent:!!i,value:p,style:E})}}),r.t("sheet.cf.valueType.percent")]})]}),R.jsx("div",{className:`
171
+ ${G.cfPreviewWrap}
172
+ `,children:R.jsx(We,{rule:S({type:u,isPercent:m,value:p,style:E})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
173
173
  ${A.mTSm}
174
174
  `,onChange:i=>{I(i),T({type:u,isPercent:m,value:p,style:i})}})]})},Ma=_.createInterceptorKey("beforeSubmit"),Na=_.createInterceptorKey("submit"),vn=t=>t.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getUnitId(),mn=t=>{var e;return(e=t.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},La=t=>{var d,v,x;const e=te.useDependency(_.LocaleService),n=te.useDependency(_.ICommandService),r=te.useDependency(_.IUniverInstanceService),a=te.useDependency(c.ConditionalFormattingRuleModel),o=te.useDependency(Y.SheetsSelectionsService),u=vn(r),y=mn(r),[p,C]=V.useState(void 0),m=V.useRef((v=(d=t.rule)==null?void 0:d.ranges)!=null?v:[]),w=V.useMemo(()=>{var z,U,O;let M=(z=t.rule)==null?void 0:z.ranges;return M!=null&&M.length||(M=(O=(U=o.getCurrentSelections())==null?void 0:U.map(L=>L.range))!=null?O:[]),m.current=M,M!=null&&M.length?M.map(L=>{const F=kt.serializeRange(L);return F==="NaN"?"":F}).filter(L=>!!L).join(","):""},[t.rule]),E=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[I,S]=V.useState(()=>{var U,O;const M=(U=t.rule)==null?void 0:U.rule.type,z=E[0].value;if(!M)return z;switch(M){case c.CFRuleType.highlightCell:{switch((O=t.rule)==null?void 0:O.rule.subType){case c.CFSubRuleType.number:case c.CFSubRuleType.text:case c.CFSubRuleType.duplicateValues:case c.CFSubRuleType.uniqueValues:case c.CFSubRuleType.timePeriod:return"1";case c.CFSubRuleType.average:case c.CFSubRuleType.rank:return"2";case c.CFSubRuleType.formula:return"5"}break}case c.CFRuleType.dataBar:return"3";case c.CFRuleType.colorScale:return"4";case c.CFRuleType.iconSet:return"6"}return z}),T=V.useRef(void 0),h=V.useMemo(()=>new _.InterceptorManager({beforeSubmit:Ma,submit:Na}),[]),i=V.useMemo(()=>{switch(I){case"1":return pn;case"2":return xa;case"3":return wa;case"4":return Ta;case"5":return Ia;case"6":return Da;default:return pn}},[I]);V.useEffect(()=>{const M=n.onCommandExecuted(z=>{if(z.id===Y.RemoveSheetMutation.id){const U=z.params;U.subUnitId===y&&U.unitId===u&&t.onCancel()}z.id===Y.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>M.dispose()},[]);const s=M=>{T.current=M},f=M=>{const z=M.split(",").filter(U=>!!U).map(kt.deserializeRangeWithSheet).map(U=>U.range);m.current=z},b=()=>{if(p)return;const z=(()=>{const O=r.getCurrentUnitForType(_.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!O)throw new Error("No active sheet found");return m.current.map(q=>Y.setEndForRange(q,O.getRowCount(),O.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(h.fetchThroughInterceptors(h.getInterceptPoints().beforeSubmit)(!0,null)){const O=h.fetchThroughInterceptors(h.getInterceptPoints().submit)(null,null);if(O){const L=vn(r),F=mn(r);if(!L||!F)throw new Error("No active sheet found");let q={};t.rule&&t.rule.cfId?(q={...t.rule,ranges:z,rule:O},n.executeCommand(c.SetCfCommand.id,{unitId:L,subUnitId:F,rule:q}),t.onCancel()):(q={cfId:a.createCfId(L,F),ranges:z,rule:O,stopIfTrue:!1},n.executeCommand(c.AddCfCommand.id,{unitId:L,subUnitId:F,rule:q}),t.onCancel())}}},l=()=>{t.onCancel()},g=(M,z)=>{M?z.length<1?C(e.t("sheet.cf.errorMessage.rangeError")):C(void 0):C(e.t("sheet.cf.errorMessage.rangeError"))};return R.jsxs("div",{className:G.cfRuleStyleEditor,children:[R.jsx("div",{className:A.title,children:e.t("sheet.cf.panel.range")}),R.jsxs("div",{className:`
175
175
  ${A.mTBase}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-conditional-formatting",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,13 +57,13 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-conditional-formatting": "0.6.2",
61
- "@univerjs/sheets-conditional-formatting-ui": "0.6.2"
60
+ "@univerjs/sheets-conditional-formatting": "0.6.3",
61
+ "@univerjs/sheets-conditional-formatting-ui": "0.6.3"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.6.2",
64
+ "@univerjs/core": "0.6.3",
65
65
  "typescript": "^5.7.3",
66
- "@univerjs-infra/shared": "0.6.2"
66
+ "@univerjs-infra/shared": "0.6.3"
67
67
  },
68
68
  "scripts": {
69
69
  "prebuild:preset": "tsx prepare.ts",