@univerjs/sheets-conditional-formatting-ui 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.
package/lib/cjs/index.js CHANGED
@@ -38,34 +38,34 @@
38
38
  `,"univer-box-border univer-h-7"),children:[I.jsx(Q.Select,{style:{flexShrink:0},options:y,value:_,onChange:E=>{w(E);const N=u.createDefaultValueByValueType(E,90);f(N),U({minType:p,medianType:v,maxType:E,minValue:b,medianValue:h,maxValue:N,minColor:C,medianColor:m,maxColor:g})}}),I.jsx(Wt,{id:"max",className:`
39
39
  ${z.mLXxs}
40
40
  `,value:s,type:_,onChange:E=>{f(E),U({minType:p,medianType:v,maxType:_,minValue:b,medianValue:h,maxValue:E,minColor:C,medianColor:m,maxColor:g})}}),I.jsx(Ne,{className:z.mLXxs,color:g,onChange:E=>{F(E),U({minType:p,medianType:v,maxType:_,minValue:b,medianValue:h,maxValue:s,minColor:C,medianColor:m,maxColor:E})}})]})]})},Le=(t,e)=>({label:e.t(`sheet.cf.valueType.${t}`),value:t}),Hn=t=>{var R;const{onChange:e,className:r,value:n,type:o,id:i,disabled:c=!1}=t,y=ee.useDependency(x.IUniverInstanceService),p=y.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getUnitId(),S=(R=y.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:R.getSheetId(),v=j.useRef({}),[T,_]=j.useState(!1);ee.useSidebarClick(h=>{var s;const a=(s=v.current)==null?void 0:s.handleOutClick;a&&a(h,()=>_(!1))});const w=j.useRef(n),b=j.useMemo(()=>[u.CFValueType.percentile,u.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===u.CFValueType.formula){const h=String(w.current).startsWith("=")?String(w.current)||"":"=";return I.jsx("div",{style:{width:"100%",marginLeft:12},children:I.jsx(dt.FormulaEditor,{initValue:h,unitId:p,subUnitId:S,isFocus:T,onChange:(a="")=>{e(a||"")},onFocus:()=>_(!0),actions:v.current})})}return I.jsx(Q.InputNumber,{className:r,value:Number(n)||0,disabled:c,onChange:h=>{e(h||0)},...b})},Fi=t=>{var L;const{interceptorManager:e}=t,r=ee.useDependency(x.LocaleService),n=((L=t.rule)==null?void 0:L.type)===u.CFRuleType.dataBar?t.rule:void 0,[o,i]=j.useState(()=>{var N;const E="0";return n?(N=n.config)!=null&&N.isGradient?"1":"0":E}),[c,y]=j.useState(()=>{var E;return n&&((E=n.config)==null?void 0:E.positiveColor)||u.defaultDataBarPositiveColor}),[p,S]=j.useState(()=>{var E;return n&&((E=n.config)==null?void 0:E.nativeColor)||u.defaultDataBarNativeColor}),v=[Le(u.CFValueType.num,r),Le(u.CFValueType.percent,r),Le(u.CFValueType.percentile,r),Le(u.CFValueType.formula,r)],T=[Le(u.CFValueType.min,r),...v],_=[Le(u.CFValueType.max,r),...v],[w,b]=j.useState(()=>{var N;const E=T[0].value;return n&&((N=n.config)==null?void 0:N.min.type)||E}),[R,h]=j.useState(()=>{var N;const E=_[0].value;return n&&((N=n.config)==null?void 0:N.max.type)||E}),[a,s]=j.useState(()=>{var W;if(!n)return 0;const N=((W=n.config)==null?void 0:W.min)||{};return N.type===u.CFValueType.formula?N.value||"=":N.value||0}),[f,C]=j.useState(()=>{var W;if(!n)return 100;const N=((W=n.config)==null?void 0:W.max)||{};return N.type===u.CFValueType.formula?N.value||"=":N.value===void 0?100:N.value}),[l,m]=j.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),d=E=>({config:{min:{type:E.minValueType,value:E.minValue},max:{type:E.maxValueType,value:E.maxValue},isGradient:E.isGradient==="1",positiveColor:E.positiveColor||u.defaultDataBarPositiveColor,nativeColor:E.nativeColor||u.defaultDataBarNativeColor},type:u.CFRuleType.dataBar,isShowValue:E.isShowValue});j.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return d({isGradient:o,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}}),[o,a,w,f,R,c,p,e,l]);const g=E=>{t.onChange(d(E))},F=E=>{y(E),g({isGradient:o,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:E,nativeColor:p,isShowValue:l})},D=E=>{S(E),g({isGradient:o,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:E,isShowValue:l})},U=E=>v.map(N=>N.value).includes(E);return I.jsxs("div",{children:[I.jsx("div",{className:z.title,children:r.t("sheet.cf.panel.styleRule")}),I.jsx("div",{className:`
41
- ${H.cfPreviewWrap}
42
- `,children:I.jsx(qe,{rule:d({isGradient:o,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})})}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.panel.fillType")}),I.jsxs("div",{className:`
43
- ${z.mTSm}
44
- ${z.mLXxs}
45
- ${z.labelContainer}
46
- `,children:[I.jsxs(Q.RadioGroup,{value:o,onChange:E=>{i(E),g({isGradient:E,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})},children:[I.jsx(Q.Radio,{value:"0",children:I.jsx("span",{className:H.text,children:r.t("sheet.cf.panel.pureColor")})}),I.jsx(Q.Radio,{value:"1",children:I.jsx("span",{className:H.text,children:r.t("sheet.cf.panel.gradient")})})]}),I.jsxs("div",{className:`
47
- ${H.utilItem}
48
- ${z.mLXl}
49
- `,children:[I.jsx(Q.Checkbox,{checked:!l,onChange:E=>{m(!E),g({isGradient:E,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:!E})}}),r.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.panel.colorSet")}),I.jsxs("div",{className:`
50
- ${z.labelContainer}
51
- ${z.mTSm}
52
- ${z.mLXxs}
53
- `,children:[I.jsxs("div",{className:`
41
+ ${H.cfPreviewWrap}
42
+ `,children:I.jsx(qe,{rule:d({isGradient:o,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})})}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.panel.fillType")}),I.jsxs("div",{className:`
43
+ ${z.mTSm}
44
+ ${z.mLXxs}
54
45
  ${z.labelContainer}
55
- `,children:[I.jsx("div",{className:`
56
- ${H.text}
57
- `,children:r.t("sheet.cf.panel.native")}),I.jsx(Ne,{color:p,onChange:D})]}),I.jsxs("div",{className:`
46
+ `,children:[I.jsxs(Q.RadioGroup,{value:o,onChange:E=>{i(E),g({isGradient:E,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})},children:[I.jsx(Q.Radio,{value:"0",children:I.jsx("span",{className:H.text,children:r.t("sheet.cf.panel.pureColor")})}),I.jsx(Q.Radio,{value:"1",children:I.jsx("span",{className:H.text,children:r.t("sheet.cf.panel.gradient")})})]}),I.jsxs("div",{className:`
47
+ ${H.utilItem}
48
+ ${z.mLXl}
49
+ `,children:[I.jsx(Q.Checkbox,{checked:!l,onChange:E=>{m(!E),g({isGradient:E,minValue:a,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:!E})}}),r.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.panel.colorSet")}),I.jsxs("div",{className:`
58
50
  ${z.labelContainer}
59
- ${z.mLSm}
60
- `,children:[I.jsx("div",{className:`
61
- ${H.text}
62
- `,children:r.t("sheet.cf.panel.positive")}),I.jsx(Ne,{color:c,onChange:F})]})]})]}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.valueType.min")}),I.jsxs("div",{className:`
63
- ${z.mTSm}
64
- ${z.labelContainer}
65
- `,children:[I.jsx(Q.Select,{style:{width:"50%",flexShrink:0},options:T,value:w,onChange:E=>{b(E);const N=u.createDefaultValueByValueType(E,10);s(N),g({isGradient:o,minValue:N,minValueType:E,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}}),I.jsx(Hn,{disabled:!U(w),id:"min",type:w,className:z.mLSm,value:a,onChange:E=>{s(E||0),g({isGradient:o,minValue:E||0,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}})]}),I.jsx("div",{className:z.label,children:r.t("sheet.cf.valueType.max")}),I.jsxs("div",{className:`
66
- ${z.mTSm}
67
- ${z.labelContainer}
68
- `,children:[I.jsx(Q.Select,{style:{width:"50%",flexShrink:0},options:_,value:R,onChange:E=>{h(E);const N=u.createDefaultValueByValueType(E,90);C(N),g({isGradient:o,minValue:a,minValueType:w,maxValue:N,maxValueType:E,positiveColor:c,nativeColor:p,isShowValue:l})}}),I.jsx(Hn,{disabled:!U(R),id:"max",type:R,className:z.mLSm,value:f,onChange:E=>{C(E||0),g({isGradient:o,minValue:a,minValueType:w,maxValue:E||0,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}})]})]})]})},Di="univer-cf-style-edit",Mi="univer-button-item",Ni="univer-isActive",xe={cfStyleEdit:Di,buttonItem:Mi,isActive:Ni},bt=t=>[x.BooleanNumber.FALSE,void 0].includes(t)?x.BooleanNumber.TRUE:x.BooleanNumber.FALSE,St=t=>t!==x.BooleanNumber.FALSE,fn=t=>{const{style:e,onChange:r,className:n}=t,o=ee.useDependency(ee.ComponentManager),[i,c]=j.useState(()=>{if(e!=null&&e.bl)return e.bl}),[y,p]=j.useState(()=>{if(e!=null&&e.it)return e.it}),[S,v]=j.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[T,_]=j.useState(()=>{if(e!=null&&e.st)return e.st.s}),[w,b]=j.useState(()=>{var m;const l="#2f56ef";return(m=e==null?void 0:e.cl)!=null&&m.rgb?e.cl.rgb:l}),[R,h]=j.useState(()=>{var m;const l="#e8ecfc";return(m=e==null?void 0:e.bg)!=null&&m.rgb?e.bg.rgb:l}),a=o.get("BoldSingle"),s=o.get("ItalicSingle"),f=o.get("UnderlineSingle"),C=o.get("StrikethroughSingle");return j.useEffect(()=>{const l={bl:i,it:y};w!==void 0&&(l.cl={rgb:w}),R!==void 0&&(l.bg={rgb:R}),T!==void 0&&(l.st={s:T}),S!==void 0&&(l.ul={s:S}),r(u.removeUndefinedAttr(l))},[i,y,S,T,w,R]),I.jsxs("div",{className:Q.clsx(xe.cfStyleEdit,n),children:[a&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(i||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>c(bt(i)),children:I.jsx(a,{})}),s&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(y||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>p(bt(y)),children:I.jsx(s,{})}),f&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(S||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>v(bt(S)),children:I.jsx(f,{})}),C&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(T||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>_(bt(T)),children:I.jsx(C,{})}),I.jsx(Ne,{color:w,onChange:b,iconId:"FontColor"}),I.jsx(Ne,{color:R,onChange:h,iconId:"PaintBucket"})]})},ji=t=>{var C;const{onChange:e,interceptorManager:r}=t,n=ee.useDependency(x.LocaleService),i=ee.useDependency(x.IUniverInstanceService).getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET),c=i.getActiveSheet(),y=((C=t.rule)==null?void 0:C.type)===u.CFRuleType.highlightCell?t.rule:void 0,p=j.useRef(null),[S,v]=j.useState(!1),T=j.useRef({}),[_,w]=j.useState({}),[b,R]=j.useState(()=>(y==null?void 0:y.subType)===u.CFSubRuleType.formula?y.value:"="),[h,a]=j.useState(void 0),s=l=>({style:l.style,value:b,type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.formula});j.useEffect(()=>r.intercept(r.getInterceptPoints().submit,{handler(){return s({style:_})}}),[_,b,r]),j.useEffect(()=>r.intercept(r.getInterceptPoints().beforeSubmit,{handler:(m,d,g)=>h||b.length===1||!b.startsWith("=")?(a(n.t("sheet.cf.errorMessage.formulaError")),!1):g(m)}),[h,b]);const f=l=>{e(s(l))};return ee.useSidebarClick(l=>{var d;const m=(d=T.current)==null?void 0:d.handleOutClick;m&&m(l,()=>v(!1))}),I.jsxs("div",{ref:p,children:[I.jsx("div",{className:`
51
+ ${z.mTSm}
52
+ ${z.mLXxs}
53
+ `,children:[I.jsxs("div",{className:`
54
+ ${z.labelContainer}
55
+ `,children:[I.jsx("div",{className:`
56
+ ${H.text}
57
+ `,children:r.t("sheet.cf.panel.native")}),I.jsx(Ne,{color:p,onChange:D})]}),I.jsxs("div",{className:`
58
+ ${z.labelContainer}
59
+ ${z.mLSm}
60
+ `,children:[I.jsx("div",{className:`
61
+ ${H.text}
62
+ `,children:r.t("sheet.cf.panel.positive")}),I.jsx(Ne,{color:c,onChange:F})]})]})]}),I.jsxs("div",{children:[I.jsx("div",{className:z.label,children:r.t("sheet.cf.valueType.min")}),I.jsxs("div",{className:`
63
+ ${z.mTSm}
64
+ ${z.labelContainer}
65
+ `,children:[I.jsx(Q.Select,{style:{width:"50%",flexShrink:0},options:T,value:w,onChange:E=>{b(E);const N=u.createDefaultValueByValueType(E,10);s(N),g({isGradient:o,minValue:N,minValueType:E,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}}),I.jsx(Hn,{disabled:!U(w),id:"min",type:w,className:z.mLSm,value:a,onChange:E=>{s(E||0),g({isGradient:o,minValue:E||0,minValueType:w,maxValue:f,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}})]}),I.jsx("div",{className:z.label,children:r.t("sheet.cf.valueType.max")}),I.jsxs("div",{className:`
66
+ ${z.mTSm}
67
+ ${z.labelContainer}
68
+ `,children:[I.jsx(Q.Select,{style:{width:"50%",flexShrink:0},options:_,value:R,onChange:E=>{h(E);const N=u.createDefaultValueByValueType(E,90);C(N),g({isGradient:o,minValue:a,minValueType:w,maxValue:N,maxValueType:E,positiveColor:c,nativeColor:p,isShowValue:l})}}),I.jsx(Hn,{disabled:!U(R),id:"max",type:R,className:z.mLSm,value:f,onChange:E=>{C(E||0),g({isGradient:o,minValue:a,minValueType:w,maxValue:E||0,maxValueType:R,positiveColor:c,nativeColor:p,isShowValue:l})}})]})]})]})},Di="univer-cf-style-edit",Mi="univer-button-item",Ni="univer-isActive",xe={cfStyleEdit:Di,buttonItem:Mi,isActive:Ni},bt=t=>[x.BooleanNumber.FALSE,void 0].includes(t)?x.BooleanNumber.TRUE:x.BooleanNumber.FALSE,St=t=>t!==x.BooleanNumber.FALSE,fn=t=>{const{style:e,onChange:r,className:n}=t,o=ee.useDependency(ee.ComponentManager),[i,c]=j.useState(()=>{if(e!=null&&e.bl)return e.bl}),[y,p]=j.useState(()=>{if(e!=null&&e.it)return e.it}),[S,v]=j.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[T,_]=j.useState(()=>{if(e!=null&&e.st)return e.st.s}),[w,b]=j.useState(()=>{var m;const l="#2f56ef";return(m=e==null?void 0:e.cl)!=null&&m.rgb?e.cl.rgb:l}),[R,h]=j.useState(()=>{var m;const l="#e8ecfc";return(m=e==null?void 0:e.bg)!=null&&m.rgb?e.bg.rgb:l}),a=o.get("BoldSingle"),s=o.get("ItalicSingle"),f=o.get("UnderlineSingle"),C=o.get("StrikethroughSingle");return j.useEffect(()=>{const l={bl:i,it:y};w!==void 0&&(l.cl={rgb:w}),R!==void 0&&(l.bg={rgb:R}),T!==void 0&&(l.st={s:T}),S!==void 0&&(l.ul={s:S}),r(u.removeUndefinedAttr(l))},[i,y,S,T,w,R]),I.jsxs("div",{className:Q.clsx(xe.cfStyleEdit,n),children:[a&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(i||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>c(bt(i)),children:I.jsx(a,{})}),s&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(y||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>p(bt(y)),children:I.jsx(s,{})}),f&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(S||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>v(bt(S)),children:I.jsx(f,{})}),C&&I.jsx("div",{className:Q.clsx({[xe.isActive]:St(T||x.BooleanNumber.FALSE)},xe.buttonItem),onClick:()=>_(bt(T)),children:I.jsx(C,{})}),I.jsx(Ne,{color:w,onChange:b,iconId:"FontColor"}),I.jsx(Ne,{color:R,onChange:h,iconId:"PaintBucket"})]})},ji=t=>{var C;const{onChange:e,interceptorManager:r}=t,n=ee.useDependency(x.LocaleService),i=ee.useDependency(x.IUniverInstanceService).getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET),c=i.getActiveSheet(),y=((C=t.rule)==null?void 0:C.type)===u.CFRuleType.highlightCell?t.rule:void 0,p=j.useRef(null),[S,v]=j.useState(!1),T=j.useRef({}),[_,w]=j.useState({}),[b,R]=j.useState(()=>(y==null?void 0:y.subType)===u.CFSubRuleType.formula?y.value:"="),[h,a]=j.useState(void 0),s=l=>({style:l.style,value:b,type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.formula});j.useEffect(()=>r.intercept(r.getInterceptPoints().submit,{handler(){return s({style:_})}}),[_,b,r]),j.useEffect(()=>r.intercept(r.getInterceptPoints().beforeSubmit,{handler:(m,d,g)=>h||b.length===1||!b.startsWith("=")?(a(n.t("sheet.cf.errorMessage.formulaError")),!1):g(m)}),[h,b]);const f=l=>{e(s(l))};return ee.useSidebarClick(l=>{var d;const m=(d=T.current)==null?void 0:d.handleOutClick;m&&m(l,()=>v(!1))}),I.jsxs("div",{ref:p,children:[I.jsx("div",{className:`
69
69
  ${z.title}
70
70
  ${z.mTBase}
71
71
  `,children:n.t("sheet.cf.panel.styleRule")}),I.jsx("div",{className:`
@@ -75,26 +75,26 @@
75
75
  `,children:I.jsx(qe,{rule:s({style:_})})}),I.jsx(fn,{style:y==null?void 0:y.style,className:`
76
76
  ${z.mTSm}
77
77
  `,onChange:l=>{w(l),f({style:l})}})]})},Rt=t=>I.jsxs("div",{style:{position:"relative"},children:[I.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:t.errorText}),t.children]}),ue=(t,e)=>({label:e.t(`sheet.cf.operator.${t}`),value:t}),Li=t=>{const{type:e,operator:r,onChange:n,value:o,interceptorManager:i}=t,c=ee.useDependency(x.LocaleService),[y,p]=j.useState(()=>typeof o=="number"?o:0),[S,v]=j.useState(""),[T,_]=j.useState(()=>typeof o=="string"?o:""),[w,b]=j.useState(""),[R,h]=j.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[a,s]=j.useState(""),[f,C]=j.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[l,m]=j.useState("");switch(j.useEffect(()=>{switch(e){case u.CFSubRuleType.text:{[u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(r)&&n(T);break}case u.CFSubRuleType.number:{[u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(r)&&n(y),[u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(r)&&n([R,f]);break}}},[e]),j.useEffect(()=>{const d=i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(g,F,D)=>{switch(e){case u.CFSubRuleType.text:if([u.CFTextOperator.beginsWith,u.CFTextOperator.containsText,u.CFTextOperator.endsWith,u.CFTextOperator.notEqual,u.CFTextOperator.notContainsText,u.CFTextOperator.equal].includes(r))return T?D(g):(b(c.t("sheet.cf.errorMessage.notBlank")),!1)}return D(g)}});return()=>{d()}},[e,y,T,r]),e){case u.CFSubRuleType.text:{if([u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(r)){const d=g=>{_(g),n(g)};return I.jsx("div",{className:`
78
- ${z.mTSm}
79
- `,children:I.jsx(Rt,{errorText:w,children:I.jsx(Q.Input,{className:H.width100,value:T,onChange:g=>{b(""),d(g)}})})})}break}case u.CFSubRuleType.number:{if([u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(r)){const d=g=>{p(g||0),n(g||0),v("")};return I.jsx("div",{className:`
80
- ${z.mTSm}
81
- `,children:I.jsx(Rt,{errorText:S,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:H.width100,value:y,onChange:d})})})}if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(r)){const d=F=>{h(F||0),n([F||0,f]),s("")},g=F=>{C(F||0),n([R,F||0]),m("")};return I.jsxs("div",{className:`
82
- ${z.mTSm}
83
- ${z.labelContainer}
84
- `,children:[I.jsx(Rt,{errorText:a,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:R,onChange:d})}),I.jsx(Rt,{errorText:l,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:`
78
+ ${z.mTSm}
79
+ `,children:I.jsx(Rt,{errorText:w,children:I.jsx(Q.Input,{className:H.width100,value:T,onChange:g=>{b(""),d(g)}})})})}break}case u.CFSubRuleType.number:{if([u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(r)){const d=g=>{p(g||0),n(g||0),v("")};return I.jsx("div",{className:`
80
+ ${z.mTSm}
81
+ `,children:I.jsx(Rt,{errorText:S,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:H.width100,value:y,onChange:d})})})}if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(r)){const d=F=>{h(F||0),n([F||0,f]),s("")},g=F=>{C(F||0),n([R,F||0]),m("")};return I.jsxs("div",{className:`
82
+ ${z.mTSm}
83
+ ${z.labelContainer}
84
+ `,children:[I.jsx(Rt,{errorText:a,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:R,onChange:d})}),I.jsx(Rt,{errorText:l,children:I.jsx(Q.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,className:`
85
85
  ${z.mLSm}
86
86
  `,value:f,onChange:g})})]})}}}return null},Bn=(t,e)=>{switch(t){case u.CFSubRuleType.text:return[ue(u.CFTextOperator.containsText,e),ue(u.CFTextOperator.notContainsText,e),ue(u.CFTextOperator.beginsWith,e),ue(u.CFTextOperator.endsWith,e),ue(u.CFTextOperator.equal,e),ue(u.CFTextOperator.notEqual,e),ue(u.CFTextOperator.containsBlanks,e),ue(u.CFTextOperator.notContainsBlanks,e),ue(u.CFTextOperator.containsErrors,e),ue(u.CFTextOperator.notContainsErrors,e)];case u.CFSubRuleType.number:return[ue(u.CFNumberOperator.between,e),ue(u.CFNumberOperator.notBetween,e),ue(u.CFNumberOperator.equal,e),ue(u.CFNumberOperator.notEqual,e),ue(u.CFNumberOperator.greaterThan,e),ue(u.CFNumberOperator.greaterThanOrEqual,e),ue(u.CFNumberOperator.lessThan,e),ue(u.CFNumberOperator.lessThanOrEqual,e)];case u.CFSubRuleType.timePeriod:return[ue(u.CFTimePeriodOperator.yesterday,e),ue(u.CFTimePeriodOperator.today,e),ue(u.CFTimePeriodOperator.tomorrow,e),ue(u.CFTimePeriodOperator.last7Days,e),ue(u.CFTimePeriodOperator.lastWeek,e),ue(u.CFTimePeriodOperator.thisWeek,e),ue(u.CFTimePeriodOperator.nextWeek,e),ue(u.CFTimePeriodOperator.lastMonth,e),ue(u.CFTimePeriodOperator.thisMonth,e),ue(u.CFTimePeriodOperator.nextMonth,e)]}},Gn=t=>{var C;const{interceptorManager:e,onChange:r}=t,n=ee.useDependency(x.LocaleService),o=((C=t.rule)==null?void 0:C.type)===u.CFRuleType.highlightCell?t.rule:void 0,[i,c]=j.useState(()=>{const l=u.CFSubRuleType.text;return o&&o.subType||l}),y=[{value:u.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:u.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:u.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:u.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:u.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],p=j.useMemo(()=>Bn(i,n),[i]),[S,v]=j.useState(()=>{const l=p?p[0].value:void 0;return o&&o.operator||l}),[T,_]=j.useState(()=>{var d;const l="";return o?(d=o.value)!=null?d:u.createDefaultValue(o.subType,o.operator):l}),[w,b]=j.useState({}),R=j.useMemo(()=>l=>{var m,d,g,F,D,U,L,E,N,W,B,Z,se,re,q;switch(l.subType||i){case u.CFSubRuleType.text:{if([u.CFTextOperator.beginsWith,u.CFTextOperator.endsWith,u.CFTextOperator.containsText,u.CFTextOperator.notContainsText,u.CFTextOperator.equal,u.CFTextOperator.notEqual].includes(S))return{type:u.CFRuleType.highlightCell,subType:(m=l.subType)!=null?m:i,operator:(d=l.operator)!=null?d:S,style:(g=l.style)!=null?g:w,value:(F=l.value)!=null?F:T};break}case u.CFSubRuleType.number:{if([u.CFNumberOperator.equal,u.CFNumberOperator.notEqual,u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual,u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(S))return{type:u.CFRuleType.highlightCell,subType:(D=l.subType)!=null?D:i,operator:(U=l.operator)!=null?U:S,style:(L=l.style)!=null?L:w,value:(E=l.value)!=null?E:T};if([u.CFNumberOperator.between,u.CFNumberOperator.notBetween].includes(S))return{type:u.CFRuleType.highlightCell,subType:(N=l.subType)!=null?N:i,operator:(W=l.operator)!=null?W:S,style:(B=l.style)!=null?B:w,value:(Z=l.value)!=null?Z:T};break}}return{type:u.CFRuleType.highlightCell,subType:(se=l.subType)!=null?se:i,operator:(re=l.operator)!=null?re:S,style:(q=l.style)!=null?q:w}},[i,S,T,w]);j.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return R({})}}),[R,e]),j.useEffect(()=>{y.some(l=>l.value===i)||c(y[0].value)},[y]);const h=l=>{const m=l,d=Bn(m,n),g=d&&d[0].value;c(m),v(g),g&&_(u.createDefaultValue(m,g)),r(R({subType:m,operator:g}))},a=l=>{const m=l;v(m),r(R({operator:m}))},s=l=>{_(l),r(R({value:l}))},f=j.useMemo(()=>`${i}_${S}_${Math.random()}`,[i,S]);return I.jsxs("div",{children:[I.jsx("div",{className:`
87
- ${z.title}
88
- ${z.mTBase}
89
- `,children:n.t("sheet.cf.panel.styleRule")}),I.jsx(Q.Select,{className:`
87
+ ${z.title}
88
+ ${z.mTBase}
89
+ `,children:n.t("sheet.cf.panel.styleRule")}),I.jsx(Q.Select,{className:`
90
90
  ${z.mTSm}
91
91
  ${H.width100}
92
92
  `,onChange:h,value:i,options:y}),(p==null?void 0:p.length)&&I.jsx(Q.Select,{className:`
93
93
  ${z.mTSm}
94
94
  ${H.width100}
95
95
  `,onChange:a,value:S||"",options:p}),I.jsx(Li,{value:T,interceptorManager:e,type:i,operator:S,rule:o,onChange:s},f),I.jsx("div",{className:`
96
- ${H.cfPreviewWrap}
97
- `,children:I.jsx(qe,{rule:R({})})}),I.jsx(fn,{style:o==null?void 0:o.style,className:`
96
+ ${H.cfPreviewWrap}
97
+ `,children:I.jsx(qe,{rule:R({})})}),I.jsx(fn,{style:o==null?void 0:o.style,className:`
98
98
  ${z.mLXxs}
99
99
  `,onChange:l=>{b(l),r(R({style:l}))}})]})},br=(t,e)=>(u.iconMap[t]||[])[Number(e)]||"",Ui=t=>{var p;const e=ee.useDependency(x.IUniverInstanceService),r=e.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=(p=e.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:p.getSheetId(),o=j.useMemo(()=>t.error?H.errorInput:"",[t.error]),i=j.useRef({}),[c,y]=j.useState(!1);return ee.useSidebarClick(S=>{var T;const v=(T=i.current)==null?void 0:T.handleOutClick;v&&v(S,()=>y(!1))}),I.jsx("div",{className:H.positionRelative,children:t.type!==u.CFValueType.formula?I.jsxs(I.Fragment,{children:[I.jsx(Q.InputNumber,{className:o,value:Number(t.value)||0,onChange:S=>t.onChange(S!=null?S:0)}),t.error&&I.jsx("div",{className:H.errorText,children:t.error})]}):I.jsx("div",{style:{width:"100%"},children:I.jsx(dt.FormulaEditor,{initValue:String(t.value),unitId:r,subUnitId:n,isFocus:c,onChange:(S="")=>{const v=S||"";t.onChange(v)},onFocus:()=>y(!0),actions:i.current})})})},Xn=(t,e,r)=>({operator:u.CFNumberOperator.greaterThan,value:{type:u.CFValueType.num,value:(r.length-1-e)*10},iconType:t,iconId:String(e)}),Vi=j.forwardRef((t,e)=>{const r=ee.useDependency(x.LocaleService),n=o=>{t.onClick(o)};return I.jsx("div",{ref:e,className:H.iconGroupList,children:u.iconGroup.map((o,i)=>I.jsxs("div",{className:H.group,children:[I.jsx("div",{className:H.title,children:r.t(o.title)}),I.jsx("div",{className:H.itemContent,children:o.group.map(c=>I.jsx("div",{className:H.itemWrap,onClick:()=>{n(c.name)},children:I.jsx("div",{className:H.item,children:c.list.map((y,p)=>I.jsx("img",{className:H.icon,src:y},p))})},c.name))})]},i))})}),zi=t=>{const e=j.useMemo(()=>{const n=[];for(const o in u.iconMap){const i=u.iconMap[o],c=o;i.forEach((y,p)=>{n.push({iconType:c,base64:y,iconId:String(p)})})}return n},[]),r=n=>{t.onClick(n.iconType,n.iconId)};return I.jsxs("div",{className:H.iconItemListWrap,children:[I.jsxs("div",{className:H.none,onClick:()=>r({iconType:u.EMPTY_ICON_TYPE,iconId:""}),children:[I.jsx(ft,{className:H.icon}),I.jsx("span",{children:"无单元格图标"})]}),I.jsx("div",{className:H.iconItemList,children:e.map(n=>I.jsx("div",{className:H.item,children:I.jsx("img",{onClick:()=>r(n),className:`
100
100
  ${H.icon}
@@ -146,21 +146,21 @@
146
146
  ${H.utilItem}
147
147
  ${z.mLXl}
148
148
  `,children:[I.jsx(Q.Checkbox,{checked:!v,onChange:l=>{T(!l)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),I.jsx(ki,{errorMap:o,onChange:b,configList:p})]})},Ai=t=>{var h;const{onChange:e,interceptorManager:r}=t,n=ee.useDependency(x.LocaleService),o=((h=t.rule)==null?void 0:h.type)===u.CFRuleType.highlightCell?t.rule:void 0,i=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[c,y]=j.useState(()=>{const a=i[0].value,s=o==null?void 0:o.type;if(!o)return a;switch(s){case u.CFRuleType.highlightCell:switch(o.subType){case u.CFSubRuleType.average:return[u.CFNumberOperator.greaterThan,u.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[u.CFNumberOperator.lessThan,u.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":a;case u.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return a}),[p,S]=j.useState(()=>{const s=o==null?void 0:o.type;if(!o)return 10;switch(s){case u.CFRuleType.highlightCell:switch(o.subType){case u.CFSubRuleType.rank:return o.value||10}}return 10}),[v,T]=j.useState(()=>{const s=o==null?void 0:o.type;if(!o)return!1;switch(s){case u.CFRuleType.highlightCell:switch(o.subType){case u.CFSubRuleType.rank:return o.isPercent||!1}}return!1}),[_,w]=j.useState({}),b=a=>{const{type:s,isPercent:f,value:C,style:l}=a;if(s==="isNotBottom")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank,isPercent:f,isBottom:!1,value:C,style:l};if(s==="isBottom")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.rank,isPercent:f,isBottom:!0,value:C,style:l};if(s==="greaterThanAverage")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.average,operator:u.CFNumberOperator.greaterThan,style:l};if(s==="lessThanAverage")return{type:u.CFRuleType.highlightCell,subType:u.CFSubRuleType.average,operator:u.CFNumberOperator.lessThan,style:l}};j.useEffect(()=>r.intercept(r.getInterceptPoints().submit,{handler(){return b({type:c,isPercent:v,value:p,style:_})}}),[c,v,p,_,r]);const R=a=>{e(b(a))};return I.jsxs("div",{children:[I.jsx("div",{className:`
149
- ${z.title}
150
- ${z.mTBase}
151
- `,children:n.t("sheet.cf.panel.styleRule")}),I.jsx(Q.Select,{className:`
149
+ ${z.title}
150
+ ${z.mTBase}
151
+ `,children:n.t("sheet.cf.panel.styleRule")}),I.jsx(Q.Select,{className:`
152
152
  ${H.width100}
153
153
  ${z.mTSm}
154
154
  `,value:c,options:i,onChange:a=>{y(a),R({type:a,isPercent:v,value:p,style:_})}}),["isNotBottom","isBottom"].includes(c)&&I.jsxs("div",{className:`
155
- ${z.labelContainer}
156
- ${z.mTSm}
157
- `,children:[I.jsx(Q.InputNumber,{min:1,max:1e3,value:p,onChange:a=>{const s=a||0;S(s),R({type:c,isPercent:v,value:s,style:_})}}),I.jsxs("div",{className:`
158
- ${z.mLSm}
159
155
  ${z.labelContainer}
160
- ${H.text}
161
- `,children:[I.jsx(Q.Checkbox,{checked:v,onChange:a=>{T(!!a),R({type:c,isPercent:!!a,value:p,style:_})}}),n.t("sheet.cf.valueType.percent")]})]}),I.jsx("div",{className:`
162
- ${H.cfPreviewWrap}
163
- `,children:I.jsx(qe,{rule:b({type:c,isPercent:v,value:p,style:_})})}),I.jsx(fn,{style:o==null?void 0:o.style,className:`
156
+ ${z.mTSm}
157
+ `,children:[I.jsx(Q.InputNumber,{min:1,max:1e3,value:p,onChange:a=>{const s=a||0;S(s),R({type:c,isPercent:v,value:s,style:_})}}),I.jsxs("div",{className:`
158
+ ${z.mLSm}
159
+ ${z.labelContainer}
160
+ ${H.text}
161
+ `,children:[I.jsx(Q.Checkbox,{checked:v,onChange:a=>{T(!!a),R({type:c,isPercent:!!a,value:p,style:_})}}),n.t("sheet.cf.valueType.percent")]})]}),I.jsx("div",{className:`
162
+ ${H.cfPreviewWrap}
163
+ `,children:I.jsx(qe,{rule:b({type:c,isPercent:v,value:p,style:_})})}),I.jsx(fn,{style:o==null?void 0:o.style,className:`
164
164
  ${z.mTSm}
165
165
  `,onChange:a=>{w(a),R({type:c,isPercent:v,value:p,style:a})}})]})},qi=x.createInterceptorKey("beforeSubmit"),Wi=x.createInterceptorKey("submit"),Yn=t=>t.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getUnitId(),Kn=t=>{var e;return(e=t.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Hi=t=>{var d,g,F;const e=ee.useDependency(x.LocaleService),r=ee.useDependency(x.ICommandService),n=ee.useDependency(x.IUniverInstanceService),o=ee.useDependency(u.ConditionalFormattingRuleModel),i=ee.useDependency(Y.SheetsSelectionsService),c=Yn(n),y=Kn(n),[p,S]=j.useState(void 0),v=j.useRef((g=(d=t.rule)==null?void 0:d.ranges)!=null?g:[]),T=j.useMemo(()=>{var U,L,E;let D=(U=t.rule)==null?void 0:U.ranges;return D!=null&&D.length||(D=(E=(L=i.getCurrentSelections())==null?void 0:L.map(N=>N.range))!=null?E:[]),v.current=D,D!=null&&D.length?D.map(N=>{const W=Yt.serializeRange(N);return W==="NaN"?"":W}).filter(N=>!!N).join(","):""},[t.rule]),_=[{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"}],[w,b]=j.useState(()=>{var L,E;const D=(L=t.rule)==null?void 0:L.rule.type,U=_[0].value;if(!D)return U;switch(D){case u.CFRuleType.highlightCell:{switch((E=t.rule)==null?void 0:E.rule.subType){case u.CFSubRuleType.number:case u.CFSubRuleType.text:case u.CFSubRuleType.duplicateValues:case u.CFSubRuleType.uniqueValues:case u.CFSubRuleType.timePeriod:return"1";case u.CFSubRuleType.average:case u.CFSubRuleType.rank:return"2";case u.CFSubRuleType.formula:return"5"}break}case u.CFRuleType.dataBar:return"3";case u.CFRuleType.colorScale:return"4";case u.CFRuleType.iconSet:return"6"}return U}),R=j.useRef(void 0),h=j.useMemo(()=>new x.InterceptorManager({beforeSubmit:qi,submit:Wi}),[]),a=j.useMemo(()=>{switch(w){case"1":return Gn;case"2":return Ai;case"3":return Fi;case"4":return Pi;case"5":return ji;case"6":return $i;default:return Gn}},[w]);j.useEffect(()=>{const D=r.onCommandExecuted(U=>{if(U.id===Y.RemoveSheetMutation.id){const L=U.params;L.subUnitId===y&&L.unitId===c&&t.onCancel()}U.id===Y.SetWorksheetActiveOperation.id&&t.onCancel()});return()=>D.dispose()},[]);const s=D=>{R.current=D},f=D=>{const U=D.split(",").filter(L=>!!L).map(Yt.deserializeRangeWithSheet).map(L=>L.range);v.current=U},C=()=>{if(p)return;const U=(()=>{const E=n.getCurrentUnitForType(x.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!E)throw new Error("No active sheet found");return v.current.map(B=>Y.setEndForRange(B,E.getRowCount(),E.getColumnCount())).filter(B=>!(Number.isNaN(B.startRow)||Number.isNaN(B.startColumn)))})();if(h.fetchThroughInterceptors(h.getInterceptPoints().beforeSubmit)(!0,null)){const E=h.fetchThroughInterceptors(h.getInterceptPoints().submit)(null,null);if(E){const N=Yn(n),W=Kn(n);if(!N||!W)throw new Error("No active sheet found");let B={};t.rule&&t.rule.cfId?(B={...t.rule,ranges:U,rule:E},r.executeCommand(u.SetCfCommand.id,{unitId:N,subUnitId:W,rule:B}),t.onCancel()):(B={cfId:o.createCfId(N,W),ranges:U,rule:E,stopIfTrue:!1},r.executeCommand(u.AddCfCommand.id,{unitId:N,subUnitId:W,rule:B}),t.onCancel())}}},l=()=>{t.onCancel()},m=(D,U)=>{D?U.length<1?S(e.t("sheet.cf.errorMessage.rangeError")):S(void 0):S(e.t("sheet.cf.errorMessage.rangeError"))};return I.jsxs("div",{className:H.cfRuleStyleEditor,children:[I.jsx("div",{className:z.title,children:e.t("sheet.cf.panel.range")}),I.jsxs("div",{className:`
166
166
  ${z.mTBase}
package/lib/es/index.js CHANGED
@@ -4488,12 +4488,9 @@ const Pa = (t) => {
4488
4488
  }, [P]);
4489
4489
  return /* @__PURE__ */ B("div", { className: ye.cfRuleList, children: [
4490
4490
  /* @__PURE__ */ B("div", { className: ye.ruleSelector, children: [
4491
- /* @__PURE__ */ O("div", { children: f.tWithReactNode(
4492
- "sheet.cf.panel.managerRuleSelect",
4493
- /* @__PURE__ */ O(De, { className: ye.select, options: g, value: C, onChange: (q) => {
4494
- h(q);
4495
- } })
4496
- ).map((q, k) => /* @__PURE__ */ O("span", { children: q }, k)) }),
4491
+ /* @__PURE__ */ O("div", { children: f.tWithReactNode("sheet.cf.panel.managerRuleSelect", /* @__PURE__ */ O(De, { className: ye.select, options: g, value: C, onChange: (q) => {
4492
+ h(q);
4493
+ } })).map((q, k) => /* @__PURE__ */ O("span", { children: q }, k)) }),
4497
4494
  /* @__PURE__ */ B("div", { className: ye.btnList, children: [
4498
4495
  /* @__PURE__ */ O(ar, { title: u.t("sheet.cf.panel.createRule"), placement: "bottom", children: /* @__PURE__ */ O(
4499
4496
  "div",
@@ -4711,17 +4708,7 @@ const Pa = (t) => {
4711
4708
  const E = "#2e55ef";
4712
4709
  return n && ((M = n.config[n.config.length - 1]) == null ? void 0 : M.color) || E;
4713
4710
  }), P = be(() => (E) => {
4714
- const {
4715
- minType: M,
4716
- medianType: W,
4717
- maxType: U,
4718
- minValue: Z,
4719
- medianValue: ue,
4720
- maxValue: ie,
4721
- minColor: q,
4722
- medianColor: k,
4723
- maxColor: oe
4724
- } = E, se = [];
4711
+ const { minType: M, medianType: W, maxType: U, minValue: Z, medianValue: ue, maxValue: ie, minColor: q, medianColor: k, maxColor: oe } = E, se = [];
4725
4712
  return se.push({ color: q, value: { type: M, value: Z } }), W !== "none" && se.push({ color: k, value: { type: W, value: ue } }), se.push({ color: oe, value: { type: U, value: ie } }), { config: se.map((ve, Ee) => ({ ...ve, index: Ee })), type: K.colorScale };
4726
4713
  }, []);
4727
4714
  Ce(() => e.intercept(e.getInterceptPoints().submit, {
@@ -4992,8 +4979,8 @@ const Pa = (t) => {
4992
4979
  "div",
4993
4980
  {
4994
4981
  className: `
4995
- ${H.cfPreviewWrap}
4996
- `,
4982
+ ${H.cfPreviewWrap}
4983
+ `,
4997
4984
  children: /* @__PURE__ */ O(wt, { rule: c({ isGradient: o, minValue: s, minValueType: R, maxValue: d, maxValueType: C, positiveColor: u, nativeColor: f, isShowValue: l }) })
4998
4985
  }
4999
4986
  ),
@@ -5003,10 +4990,10 @@ const Pa = (t) => {
5003
4990
  "div",
5004
4991
  {
5005
4992
  className: `
5006
- ${$.mTSm}
5007
- ${$.mLXxs}
5008
- ${$.labelContainer}
5009
- `,
4993
+ ${$.mTSm}
4994
+ ${$.mLXxs}
4995
+ ${$.labelContainer}
4996
+ `,
5010
4997
  children: [
5011
4998
  /* @__PURE__ */ B(
5012
4999
  Bi,
@@ -5025,9 +5012,9 @@ const Pa = (t) => {
5025
5012
  "div",
5026
5013
  {
5027
5014
  className: `
5028
- ${H.utilItem}
5029
- ${$.mLXl}
5030
- `,
5015
+ ${H.utilItem}
5016
+ ${$.mLXl}
5017
+ `,
5031
5018
  children: [
5032
5019
  /* @__PURE__ */ O(
5033
5020
  fn,
@@ -5052,24 +5039,24 @@ const Pa = (t) => {
5052
5039
  "div",
5053
5040
  {
5054
5041
  className: `
5055
- ${$.labelContainer}
5056
- ${$.mTSm}
5057
- ${$.mLXxs}
5058
- `,
5042
+ ${$.labelContainer}
5043
+ ${$.mTSm}
5044
+ ${$.mLXxs}
5045
+ `,
5059
5046
  children: [
5060
5047
  /* @__PURE__ */ B(
5061
5048
  "div",
5062
5049
  {
5063
5050
  className: `
5064
- ${$.labelContainer}
5065
- `,
5051
+ ${$.labelContainer}
5052
+ `,
5066
5053
  children: [
5067
5054
  /* @__PURE__ */ O(
5068
5055
  "div",
5069
5056
  {
5070
5057
  className: `
5071
- ${H.text}
5072
- `,
5058
+ ${H.text}
5059
+ `,
5073
5060
  children: r.t("sheet.cf.panel.native")
5074
5061
  }
5075
5062
  ),
@@ -5087,16 +5074,16 @@ const Pa = (t) => {
5087
5074
  "div",
5088
5075
  {
5089
5076
  className: `
5090
- ${$.labelContainer}
5091
- ${$.mLSm}
5092
- `,
5077
+ ${$.labelContainer}
5078
+ ${$.mLSm}
5079
+ `,
5093
5080
  children: [
5094
5081
  /* @__PURE__ */ O(
5095
5082
  "div",
5096
5083
  {
5097
5084
  className: `
5098
- ${H.text}
5099
- `,
5085
+ ${H.text}
5086
+ `,
5100
5087
  children: r.t("sheet.cf.panel.positive")
5101
5088
  }
5102
5089
  ),
@@ -5120,9 +5107,9 @@ const Pa = (t) => {
5120
5107
  "div",
5121
5108
  {
5122
5109
  className: `
5123
- ${$.mTSm}
5124
- ${$.labelContainer}
5125
- `,
5110
+ ${$.mTSm}
5111
+ ${$.labelContainer}
5112
+ `,
5126
5113
  children: [
5127
5114
  /* @__PURE__ */ O(
5128
5115
  De,
@@ -5158,9 +5145,9 @@ const Pa = (t) => {
5158
5145
  "div",
5159
5146
  {
5160
5147
  className: `
5161
- ${$.mTSm}
5162
- ${$.labelContainer}
5163
- `,
5148
+ ${$.mTSm}
5149
+ ${$.labelContainer}
5150
+ `,
5164
5151
  children: [
5165
5152
  /* @__PURE__ */ O(
5166
5153
  De,
@@ -5370,25 +5357,11 @@ const Pa = (t) => {
5370
5357
  switch (Ce(() => {
5371
5358
  switch (e) {
5372
5359
  case G.text: {
5373
- [
5374
- le.beginsWith,
5375
- le.endsWith,
5376
- le.containsText,
5377
- le.notContainsText,
5378
- le.equal,
5379
- le.notEqual
5380
- ].includes(r) && n(w);
5360
+ [le.beginsWith, le.endsWith, le.containsText, le.notContainsText, le.equal, le.notEqual].includes(r) && n(w);
5381
5361
  break;
5382
5362
  }
5383
5363
  case G.number: {
5384
- [
5385
- Q.equal,
5386
- Q.notEqual,
5387
- Q.greaterThan,
5388
- Q.greaterThanOrEqual,
5389
- Q.lessThan,
5390
- Q.lessThanOrEqual
5391
- ].includes(r) && n(y), [Q.between, Q.notBetween].includes(r) && n([C, d]);
5364
+ [Q.equal, Q.notEqual, Q.greaterThan, Q.greaterThanOrEqual, Q.lessThan, Q.lessThanOrEqual].includes(r) && n(y), [Q.between, Q.notBetween].includes(r) && n([C, d]);
5392
5365
  break;
5393
5366
  }
5394
5367
  }
@@ -5397,14 +5370,7 @@ const Pa = (t) => {
5397
5370
  handler: (g, x, P) => {
5398
5371
  switch (e) {
5399
5372
  case G.text:
5400
- if ([
5401
- le.beginsWith,
5402
- le.containsText,
5403
- le.endsWith,
5404
- le.notEqual,
5405
- le.notContainsText,
5406
- le.equal
5407
- ].includes(r))
5373
+ if ([le.beginsWith, le.containsText, le.endsWith, le.notEqual, le.notContainsText, le.equal].includes(r))
5408
5374
  return w ? P(g) : (b(u.t("sheet.cf.errorMessage.notBlank")), !1);
5409
5375
  }
5410
5376
  return P(g);
@@ -5415,14 +5381,7 @@ const Pa = (t) => {
5415
5381
  };
5416
5382
  }, [e, y, w, r]), e) {
5417
5383
  case G.text: {
5418
- if ([
5419
- le.beginsWith,
5420
- le.endsWith,
5421
- le.containsText,
5422
- le.notContainsText,
5423
- le.equal,
5424
- le.notEqual
5425
- ].includes(r)) {
5384
+ if ([le.beginsWith, le.endsWith, le.containsText, le.notContainsText, le.equal, le.notEqual].includes(r)) {
5426
5385
  const c = (g) => {
5427
5386
  _(g), n(g);
5428
5387
  };
@@ -5430,8 +5389,8 @@ const Pa = (t) => {
5430
5389
  "div",
5431
5390
  {
5432
5391
  className: `
5433
- ${$.mTSm}
5434
- `,
5392
+ ${$.mTSm}
5393
+ `,
5435
5394
  children: /* @__PURE__ */ O(rn, { errorText: R, children: /* @__PURE__ */ O(
5436
5395
  Gi,
5437
5396
  {
@@ -5448,14 +5407,7 @@ const Pa = (t) => {
5448
5407
  break;
5449
5408
  }
5450
5409
  case G.number: {
5451
- if ([
5452
- Q.equal,
5453
- Q.notEqual,
5454
- Q.greaterThan,
5455
- Q.greaterThanOrEqual,
5456
- Q.lessThan,
5457
- Q.lessThanOrEqual
5458
- ].includes(r)) {
5410
+ if ([Q.equal, Q.notEqual, Q.greaterThan, Q.greaterThanOrEqual, Q.lessThan, Q.lessThanOrEqual].includes(r)) {
5459
5411
  const c = (g) => {
5460
5412
  f(g || 0), n(g || 0), m("");
5461
5413
  };
@@ -5463,8 +5415,8 @@ const Pa = (t) => {
5463
5415
  "div",
5464
5416
  {
5465
5417
  className: `
5466
- ${$.mTSm}
5467
- `,
5418
+ ${$.mTSm}
5419
+ `,
5468
5420
  children: /* @__PURE__ */ O(rn, { errorText: S, children: /* @__PURE__ */ O(at, { min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER, className: H.width100, value: y, onChange: c }) })
5469
5421
  }
5470
5422
  );
@@ -5479,9 +5431,9 @@ const Pa = (t) => {
5479
5431
  "div",
5480
5432
  {
5481
5433
  className: `
5482
- ${$.mTSm}
5483
- ${$.labelContainer}
5484
- `,
5434
+ ${$.mTSm}
5435
+ ${$.labelContainer}
5436
+ `,
5485
5437
  children: [
5486
5438
  /* @__PURE__ */ O(rn, { errorText: s, children: /* @__PURE__ */ O(at, { min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER, value: C, onChange: c }) }),
5487
5439
  /* @__PURE__ */ O(rn, { errorText: l, children: /* @__PURE__ */ O(
@@ -5548,28 +5500,22 @@ const Pa = (t) => {
5548
5500
  const { interceptorManager: e, onChange: r } = t, n = he(_e), o = ((v = t.rule) == null ? void 0 : v.type) === K.highlightCell ? t.rule : void 0, [i, u] = A(() => {
5549
5501
  const l = G.text;
5550
5502
  return o && o.subType || l;
5551
- }), y = [
5552
- {
5553
- value: G.text,
5554
- label: n.t("sheet.cf.subRuleType.text")
5555
- },
5556
- {
5557
- value: G.number,
5558
- label: n.t("sheet.cf.subRuleType.number")
5559
- },
5560
- {
5561
- value: G.timePeriod,
5562
- label: n.t("sheet.cf.subRuleType.timePeriod")
5563
- },
5564
- {
5565
- value: G.duplicateValues,
5566
- label: n.t("sheet.cf.subRuleType.duplicateValues")
5567
- },
5568
- {
5569
- value: G.uniqueValues,
5570
- label: n.t("sheet.cf.subRuleType.uniqueValues")
5571
- }
5572
- ], f = be(() => Gr(i, n), [i]), [S, m] = A(() => {
5503
+ }), y = [{
5504
+ value: G.text,
5505
+ label: n.t("sheet.cf.subRuleType.text")
5506
+ }, {
5507
+ value: G.number,
5508
+ label: n.t("sheet.cf.subRuleType.number")
5509
+ }, {
5510
+ value: G.timePeriod,
5511
+ label: n.t("sheet.cf.subRuleType.timePeriod")
5512
+ }, {
5513
+ value: G.duplicateValues,
5514
+ label: n.t("sheet.cf.subRuleType.duplicateValues")
5515
+ }, {
5516
+ value: G.uniqueValues,
5517
+ label: n.t("sheet.cf.subRuleType.uniqueValues")
5518
+ }], f = be(() => Gr(i, n), [i]), [S, m] = A(() => {
5573
5519
  const l = f ? f[0].value : void 0;
5574
5520
  return o && o.operator || l;
5575
5521
  }), [w, _] = A(() => {
@@ -5580,14 +5526,7 @@ const Pa = (t) => {
5580
5526
  var p, c, g, x, P, L, N, E, M, W, U, Z, ue, ie, q;
5581
5527
  switch (l.subType || i) {
5582
5528
  case G.text: {
5583
- if ([
5584
- le.beginsWith,
5585
- le.endsWith,
5586
- le.containsText,
5587
- le.notContainsText,
5588
- le.equal,
5589
- le.notEqual
5590
- ].includes(S))
5529
+ if ([le.beginsWith, le.endsWith, le.containsText, le.notContainsText, le.equal, le.notEqual].includes(S))
5591
5530
  return {
5592
5531
  type: K.highlightCell,
5593
5532
  subType: (p = l.subType) != null ? p : i,
@@ -5598,14 +5537,7 @@ const Pa = (t) => {
5598
5537
  break;
5599
5538
  }
5600
5539
  case G.number: {
5601
- if ([
5602
- Q.equal,
5603
- Q.notEqual,
5604
- Q.greaterThan,
5605
- Q.greaterThanOrEqual,
5606
- Q.lessThan,
5607
- Q.lessThanOrEqual
5608
- ].includes(S))
5540
+ if ([Q.equal, Q.notEqual, Q.greaterThan, Q.greaterThanOrEqual, Q.lessThan, Q.lessThanOrEqual].includes(S))
5609
5541
  return {
5610
5542
  type: K.highlightCell,
5611
5543
  subType: (P = l.subType) != null ? P : i,
@@ -5652,9 +5584,9 @@ const Pa = (t) => {
5652
5584
  "div",
5653
5585
  {
5654
5586
  className: `
5655
- ${$.title}
5656
- ${$.mTBase}
5657
- `,
5587
+ ${$.title}
5588
+ ${$.mTBase}
5589
+ `,
5658
5590
  children: n.t("sheet.cf.panel.styleRule")
5659
5591
  }
5660
5592
  ),
@@ -5687,8 +5619,8 @@ const Pa = (t) => {
5687
5619
  "div",
5688
5620
  {
5689
5621
  className: `
5690
- ${H.cfPreviewWrap}
5691
- `,
5622
+ ${H.cfPreviewWrap}
5623
+ `,
5692
5624
  children: /* @__PURE__ */ O(wt, { rule: C({}) })
5693
5625
  }
5694
5626
  ),
@@ -5779,10 +5711,7 @@ const Pa = (t) => {
5779
5711
  ) }, `${n.iconType}_${n.iconId}`)) })
5780
5712
  ] });
5781
5713
  }, ml = (t) => {
5782
- const { onChange: e, configList: r, errorMap: n = {} } = t, o = he(_e), i = [
5783
- { label: o.t(`sheet.cf.symbol.${Q.greaterThan}`), value: Q.greaterThan },
5784
- { label: o.t(`sheet.cf.symbol.${Q.greaterThanOrEqual}`), value: Q.greaterThanOrEqual }
5785
- ], u = [
5714
+ const { onChange: e, configList: r, errorMap: n = {} } = t, o = he(_e), i = [{ label: o.t(`sheet.cf.symbol.${Q.greaterThan}`), value: Q.greaterThan }, { label: o.t(`sheet.cf.symbol.${Q.greaterThanOrEqual}`), value: Q.greaterThanOrEqual }], u = [
5786
5715
  { label: o.t(`sheet.cf.valueType.${te.num}`), value: te.num },
5787
5716
  { label: o.t(`sheet.cf.valueType.${te.percent}`), value: te.percent },
5788
5717
  { label: o.t(`sheet.cf.valueType.${te.percentile}`), value: te.percentile },
@@ -6145,12 +6074,7 @@ const Pa = (t) => {
6145
6074
  ] });
6146
6075
  }, yl = (t) => {
6147
6076
  var h;
6148
- const { onChange: e, interceptorManager: r } = t, n = he(_e), o = ((h = t.rule) == null ? void 0 : h.type) === K.highlightCell ? t.rule : void 0, i = [
6149
- { label: n.t("sheet.cf.panel.isNotBottom"), value: "isNotBottom" },
6150
- { label: n.t("sheet.cf.panel.isBottom"), value: "isBottom" },
6151
- { label: n.t("sheet.cf.panel.greaterThanAverage"), value: "greaterThanAverage" },
6152
- { label: n.t("sheet.cf.panel.lessThanAverage"), value: "lessThanAverage" }
6153
- ], [u, y] = A(() => {
6077
+ const { onChange: e, interceptorManager: r } = t, n = he(_e), o = ((h = t.rule) == null ? void 0 : h.type) === K.highlightCell ? t.rule : void 0, i = [{ label: n.t("sheet.cf.panel.isNotBottom"), value: "isNotBottom" }, { label: n.t("sheet.cf.panel.isBottom"), value: "isBottom" }, { label: n.t("sheet.cf.panel.greaterThanAverage"), value: "greaterThanAverage" }, { label: n.t("sheet.cf.panel.lessThanAverage"), value: "lessThanAverage" }], [u, y] = A(() => {
6154
6078
  const s = i[0].value, a = o == null ? void 0 : o.type;
6155
6079
  if (!o)
6156
6080
  return s;
@@ -6212,9 +6136,9 @@ const Pa = (t) => {
6212
6136
  "div",
6213
6137
  {
6214
6138
  className: `
6215
- ${$.title}
6216
- ${$.mTBase}
6217
- `,
6139
+ ${$.title}
6140
+ ${$.mTBase}
6141
+ `,
6218
6142
  children: n.t("sheet.cf.panel.styleRule")
6219
6143
  }
6220
6144
  ),
@@ -6236,9 +6160,9 @@ const Pa = (t) => {
6236
6160
  "div",
6237
6161
  {
6238
6162
  className: `
6239
- ${$.labelContainer}
6240
- ${$.mTSm}
6241
- `,
6163
+ ${$.labelContainer}
6164
+ ${$.mTSm}
6165
+ `,
6242
6166
  children: [
6243
6167
  /* @__PURE__ */ O(
6244
6168
  at,
@@ -6256,10 +6180,10 @@ const Pa = (t) => {
6256
6180
  "div",
6257
6181
  {
6258
6182
  className: `
6259
- ${$.mLSm}
6260
- ${$.labelContainer}
6261
- ${H.text}
6262
- `,
6183
+ ${$.mLSm}
6184
+ ${$.labelContainer}
6185
+ ${H.text}
6186
+ `,
6263
6187
  children: [
6264
6188
  /* @__PURE__ */ O(
6265
6189
  fn,
@@ -6281,8 +6205,8 @@ const Pa = (t) => {
6281
6205
  "div",
6282
6206
  {
6283
6207
  className: `
6284
- ${H.cfPreviewWrap}
6285
- `,
6208
+ ${H.cfPreviewWrap}
6209
+ `,
6286
6210
  children: /* @__PURE__ */ O(wt, { rule: b({ type: u, isPercent: m, value: f, style: _ }) })
6287
6211
  }
6288
6212
  ),
package/lib/umd/index.js CHANGED
@@ -38,34 +38,34 @@
38
38
  `,"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:`
39
39
  ${A.mLXxs}
40
40
  `,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:`
41
- ${G.cfPreviewWrap}
42
- `,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:`
43
- ${A.mTSm}
44
- ${A.mLXxs}
45
- ${A.labelContainer}
46
- `,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:`
47
- ${G.utilItem}
48
- ${A.mLXl}
49
- `,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:`
50
- ${A.labelContainer}
51
- ${A.mTSm}
52
- ${A.mLXxs}
53
- `,children:[R.jsxs("div",{className:`
41
+ ${G.cfPreviewWrap}
42
+ `,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:`
43
+ ${A.mTSm}
44
+ ${A.mLXxs}
54
45
  ${A.labelContainer}
55
- `,children:[R.jsx("div",{className:`
56
- ${G.text}
57
- `,children:n.t("sheet.cf.panel.native")}),R.jsx(Me,{color:p,onChange:M})]}),R.jsxs("div",{className:`
46
+ `,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:`
47
+ ${G.utilItem}
48
+ ${A.mLXl}
49
+ `,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:`
58
50
  ${A.labelContainer}
59
- ${A.mLSm}
60
- `,children:[R.jsx("div",{className:`
61
- ${G.text}
62
- `,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:`
63
- ${A.mTSm}
64
- ${A.labelContainer}
65
- `,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:`
66
- ${A.mTSm}
67
- ${A.labelContainer}
68
- `,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:`
51
+ ${A.mTSm}
52
+ ${A.mLXxs}
53
+ `,children:[R.jsxs("div",{className:`
54
+ ${A.labelContainer}
55
+ `,children:[R.jsx("div",{className:`
56
+ ${G.text}
57
+ `,children:n.t("sheet.cf.panel.native")}),R.jsx(Me,{color:p,onChange:M})]}),R.jsxs("div",{className:`
58
+ ${A.labelContainer}
59
+ ${A.mLSm}
60
+ `,children:[R.jsx("div",{className:`
61
+ ${G.text}
62
+ `,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:`
63
+ ${A.mTSm}
64
+ ${A.labelContainer}
65
+ `,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:`
66
+ ${A.mTSm}
67
+ ${A.labelContainer}
68
+ `,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:`
69
69
  ${A.title}
70
70
  ${A.mTBase}
71
71
  `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx("div",{className:`
@@ -75,26 +75,26 @@
75
75
  `,children:R.jsx(We,{rule:s({style:E})})}),R.jsx(sr,{style:y==null?void 0:y.style,className:`
76
76
  ${A.mTSm}
77
77
  `,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:`
78
- ${A.mTSm}
79
- `,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:`
80
- ${A.mTSm}
81
- `,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:`
82
- ${A.mTSm}
83
- ${A.labelContainer}
84
- `,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:`
78
+ ${A.mTSm}
79
+ `,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:`
80
+ ${A.mTSm}
81
+ `,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:`
82
+ ${A.mTSm}
83
+ ${A.labelContainer}
84
+ `,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:`
85
85
  ${A.mLSm}
86
86
  `,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:`
87
- ${A.title}
88
- ${A.mTBase}
89
- `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
87
+ ${A.title}
88
+ ${A.mTBase}
89
+ `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
90
90
  ${A.mTSm}
91
91
  ${G.width100}
92
92
  `,onChange:h,value:o,options:y}),(p==null?void 0:p.length)&&R.jsx(ee.Select,{className:`
93
93
  ${A.mTSm}
94
94
  ${G.width100}
95
95
  `,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:`
96
- ${G.cfPreviewWrap}
97
- `,children:R.jsx(We,{rule:T({})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
96
+ ${G.cfPreviewWrap}
97
+ `,children:R.jsx(We,{rule:T({})})}),R.jsx(sr,{style:a==null?void 0:a.style,className:`
98
98
  ${A.mLXxs}
99
99
  `,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:`
100
100
  ${G.icon}
@@ -146,21 +146,21 @@
146
146
  ${G.utilItem}
147
147
  ${A.mLXl}
148
148
  `,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:`
149
- ${A.title}
150
- ${A.mTBase}
151
- `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
149
+ ${A.title}
150
+ ${A.mTBase}
151
+ `,children:r.t("sheet.cf.panel.styleRule")}),R.jsx(ee.Select,{className:`
152
152
  ${G.width100}
153
153
  ${A.mTSm}
154
154
  `,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:`
155
- ${A.labelContainer}
156
- ${A.mTSm}
157
- `,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:`
158
- ${A.mLSm}
159
155
  ${A.labelContainer}
160
- ${G.text}
161
- `,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:`
162
- ${G.cfPreviewWrap}
163
- `,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:`
156
+ ${A.mTSm}
157
+ `,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:`
158
+ ${A.mLSm}
159
+ ${A.labelContainer}
160
+ ${G.text}
161
+ `,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:`
162
+ ${G.cfPreviewWrap}
163
+ `,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:`
164
164
  ${A.mTSm}
165
165
  `,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:`
166
166
  ${A.mTBase}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting-ui",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -58,15 +58,15 @@
58
58
  "@univerjs/icons": "^0.2.20",
59
59
  "react-grid-layout": "^1.4.4",
60
60
  "react-resizable": "^3.0.5",
61
- "@univerjs/core": "0.6.2",
62
- "@univerjs/design": "0.6.2",
63
- "@univerjs/engine-formula": "0.6.2",
64
- "@univerjs/engine-render": "0.6.2",
65
- "@univerjs/sheets": "0.6.2",
66
- "@univerjs/sheets-conditional-formatting": "0.6.2",
67
- "@univerjs/sheets-ui": "0.6.2",
68
- "@univerjs/sheets-formula-ui": "0.6.2",
69
- "@univerjs/ui": "0.6.2"
61
+ "@univerjs/core": "0.6.3",
62
+ "@univerjs/engine-formula": "0.6.3",
63
+ "@univerjs/engine-render": "0.6.3",
64
+ "@univerjs/sheets": "0.6.3",
65
+ "@univerjs/sheets-formula-ui": "0.6.3",
66
+ "@univerjs/ui": "0.6.3",
67
+ "@univerjs/sheets-ui": "0.6.3",
68
+ "@univerjs/design": "0.6.3",
69
+ "@univerjs/sheets-conditional-formatting": "0.6.3"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/react-grid-layout": "^1.3.5",
@@ -75,10 +75,10 @@
75
75
  "react": "18.3.1",
76
76
  "rxjs": "^7.8.1",
77
77
  "tailwindcss": "^3.4.17",
78
- "typescript": "^5.7.3",
78
+ "typescript": "^5.8.2",
79
79
  "vite": "^6.2.0",
80
80
  "vitest": "^3.0.7",
81
- "@univerjs-infra/shared": "0.6.2"
81
+ "@univerjs-infra/shared": "0.6.3"
82
82
  },
83
83
  "scripts": {
84
84
  "test": "vitest run",