@univerjs/sheets-conditional-formatting 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +4 -51
- package/lib/cjs/index.js +19 -15
- package/lib/es/facade.js +4 -51
- package/lib/es/index.js +21 -17
- package/lib/facade.js +4 -51
- package/lib/index.js +21 -17
- package/lib/types/facade/f-range.d.ts +1 -40
- package/lib/types/facade/f-worksheet.d.ts +0 -8
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';
|
|
17
17
|
import { FRange } from '@univerjs/sheets/facade';
|
|
18
18
|
import { FConditionalFormattingBuilder } from './f-conditional-formatting-builder';
|
|
19
19
|
/**
|
|
@@ -69,41 +69,6 @@ export interface IFRangeSheetsConditionalFormattingMixin {
|
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
72
|
-
/**
|
|
73
|
-
* Add a new conditional format
|
|
74
|
-
* @deprecated use same API in FWorkSheet.
|
|
75
|
-
* @param {IConditionFormattingRule} rule
|
|
76
|
-
* @returns {FRange} Returns the current range instance for method chaining
|
|
77
|
-
* @memberof IFRangeConditionalFormattingMixin
|
|
78
|
-
*/
|
|
79
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule): FRange;
|
|
80
|
-
/**
|
|
81
|
-
* Delete conditional format according to `cfId`
|
|
82
|
-
* @deprecated use same API in FWorkSheet.
|
|
83
|
-
* @param {string} cfId
|
|
84
|
-
* @returns {FRange} Returns the current range instance for method chaining
|
|
85
|
-
* @memberof IFRangeConditionalFormattingMixin
|
|
86
|
-
*/
|
|
87
|
-
deleteConditionalFormattingRule(cfId: string): FRange;
|
|
88
|
-
/**
|
|
89
|
-
* Modify the priority of the conditional format
|
|
90
|
-
* @deprecated use same API in FWorkSheet.
|
|
91
|
-
* @param {string} cfId Rules that need to be moved
|
|
92
|
-
* @param {string} toCfId Target rule
|
|
93
|
-
* @param {IAnchor['type']} [type] After the default move to the destination rule, if type = before moves to the front, the default value is after
|
|
94
|
-
* @returns {FRange} Returns the current range instance for method chaining
|
|
95
|
-
* @memberof FRangeConditionalFormattingMixin
|
|
96
|
-
*/
|
|
97
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FRange;
|
|
98
|
-
/**
|
|
99
|
-
* Set the conditional format according to `cfId`
|
|
100
|
-
* @deprecated use same API in FWorkSheet.
|
|
101
|
-
* @param {string} cfId
|
|
102
|
-
* @param {IConditionFormattingRule} rule
|
|
103
|
-
* @returns {FRange} Returns the current range instance for method chaining
|
|
104
|
-
* @memberof IFRangeConditionalFormattingMixin
|
|
105
|
-
*/
|
|
106
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FRange;
|
|
107
72
|
/**
|
|
108
73
|
* Clear the conditional rules for the range.
|
|
109
74
|
* @returns {FRange} Returns the current range instance for method chaining
|
|
@@ -126,10 +91,6 @@ export declare class FRangeSheetsConditionalFormattingMixin extends FRange imple
|
|
|
126
91
|
private _getConditionalFormattingRuleModel;
|
|
127
92
|
getConditionalFormattingRules(): IConditionFormattingRule[];
|
|
128
93
|
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
129
|
-
addConditionalFormattingRule(rule: IConditionFormattingRule): FRange;
|
|
130
|
-
deleteConditionalFormattingRule(cfId: string): FRange;
|
|
131
|
-
moveConditionalFormattingRule(cfId: string, toCfId: string, type?: IAnchor['type']): FRange;
|
|
132
|
-
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FRange;
|
|
133
94
|
clearConditionalFormatRules(): FRange;
|
|
134
95
|
}
|
|
135
96
|
declare module '@univerjs/sheets/facade' {
|
|
@@ -34,13 +34,6 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
getConditionalFormattingRules(): IConditionFormattingRule[];
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated use `newConditionalFormattingRule` instead.
|
|
39
|
-
* Creates a constructor for conditional formatting
|
|
40
|
-
* @returns {FConditionalFormattingBuilder} The conditional formatting builder
|
|
41
|
-
* @memberof IFWorksheetConditionalFormattingMixin
|
|
42
|
-
*/
|
|
43
|
-
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
44
37
|
/**
|
|
45
38
|
* Creates a constructor for conditional formatting
|
|
46
39
|
* @returns {FConditionalFormattingBuilder} The conditional formatting builder
|
|
@@ -174,7 +167,6 @@ export interface IFWorksheetConditionalFormattingMixin {
|
|
|
174
167
|
export declare class FWorksheetConditionalFormattingMixin extends FWorksheet implements IFWorksheetConditionalFormattingMixin {
|
|
175
168
|
private _getConditionalFormattingRuleModel;
|
|
176
169
|
getConditionalFormattingRules(): IConditionFormattingRule[];
|
|
177
|
-
createConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
178
170
|
newConditionalFormattingRule(): FConditionalFormattingBuilder;
|
|
179
171
|
addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet;
|
|
180
172
|
deleteConditionalFormattingRule(cfId: string): FWorksheet;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:t,cfId:e};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}createConditionalFormattingRule(){return new m}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-conditional-formatting`,`@univerjs/sheets/facade`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingFacade={},e.UniverCore,e.UniverSheetsConditionalFormatting,e.UniverSheetsFacade,e.UniverCoreFacade))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class e{get _ruleConfig(){return this._rule.rule||null}_getDefaultConfig(e=n.CFRuleType.highlightCell){switch(e){case n.CFRuleType.colorScale:return{type:e,config:[{index:0,color:new t.ColorKit(``).toRgbString(),value:{type:n.CFValueType.min}},{index:0,color:new t.ColorKit(`green`).toRgbString(),value:{type:n.CFValueType.max}}]};case n.CFRuleType.dataBar:return{type:e,isShowValue:!0,config:{min:{type:n.CFValueType.min},max:{type:n.CFValueType.max},positiveColor:new t.ColorKit(`green`).toRgbString(),nativeColor:new t.ColorKit(``).toRgbString(),isGradient:!1}};case n.CFRuleType.highlightCell:return{type:e,subType:n.CFSubRuleType.text,operator:n.CFTextOperator.containsText,value:`abc`,style:{}};case n.CFRuleType.iconSet:return{type:e,isShowValue:!0,config:[{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.min},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.greaterThanOrEqual,value:{type:n.CFValueType.percentile,value:.5},iconType:n.IIconSetType.empty,iconId:``},{operator:n.CFNumberOperator.lessThanOrEqual,value:{type:n.CFValueType.max},iconType:n.IIconSetType.empty,iconId:``}]}}}constructor(e={}){c(this,`_rule`,{}),this._rule=e,this._ensureAttr(this._rule,[`rule`])}_ensureAttr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]={}),e[t]),e),e}build(){var e;this._rule.cfId||(this._rule.cfId=(0,n.createCfId)()),this._rule.ranges||(this._rule.ranges=[]),this._rule.stopIfTrue===void 0&&(this._rule.stopIfTrue=!1),(e=this._rule.rule)!=null&&e.type||(this._rule.rule.type=n.CFRuleType.highlightCell,this._ensureAttr(this._rule,[`rule`,`style`]));let t=this._getDefaultConfig(this._rule.rule.type);return{...this._rule,rule:{...t,...this._rule.rule}}}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}getRanges(){return this._rule.ranges||[]}getIconMap(){return n.iconMap}createCfId(){return(0,n.createCfId)()}setRanges(e){return this._rule.ranges=e,this}},u=class e extends l{constructor(e={}){super(e),this._ensureAttr(this._rule,[`rule`,`style`])}copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setAverage(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.average,t.operator=e,this}setUniqueValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.uniqueValues,this}setDuplicateValues(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.duplicateValues,this}setRank(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.rank,t.isBottom=e.isBottom,t.isPercent=e.isPercent,t.value=e.value,this}setBackground(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){this._ensureAttr(this._ruleConfig,[`style`,`bg`]);let n=new t.ColorKit(e);this._ruleConfig.style.bg.rgb=n.toRgbString()}else delete this._ruleConfig.style.bg;return this}setBold(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.bl=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setFontColor(e){var r;if(((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell)if(e){let n=new t.ColorKit(e);this._ensureAttr(this._ruleConfig,[`style`,`cl`]),this._ruleConfig.style.cl.rgb=n.toRgbString()}else delete this._ruleConfig.style.cl;return this}setItalic(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`]),this._ruleConfig.style.it=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setStrikethrough(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`st`]),this._ruleConfig.style.st.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}setUnderline(e){var r;return((r=this._ruleConfig)==null?void 0:r.type)===n.CFRuleType.highlightCell&&(this._ensureAttr(this._ruleConfig,[`style`,`ul`]),this._ruleConfig.style.ul.s=e?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE),this}whenCellEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.equal,this}whenCellNotEmpty(){let e=this._ruleConfig;return e.type=n.CFRuleType.highlightCell,e.subType=n.CFSubRuleType.text,e.value=``,e.operator=n.CFTextOperator.notEqual,this}whenDate(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.timePeriod,t.operator=e,this}whenFormulaSatisfied(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.formula,t.value=e,this}whenNumberBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.between,this}whenNumberEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.equal,this}whenNumberGreaterThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThan,this}whenNumberGreaterThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.greaterThanOrEqual,this}whenNumberLessThan(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThan,this}whenNumberLessThanOrEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.lessThanOrEqual,this}whenNumberNotBetween(e,t){let r=Math.min(e,t),i=Math.max(e,t),a=this._ruleConfig;return a.type=n.CFRuleType.highlightCell,a.subType=n.CFSubRuleType.number,a.value=[r,i],a.operator=n.CFNumberOperator.notBetween,this}whenNumberNotEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.number,t.value=e,t.operator=n.CFNumberOperator.notEqual,this}whenTextContains(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.containsText,this}whenTextDoesNotContain(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.notContainsText,this}whenTextEndsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.endsWith,this}whenTextEqualTo(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.equal,this}whenTextStartsWith(e){let t=this._ruleConfig;return t.type=n.CFRuleType.highlightCell,t.subType=n.CFSubRuleType.text,t.value=e,t.operator=n.CFTextOperator.beginsWith,this}},d=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setDataBar(e){let t=this._ruleConfig;return t.type=n.CFRuleType.dataBar,t.isShowValue=!!e.isShowValue,t.config={min:e.min,max:e.max,positiveColor:e.positiveColor,nativeColor:e.nativeColor,isGradient:!!e.isGradient},this}},f=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setColorScale(e){let t=this._ruleConfig;return t.type=n.CFRuleType.colorScale,t.config=e,this}},p=class e extends l{copy(){let r=t.Tools.deepClone(this._rule);return r.cfId&&(r.cfId=(0,n.createCfId)()),new e(r)}setIconSet(e){let t=this._ruleConfig;return t.type=n.CFRuleType.iconSet,t.config=e.iconConfigs,t.isShowValue=e.isShowValue,this}},m=class{constructor(e={}){this._initConfig=e}build(){return new l(this._initConfig).build()}setAverage(e){return new u(this._initConfig).setAverage(e)}setUniqueValues(){return new u(this._initConfig).setUniqueValues()}setDuplicateValues(){return new u(this._initConfig).setDuplicateValues()}setRank(e){return new u(this._initConfig).setRank(e)}getIconMap(){return n.iconMap}setIconSet(e){return new p(this._initConfig).setIconSet(e)}setColorScale(e){return new f(this._initConfig).setColorScale(e)}setDataBar(e){return new d(this._initConfig).setDataBar(e)}setBackground(e){return new u(this._initConfig).setBackground(e)}setBold(e){return new u(this._initConfig).setBold(e)}setFontColor(e){return new u(this._initConfig).setFontColor(e)}setItalic(e){return new u(this._initConfig).setItalic(e)}setStrikethrough(e){return new u(this._initConfig).setStrikethrough(e)}setUnderline(e){return new u(this._initConfig).setUnderline(e)}whenCellEmpty(){return new u(this._initConfig).whenCellEmpty()}whenCellNotEmpty(){return new u(this._initConfig).whenCellNotEmpty()}whenDate(e){return new u(this._initConfig).whenDate(e)}whenFormulaSatisfied(e){return new u(this._initConfig).whenFormulaSatisfied(e)}whenNumberBetween(e,t){return new u(this._initConfig).whenNumberBetween(e,t)}whenNumberEqualTo(e){return new u(this._initConfig).whenNumberEqualTo(e)}whenNumberGreaterThan(e){return new u(this._initConfig).whenNumberGreaterThan(e)}whenNumberGreaterThanOrEqualTo(e){return new u(this._initConfig).whenNumberGreaterThanOrEqualTo(e)}whenNumberLessThan(e){return new u(this._initConfig).whenNumberLessThan(e)}whenNumberLessThanOrEqualTo(e){return new u(this._initConfig).whenNumberLessThanOrEqualTo(e)}whenNumberNotBetween(e,t){return new u(this._initConfig).whenNumberNotBetween(e,t)}whenNumberNotEqualTo(e){return new u(this._initConfig).whenNumberNotEqualTo(e)}whenTextContains(e){return new u(this._initConfig).whenTextContains(e)}whenTextDoesNotContain(e){return new u(this._initConfig).whenTextDoesNotContain(e)}whenTextEndsWith(e){return new u(this._initConfig).whenTextEndsWith(e)}whenTextEqualTo(e){return new u(this._initConfig).whenTextEqualTo(e)}whenTextStartsWith(e){return new u(this._initConfig).whenTextStartsWith(e)}},h=class extends r.FRange{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]].filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,this._range)))}createConditionalFormattingRule(){return new m({ranges:[this._range]})}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]};return this._commandService.syncExecuteCommand(n.ClearRangeCfCommand.id,e),this}};r.FRange.extend(h);var g=class extends r.FWorksheet{_getConditionalFormattingRuleModel(){return this._injector.get(n.ConditionalFormattingRuleModel)}getConditionalFormattingRules(){return[...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(),this._worksheet.getSheetId())||[]]}newConditionalFormattingRule(){return new m}addConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:e};return this._commandService.syncExecuteCommand(n.AddCfCommand.id,t),this}deleteConditionalFormattingRule(e){let t={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e};return this._commandService.syncExecuteCommand(n.DeleteCfCommand.id,t),this}moveConditionalFormattingRule(e,t,r=`after`){let i={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),start:{id:e,type:`self`},end:{id:t,type:r}};return this._commandService.syncExecuteCommand(n.MoveCfCommand.id,i),this}setConditionalFormattingRule(e,t){let r={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),cfId:e,rule:t};return this._commandService.syncExecuteCommand(n.SetCfCommand.id,r),this}clearConditionalFormatRules(){let e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()};return this._commandService.syncExecuteCommand(n.ClearWorksheetCfCommand.id,e),this}};r.FWorksheet.extend(g);var _=class extends i.FEnum{get ConditionFormatNumberOperatorEnum(){return n.CFNumberOperator}get ConditionFormatTimePeriodOperatorEnum(){return n.CFTimePeriodOperator}get ConditionFormatIconSetTypeEnum(){return n.IIconSetType}get ConditionFormatValueTypeEnum(){return n.CFValueType}};i.FEnum.extend(_),e.FConditionalFormattingBuilder=m});
|