@univerjs/sheets-conditional-formatting 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +32 -38
- package/lib/es/index.js +288 -283
- package/lib/facade.js +32 -38
- package/lib/index.js +288 -283
- package/lib/types/facade/index.d.ts +0 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/models/calculate-unit-v2/__test__/test.util.d.ts +1 -1
- package/lib/types/models/calculate-unit-v2/utils.d.ts +1 -1
- package/lib/types/plugin.d.ts +3 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/lib/types/facade/f-workbook.d.ts +0 -18
- /package/lib/types/{controllers/config.schema.d.ts → config/config.d.ts} +0 -0
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import './f-range';
|
|
17
|
-
import './f-workbook';
|
|
18
17
|
import './f-worksheet';
|
|
19
18
|
import './f-enum';
|
|
20
19
|
export { FConditionalFormattingBuilder } from './f-conditional-formatting-builder';
|
|
21
20
|
export type { IFRangeConditionalFormattingMixin } from './f-range';
|
|
22
|
-
export type { FWorkbookConditionalFormattingMixin } from './f-workbook';
|
|
23
21
|
export type { IFWorksheetConditionalFormattingMixin } from './f-worksheet';
|
package/lib/types/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export { DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory
|
|
|
25
25
|
export { type IMoveConditionalRuleMutationParams, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory, } from './commands/mutations/move-conditional-rule.mutation';
|
|
26
26
|
export type { ISetConditionalRuleMutationParams } from './commands/mutations/set-conditional-rule.mutation';
|
|
27
27
|
export { SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from './commands/mutations/set-conditional-rule.mutation';
|
|
28
|
-
export type { IUniverSheetsConditionalFormattingConfig } from './
|
|
28
|
+
export type { IUniverSheetsConditionalFormattingConfig } from './config/config';
|
|
29
29
|
export * from './models/calculate-unit-v2/utils';
|
|
30
30
|
export * from './models/conditional-formatting-rule-model';
|
|
31
31
|
export * from './models/conditional-formatting-view-model';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dependency, ICommandService, Univer } from '@univerjs/core';
|
|
2
|
-
import { ConditionalFormattingRuleModel } from '../../../models/conditional-formatting-rule-model';
|
|
3
2
|
import { ConditionalFormattingService } from '../../../services/conditional-formatting.service';
|
|
3
|
+
import { ConditionalFormattingRuleModel } from '../../conditional-formatting-rule-model';
|
|
4
4
|
import { ConditionalFormattingViewModel } from '../../conditional-formatting-view-model';
|
|
5
5
|
export declare const createTestBed: (dependencies?: Dependency[]) => {
|
|
6
6
|
univer: Univer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, ColorKit, ObjectMatrix } from '@univerjs/core';
|
|
2
|
-
import { IConditionFormattingRule, IValueConfig } from '
|
|
2
|
+
import { IConditionFormattingRule, IValueConfig } from '../type';
|
|
3
3
|
import { IContext } from './base-calculate-unit';
|
|
4
4
|
import { FormulaResultStatus } from '@univerjs/engine-formula';
|
|
5
5
|
import { CFNumberOperator } from '../../base/const';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IUniverSheetsConditionalFormattingConfig } from './
|
|
1
|
+
import { IUniverSheetsConditionalFormattingConfig } from './config/config';
|
|
2
2
|
import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
3
|
export declare class UniverSheetsConditionalFormattingPlugin extends Plugin {
|
|
4
4
|
private readonly _config;
|
|
@@ -6,6 +6,8 @@ export declare class UniverSheetsConditionalFormattingPlugin extends Plugin {
|
|
|
6
6
|
private _commandService;
|
|
7
7
|
private readonly _configService;
|
|
8
8
|
static pluginName: string;
|
|
9
|
+
static packageName: string;
|
|
10
|
+
static version: string;
|
|
9
11
|
static type: UniverInstanceType;
|
|
10
12
|
constructor(_config: Partial<IUniverSheetsConditionalFormattingConfig> | undefined, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
|
|
11
13
|
onStarting(): void;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(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"})}));
|
|
1
|
+
(function(i,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):(i=typeof globalThis<"u"?globalThis:i||self,u(i.UniverSheetsConditionalFormattingFacade={},i.UniverCore,i.UniverSheetsConditionalFormatting,i.UniverSheetsFacade,i.UniverCoreFacade))})(this,(function(i,u,t,C,y){"use strict";var d=Object.defineProperty;var R=(i,u,t)=>u in i?d(i,u,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[u]=t;var T=(i,u,t)=>R(i,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((l,s)=>(l[s]||(l[s]={}),l[s]),e),e}build(){var l;this._rule.cfId||(this._rule.cfId=t.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=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 l=new u.ColorKit(e);this._ruleConfig.style.bg.rgb=l.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 l=new u.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 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 l=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=[l,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 l=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=[l,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 a extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new a(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 f extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new f(e)}setColorScale(e){const r=this._ruleConfig;return r.type=t.CFRuleType.colorScale,r.config=e,this}}class c extends o{copy(){const e=u.Tools.deepClone(this._rule);return e.cfId&&(e.cfId=t.createCfId()),new c(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 c(this._initConfig).setIconSet(e)}setColorScale(e){return new f(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,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(l=>u.Rectangle.intersects(l,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,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:l}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:r,cfId:e};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,l),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.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,l="after"){const s={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:"self"},end:{id:r,type:l}};return this._commandService.syncExecuteCommand(t.MoveCfCommand.id,s),this}setConditionalFormattingRule(e,r){const l={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:r};return this._commandService.syncExecuteCommand(t.SetCfCommand.id,l),this}clearConditionalFormatRules(){const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(t.ClearWorksheetCfCommand.id,e),this}}C.FWorksheet.extend(w);class b{get ConditionFormatNumberOperatorEnum(){return t.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return t.CFTimePeriodOperator}}y.FEnum.extend(b),i.FConditionalFormattingBuilder=p,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|