Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: add condition format facade api enum (#6891)
wpxp12345688eb25b40887
diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/IconSet.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/IconSet.tsxindex fd8192ffd4..a86afcd63d 100644--- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/IconSet.tsx+++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-edit/IconSet.tsx@@ -15,29 +15,18 @@*/import type { Workbook } from '@univerjs/core';-import type { IIconSet, IIconType } from '@univerjs/sheets-conditional-formatting';+import type { IIconSet } from '@univerjs/sheets-conditional-formatting';import type { IFormulaEditorRef } from '@univerjs/sheets-formula-ui';import type { IStyleEditorProps } from './type';import { get, IUniverInstanceService, LocaleService, set, Tools, UniverInstanceType } from '@univerjs/core';import { borderClassName, Checkbox, clsx, Dropdown, InputNumber, Select } from '@univerjs/design';import { MoreDownIcon, SlashDoubleIcon } from '@univerjs/icons';-import {- CFNumberOperator,- CFRuleType,- CFSubRuleType,- CFValueType,- compareWithNumber,- createDefaultValue,- EMPTY_ICON_TYPE,- getOppositeOperator,- iconGroup,- iconMap,-} from '@univerjs/sheets-conditional-formatting';+import { CFNumberOperator, CFRuleType, CFSubRuleType, CFValueType, compareWithNumber, createDefaultValue, getOppositeOperator, iconGroup, iconMap, IIconSetType } from '@univerjs/sheets-conditional-formatting';import { FormulaEditor } from '@univerjs/sheets-formula-ui';import { ILayoutService, useDependency, useScrollYOverContainer, useSidebarClick } from '@univerjs/ui';import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';-const getIcon = (iconType: string, iconId: string | number) => {+const getIcon = (iconType: IIconSetType, iconId: string | number) => {const arr = iconMap[iconType] || [];return arr[Number(iconId)] || '';};@@ -102,7 +91,7 @@ const TextInput = (props: { id: number; type: CFValueType; value: number | strin</div>);};-const createDefaultConfigItem = (iconType: IIconType, index: number, list: unknown[]): IIconSet['config'][number] => ({+const createDefaultConfigItem = (iconType: IIconSetType, index: number, list: unknown[]): IIconSet['config'][number] => ({operator: CFNumberOperator.greaterThan,value: { type: CFValueType.num, value: (list.length - 1 - index) * 10 },iconType,@@ -110,14 +99,14 @@ const createDefaultConfigItem = (iconType: IIconType, index: number, list: unkno});interface IIconGroupListProps {- onClick: (iconType: IIconType) => void;- iconType?: IIconType;+ onClick: (iconType: IIconSetType) => void;+ iconType?: IIconSetType;};const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, ref) => {const { onClick } = props;const localeService = useDependency(LocaleService);- const handleClick = (iconType: IIconType) => {+ const handleClick = (iconType: IIconSetType) => {onClick(iconType);};return (@@ -162,14 +151,14 @@ const IconGroupList = forwardRef<HTMLDivElement, IIconGroupListProps>((props, re);});-const IconItemList = (props: { onClick: (iconType: IIconType, iconId: string) => void; iconType?: IIconType; iconId: string }) => {+const IconItemList = (props: { onClick: (iconType: IIconSetType, iconId: string) => void; iconType?: IIconSetType; iconId: string }) => {const { onClick } = props;const list = useMemo(() => {- const result: { iconType: IIconType; iconId: string; base64: string }[] = [];+ const result: { iconType: IIconSetType; iconId: string; base64: string }[] = [];for (const key in iconMap) {- const list = iconMap[key as IIconType];- const iconType = key as IIconType;+ const iconType = key as IIconSetType;+ const list = iconMap[iconType];list.forEach((base64, index) => {result.push({iconType,@@ -189,7 +178,7 @@ const IconItemList = (props: { onClick: (iconType: IIconType, iconId: string) =><div><divclassName="univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1"- onClick={() => handleClick({ iconType: EMPTY_ICON_TYPE as any, iconId: '', base64: '' })}+ onClick={() => handleClick({ iconType: IIconSetType.empty, iconId: '', base64: '' })}><SlashDoubleIcon className="univer-size-5" /><span className="univer-ml-2">无单元格图标</span>@@ -258,7 +247,7 @@ const IconSetRuleEdit = (props: {const preItem = configList[index - 1];const lessThanText = preItem?.value.type === CFValueType.formula ? localeService.t('sheet.cf.valueType.formula') : preItem?.value.value;- const handleIconClick = (iconType: IIconType, iconId: string) => {+ const handleIconClick = (iconType: IIconSetType, iconId: string) => {const value = { ...item, iconId, iconType } as typeof item;onChange([String(index)], value);};@@ -398,8 +387,8 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {const rule = props.rule?.type === CFRuleType.iconSet ? props.rule : undefined;const localeService = useDependency(LocaleService);const [errorMap, setErrorMap] = useState<Record<string, string>>({});- const [currentIconType, setCurrentIconType] = useState<IIconType>(() => {- const defaultV = Object.keys(iconMap)[0] as IIconType;+ const [currentIconType, setCurrentIconType] = useState<IIconSetType>(() => {+ const defaultV = Object.keys(iconMap)[0] as IIconSetType;if (rule && rule.config.length) {const type = rule.config[0].iconType;const isNotSame = rule.config.some((item) => item.iconType !== type);@@ -505,7 +494,7 @@ export const IconSet = (props: IStyleEditorProps<unknown, IIconSet>) => {setErrorMap(checkResult(configList));}};- const handleClickIconList = (iconType: IIconType) => {+ const handleClickIconList = (iconType: IIconSetType) => {setCurrentIconType(iconType);const list = iconMap[iconType] || [];const config = new Array(list.length).fill('').map((_e, index, list) => createDefaultConfigItem(iconType, index, list));diff --git a/packages/sheets-conditional-formatting/src/facade/f-conditional-formatting-builder.ts b/packages/sheets-conditional-formatting/src/facade/f-conditional-formatting-builder.tsindex 66568a0139..7f6f86bd1f 100644--- a/packages/sheets-conditional-formatting/src/facade/f-conditional-formatting-builder.ts+++ b/packages/sheets-conditional-formatting/src/facade/f-conditional-formatting-builder.ts@@ -35,7 +35,7 @@ import type {IValueConfig,} from '@univerjs/sheets-conditional-formatting';import { BooleanNumber, ColorKit, Tools } from '@univerjs/core';-import { CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFValueType, createCfId, EMPTY_ICON_TYPE, iconMap } from '@univerjs/sheets-conditional-formatting';+import { CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFValueType, createCfId, iconMap, IIconSetType } from '@univerjs/sheets-conditional-formatting';/*** @ignore@@ -82,17 +82,17 @@ class ConditionalFormatRuleBaseBuilder {config: [{operator: CFNumberOperator.greaterThanOrEqual,value: { type: CFValueType.min },- iconType: EMPTY_ICON_TYPE,+ iconType: IIconSetType.empty,iconId: '',}, {operator: CFNumberOperator.greaterThanOrEqual,value: { type: CFValueType.percentile, value: 0.5 },- iconType: EMPTY_ICON_TYPE,+ iconType: IIconSetType.empty,iconId: '',}, {operator: CFNumberOperator.lessThanOrEqual,value: { type: CFValueType.max },- iconType: EMPTY_ICON_TYPE,+ iconType: IIconSetType.empty,iconId: '',}],} as IIconSet;@@ -1221,9 +1221,33 @@ class ConditionalFormatIconSetRuleBuilder extends ConditionalFormatRuleBaseBuild* const builder = fWorksheet.newConditionalFormattingRule()* .setIconSet({* iconConfigs: [- * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },- * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },- * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '0',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 20+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '1',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '2',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * }* ],* isShowValue: true,* })@@ -1265,9 +1289,33 @@ class ConditionalFormatIconSetRuleBuilder extends ConditionalFormatRuleBaseBuild* console.log(builder.getIconMap()); // icons key-value map* const rule = builder.setIconSet({* iconConfigs: [- * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },- * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },- * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '0',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 20+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '1',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '2',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * }* ],* isShowValue: true,* })@@ -1442,9 +1490,33 @@ export class FConditionalFormattingBuilder {* console.log(builder.getIconMap()); // icons key-value map* const rule = builder.setIconSet({* iconConfigs: [- * { iconType: '3Arrows', iconId: '0', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 20 } },- * { iconType: '3Arrows', iconId: '1', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan, value: { type: 'num', value: 10 } },- * { iconType: '3Arrows', iconId: '2', operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual, value: { type: 'num', value: 10 } }+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '0',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 20+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '1',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.greaterThan,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * },+ * {+ * iconType: univerAPI.Enum.ConditionFormatIconSetTypeEnum.threeArrows,+ * iconId: '2',+ * operator: univerAPI.Enum.ConditionFormatNumberOperatorEnum.lessThanOrEqual,+ * value: {+ * type: univerAPI.Enum.ConditionFormatValueTypeEnum.num,+ * value: 10+ * }+ * }* ],* isShowValue: true,* })diff --git a/packages/sheets-conditional-formatting/src/facade/f-enum.ts b/packages/sheets-conditional-formatting/src/facade/f-enum.tsindex 9a5127e150..166128ece3 100644--- a/packages/sheets-conditional-formatting/src/facade/f-enum.ts+++ b/packages/sheets-conditional-formatting/src/facade/f-enum.ts@@ -15,7 +15,7 @@*/import { FEnum } from '@univerjs/core/facade';-import { CFNumberOperator, CFTimePeriodOperator } from '@univerjs/sheets-conditional-formatting';+import { CFNumberOperator, CFTimePeriodOperator, CFValueType, IIconSetType } from '@univerjs/sheets-conditional-formatting';/*** @ignore@@ -30,6 +30,16 @@ export interface IFSheetsConditionalFormattingEnumMixin {* Conditional formatting time period operator*/ConditionFormatTimePeriodOperatorEnum: typeof CFTimePeriodOperator;++ /**+ * Conditional formatting icon set type+ */+ ConditionFormatIconSetTypeEnum: typeof IIconSetType;++ /**+ * Conditional formatting value type+ */+ ConditionFormatValueTypeEnum: typeof CFValueType;}export class FSheetsConditionalFormattingEnumMixin extends FEnum implements IFSheetsConditionalFormattingEnumMixin {@@ -40,6 +50,14 @@ export class FSheetsConditionalFormattingEnumMixin extends FEnum implements IFShoverride get ConditionFormatTimePeriodOperatorEnum(): typeof CFTimePeriodOperator {return CFTimePeriodOperator;}++ override get ConditionFormatIconSetTypeEnum(): typeof IIconSetType {+ return IIconSetType;+ }++ override get ConditionFormatValueTypeEnum(): typeof CFValueType {+ return CFValueType;+ }}FEnum.extend(FSheetsConditionalFormattingEnumMixin);diff --git a/packages/sheets-conditional-formatting/src/models/icon-map.ts b/packages/sheets-conditional-formatting/src/models/icon-map.tsindex d985d5449b..7ea4e8c467 100644--- a/packages/sheets-conditional-formatting/src/models/icon-map.ts+++ b/packages/sheets-conditional-formatting/src/models/icon-map.ts@@ -16,39 +16,86 @@import { ICON_MAP } from '../assets/icon-map';-export type IIconItem = string;+export enum IIconSetType {+ threeArrows = '3Arrows',+ threeArrowsGray = '3ArrowsGray',+ fourArrows = '4Arrows',+ fourArrowsGray = '4ArrowsGray',+ fiveArrows = '5Arrows',+ fiveArrowsGray = '5ArrowsGray',+ threeTriangles = '3Triangles',+ threeTrafficLights1 = '3TrafficLights1',+ threeSigns = '3Signs',+ threeTrafficLights2 = '3TrafficLights2',+ fourRedToBlack = '4RedToBlack',+ fourTrafficLights = '4TrafficLights',+ threeSymbols = '3Symbols',+ threeSymbols2 = '3Symbols2',+ threeFlags = '3Flags',+ fourRating = '4Rating',+ fiveRating = '5Rating',+ fiveQuarters = '5Quarters',+ fiveFelling = '_5Felling',+ fiveBoxes = '5Boxes',+ threeStars = '3Stars',+ empty = 'EMPTY_ICON_TYPE',+}-export const iconGroup: { title: string; group: { name: string; list: string[] }[] }[] = [+export const iconGroup: { title: string; group: { name: IIconSetType; list: string[] }[] }[] = [{title: 'sheet.cf.iconSet.direction',group: [- { name: '3Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['down-red']] },- { name: '3ArrowsGray', list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['down-gray']] },- { name: '4Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']] },- { name: '4ArrowsGray', list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['down-gray']] },- { name: '5Arrows', list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']] },- { name: '5ArrowsGray', list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['down-gray']] },- { name: '3Triangles', list: [ICON_MAP.shape.up, ICON_MAP.shape.cross, ICON_MAP.shape.down] },+ {+ name: IIconSetType.threeArrows,+ list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['down-red']],+ },+ {+ name: IIconSetType.threeArrowsGray,+ list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['down-gray']],+ },+ {+ name: IIconSetType.fourArrows,+ list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']],+ },+ {+ name: IIconSetType.fourArrowsGray,+ list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['down-gray']],+ },+ {+ name: IIconSetType.fiveArrows,+ list: [ICON_MAP.arrow['up-green'], ICON_MAP.arrow['rightAndUp-gold'], ICON_MAP.arrow['right-gold'], ICON_MAP.arrow['rightAndDown-gold'], ICON_MAP.arrow['down-red']],+ },+ {+ name: IIconSetType.fiveArrowsGray,+ list: [ICON_MAP.arrow['up-gray'], ICON_MAP.arrow['rightAndUp-gray'], ICON_MAP.arrow['right-gray'], ICON_MAP.arrow['rightAndDown-gray'], ICON_MAP.arrow['down-gray']],+ },+ {+ name: IIconSetType.threeTriangles,+ list: [ICON_MAP.shape.up, ICON_MAP.shape.cross, ICON_MAP.shape.down],+ },],},{title: 'sheet.cf.iconSet.shape',group: [{- name: '3TrafficLights1',+ name: IIconSetType.threeTrafficLights1,list: [ICON_MAP.shape['roundness-greed'], ICON_MAP.shape['roundness-gold'], ICON_MAP.shape['roundness-red']],},{- name: '3Signs',+ name: IIconSetType.threeSigns,list: [ICON_MAP.shape['roundness-greed'], ICON_MAP.shape['triangle-gold'], ICON_MAP.shape['rhomboid-red']],},- { name: '3TrafficLights2', list: [ICON_MAP.shape['indicate-greed'], ICON_MAP.shape['indicate-gold'], ICON_MAP.shape['indicate-red']] },{- name: '4RedToBlack',+ name: IIconSetType.threeTrafficLights2,+ list: [ICON_MAP.shape['indicate-greed'], ICON_MAP.shape['indicate-gold'], ICON_MAP.shape['indicate-red']],+ },+ {+ name: IIconSetType.fourRedToBlack,list: [ICON_MAP.shape['roundness-red'], ICON_MAP.shape['roundness-pink'], ICON_MAP.shape['roundness-gray'], ICON_MAP.shape['roundness-black']],},{- name: '4TrafficLights',+ name: IIconSetType.fourTrafficLights,list: [ICON_MAP.shape['roundness-greed'], ICON_MAP.shape['roundness-gold'], ICON_MAP.shape['roundness-red'], ICON_MAP.shape['roundness-black']],},],@@ -57,15 +104,15 @@ export const iconGroup: { title: string; group: { name: string; list: string[] }title: 'sheet.cf.iconSet.mark',group: [{- name: '3Symbols',+ name: IIconSetType.threeSymbols,list: [ICON_MAP.feedback.correct, ICON_MAP.feedback.warn, ICON_MAP.feedback.mistake],},{- name: '3Symbols2',+ name: IIconSetType.threeSymbols2,list: [ICON_MAP.feedback2.correct2, ICON_MAP.feedback2.warn2, ICON_MAP.feedback2.mistake2],},{- name: '3Flags',+ name: IIconSetType.threeFlags,list: [ICON_MAP.flag['flag-green'], ICON_MAP.flag['flag-gold'], ICON_MAP.flag['flag-red']],},@@ -75,27 +122,27 @@ export const iconGroup: { title: string; group: { name: string; list: string[] }title: 'sheet.cf.iconSet.rank',group: [{- name: '4Rating',+ name: IIconSetType.fourRating,list: [ICON_MAP.signal.signal25, ICON_MAP.signal.signal50, ICON_MAP.signal.signal75, ICON_MAP.signal.signal100],},{- name: '5Rating',+ name: IIconSetType.fiveRating,list: [ICON_MAP.signal.signal0, ICON_MAP.signal.signal25, ICON_MAP.signal.signal50, ICON_MAP.signal.signal75, ICON_MAP.signal.signal100],},{- name: '5Quarters',+ name: IIconSetType.fiveQuarters,list: [ICON_MAP.progress.progress100, ICON_MAP.progress.progress75, ICON_MAP.progress.progress50, ICON_MAP.progress.progress25, ICON_MAP.progress.progress0],},{- name: '_5Felling',+ name: IIconSetType.fiveFelling,list: [ICON_MAP.feeling.guffaw, ICON_MAP.feeling.smile, ICON_MAP.feeling.noninductive, ICON_MAP.feeling.dissatisfied, ICON_MAP.feeling.impatient],},{- name: '5Boxes',+ name: IIconSetType.fiveBoxes,list: [ICON_MAP.cell['cell-100'], ICON_MAP.cell['cell-75'], ICON_MAP.cell['cell-50'], ICON_MAP.cell['cell-25'], ICON_MAP.cell['cell-0']],},{- name: '3Stars',+ name: IIconSetType.threeStars,list: [ICON_MAP.star.starFull, ICON_MAP.star.starIncomplete, ICON_MAP.star.starEmpty],},],@@ -108,11 +155,9 @@ export const iconMap = iconGroup.reduce((result, cur) => {result[v.name] = v.list;}return result;-}, {} as Record<string, string[]>);-export type IIconType = keyof typeof iconMap;+}, {} as Record<IIconSetType, string[]>);for (const key in iconMap) {- const v = iconMap[key as IIconType];+ const v = iconMap[key as IIconSetType];Object.freeze(v);}-export const EMPTY_ICON_TYPE = 'EMPTY_ICON_TYPE';diff --git a/packages/sheets-conditional-formatting/src/models/type.ts b/packages/sheets-conditional-formatting/src/models/type.tsindex 56ecf3d58c..39f53194de 100644--- a/packages/sheets-conditional-formatting/src/models/type.ts+++ b/packages/sheets-conditional-formatting/src/models/type.ts@@ -16,7 +16,7 @@import type { IRange, IStyleBase } from '@univerjs/core';import type { CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType } from '../base/const';-import type { IIconType } from './icon-map';+import type { IIconSetType } from './icon-map';export interface IBaseCfRule {type: string;@@ -96,7 +96,7 @@ export interface IColorScale extends IBaseCfRule {export interface IIconSet extends IBaseCfRule {type: CFRuleType.iconSet;isShowValue: boolean;- config: { operator: CFNumberOperator; value: IValueConfig; iconType: IIconType; iconId: string }[];+ config: { operator: CFNumberOperator; value: IValueConfig; iconType: IIconSetType; iconId: string }[];}export type IConditionalFormattingRuleConfig = IColorScale | IDataBar | IUniqueValuesHighlightCell |diff --git a/packages/sheets-conditional-formatting/src/render/icon.render.ts b/packages/sheets-conditional-formatting/src/render/icon.render.tsindex aa0e27a148..44c5b2e2ca 100644--- a/packages/sheets-conditional-formatting/src/render/icon.render.ts+++ b/packages/sheets-conditional-formatting/src/render/icon.render.ts@@ -16,11 +16,10 @@import type { IRange, IScale } from '@univerjs/core';import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';-import type { IIconType } from '../models/icon-map';import type { IIconSetCellData } from './type';import { Range } from '@univerjs/core';import { SheetExtension, SpreadsheetExtensionRegistry } from '@univerjs/engine-render';-import { EMPTY_ICON_TYPE, iconMap } from '../models/icon-map';+import { iconMap, IIconSetType } from '../models/icon-map';export const IconUKey = 'sheet-conditional-rule-icon';const EXTENSION_Z_INDEX = 35;@@ -78,7 +77,7 @@ export class ConditionalFormattingIcon extends SheetExtension {}const { iconType, iconId } = cellData.iconSet;- if (iconType === EMPTY_ICON_TYPE) {+ if (iconType === IIconSetType.empty) {return;}@@ -116,9 +115,9 @@ export class ConditionalFormattingIcon extends SheetExtension {private _init() {for (const type in iconMap) {- const list = iconMap[type as IIconType];+ const list = iconMap[type as IIconSetType];list.forEach((base64, index) => {- const key = this._createKey(type as IIconType, String(index));+ const key = this._createKey(type as IIconSetType, String(index));const image = new Image();image.onload = () => {this._imageMap.set(key, image);@@ -128,7 +127,7 @@ export class ConditionalFormattingIcon extends SheetExtension {}}- private _createKey(iconType: IIconType, iconIndex: string) {+ private _createKey(iconType: IIconSetType, iconIndex: string) {return `${iconType}_${iconIndex}`;}}diff --git a/packages/sheets-conditional-formatting/src/render/type.ts b/packages/sheets-conditional-formatting/src/render/type.tsindex 5f1258321c..cc61dcd1ed 100644--- a/packages/sheets-conditional-formatting/src/render/type.ts+++ b/packages/sheets-conditional-formatting/src/render/type.ts@@ -15,7 +15,7 @@*/import type { ICellData } from '@univerjs/core';-import type { IIconType } from '../models/icon-map';+import type { IIconSetType } from '../models/icon-map';export interface IDataBarRenderParams {color: string;@@ -31,7 +31,7 @@ export interface IDataBarCellData extends ICellData {export interface IIconSetRenderParams {iconId: string;- iconType: IIconType;+ iconType: IIconSetType;isShowValue: boolean;}