@univerjs/sheets-data-validation-ui 0.14.0-insiders.20251222-4efcfbb → 0.14.0-insiders.20251227-b250a8d
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 +1 -1
- package/lib/es/index.js +2 -2
- package/lib/index.js +2 -2
- package/lib/umd/index.js +1 -1
- package/package.json +15 -15
package/lib/cjs/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
|
|
3
3
|
univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
|
|
4
4
|
univer-rounded-md univer-p-2 univer-pr-9
|
|
5
|
-
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(R=>l.addShape({range:R,style:O,primary:null})))},onMouseLeave:()=>{var R;u(!1),(R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:d==null?void 0:d.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(R=>tt.serializeRange(R)).join(",")}),v?g.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:M,children:g.jsx(ct,{})}):null]})};function Sn(e){const t=E.useDependency(C.SheetDataValidationModel),n=E.useDependency(o.IUniverInstanceService),a=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(ce),s=E.useDependency(o.LocaleService),[c,l]=T.useState([]),{workbook:d}=e,h=E.useObservable(d.activeSheet$,void 0,!0),v=d.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(v,u));const y=t.ruleChange$.subscribe(m=>{m.unitId===v&&m.subUnitId===u&&l(t.getRules(v,u))});return()=>{y.unsubscribe()}},[v,u,t]);const S=async()=>{const y=C.createDefaultNewRule(r),m={unitId:v,subUnitId:u,rule:y};await a.executeCommand(C.AddSheetDataValidationCommand.id,m),i.setActiveRule({unitId:v,subUnitId:u,rule:y})},p=()=>{a.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},M=(y=>{const m=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=m.getActiveSheet(),I=m.getUnitId(),f=D.getSheetId();return y.map(F=>H.checkRangesEditablePermission(r,I,f,F.ranges)?{...F}:{...F,disable:!0})})(c),R=M==null?void 0:M.some(y=>y.disable);return g.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var m;return g.jsx(fn,{unitId:v,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:v,subUnitId:u,rule:y})},rule:y,disable:(m=y.disable)!=null?m:!1},y.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!R?g.jsx(V.Button,{onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=E.useDependency(ce),t=E.useObservable(e.activeRule$,e.activeRule),n=E.useDependency(o.IUniverInstanceService),a=E.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=a==null?void 0:a.activeSheet$)!=null?i:re.of(null)},void 0,void 0,[]);return!a||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(mn,{},t.rule.uid):g.jsx(Sn,{workbook:a})},In=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({...n,formula1:d})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:d=>{a==null||a({...n,formula2:d})}})})]}):g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({formula1:d})}})})};function Cn(e){const{value:t,onChange:n,showError:a,validResult:r}=e,i=E.useDependency(o.LocaleService),s=a?r==null?void 0:r.formula1:"",c=a?r==null?void 0:r.formula2:"",[l,d]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function yn(e){var v;const{unitId:t,subUnitId:n,value:a,onChange:r,showError:i,validResult:s}=e,c=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[d,h]=T.useState(!1);return E.useSidebarClick(u=>{var p;((p=l.current)==null?void 0:p.isClickOutSide(u))&&h(!1)}),g.jsx(V.FormLayout,{error:c,children:g.jsx(ot.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:(v=a==null?void 0:a.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(a==null?void 0:a.formula1)&&(r==null||r({...a,formula1:S}))},onFocus:()=>h(!0)})})}const Rn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Dn=e=>{const{value:t,onChange:n,disabled:a}=e,[r,i]=T.useState(!1);return g.jsx(V.Dropdown,{align:"start",disabled:a,open:r,onOpenChange:i,overlay:g.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Rn.map(s=>g.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:g.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",V.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(dt,{})]})})},vt=e=>{const{item:t,commonProps:n,className:a}=e,{onItemChange:r,onItemDelete:i}=n;return g.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",a),children:[!t.isRef&&g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Et,{})}),g.jsx(Dn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(ct,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,v]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[p,O]=T.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),R=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),m=E.useDependency(C.DataValidationFormulaController),[D,I]=T.useState(()=>d.split(",")),f=R.getValidatorItem(o.DataValidationType.LIST),[w,F]=T.useState([]),[B,j]=T.useState(""),W=s?i==null?void 0:i.formula1:"",A=T.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),x=E.useObservable(A),k=E.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const b=y.getRuleById(a,r,c),$=b==null?void 0:b.formula1;if(o.isFormulaString($)&&f&&b){const _=await f.getListAsync(b,a,r);F(_)}})()},[y,x,f,c,r,a]),T.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(S(l),O(p))},[p,l]);const[z,q]=T.useState(()=>{const b=h!=="1"?C.deserializeListOptions(l):[],$=d.split(",");return b.map((_,U)=>({label:_,color:$[U]||ve,isRef:!1,id:o.generateRandomId(4)}))}),te=(b,$,_)=>{const U=z.find(X=>X.id===b);U&&(U.label=$,U.color=_,q([...z]))},K=b=>{const $=z.findIndex(_=>_.id===b);$!==-1&&(z.splice($,1),q([...z]))},ne=d.split(","),ae=T.useMemo(()=>w.map((b,$)=>({label:b,color:ne[$]||ve,id:`${$}`,isRef:!0})),[ne,w]),de=(b,$,_)=>{const U=[...D];U[+b]=_,I(U),k({formula1:l,formula2:U.join(",")})},ue=()=>{q([...z,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,$=[];z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:U})=>{U.forEach(X=>{b.has(X)||(b.add(X),$.push({label:X,color:_.color}))})}),k({formula1:C.serializeListOptions($.map(_=>_.label)),formula2:$.map(_=>_.color===ve?"":_.color).join(",")})},[z,k,h,p,D]);const Q=E.useEvent(async b=>{if(!o.isFormulaString(b)){k==null||k({formula1:"",formula2:d});return}m.getFormulaRefCheck(b)?(k==null||k({formula1:o.isFormulaString(b)?b:"",formula2:d}),j("")):(k==null||k({formula1:"",formula2:d}),S("="),j(M.t("dataValidation.validFail.formulaError")))}),Z=T.useRef(null),[le,J]=T.useState(!1);return E.useSidebarClick(b=>{var _;((_=Z.current)==null?void 0:_.isClickOutSide(b))&&J(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:b=>{v(b),S(p),b==="1"&&k({formula1:p==="="?"":p,formula2:D.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(V.FormLayout,{error:W||B||void 0,children:[g.jsx(ot.FormulaEditor,{ref:Z,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:u,unitId:a,subUnitId:r,isFocus:le,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(b="")=>{const $=(b!=null?b:"").trim();O($),Q($)}}),ae.length>0&&g.jsx("div",{className:"univer-mt-3",children:ae.map(b=>g.jsx(vt,{className:"univer-mb-3",item:b,commonProps:{onItemChange:de}},b.id))})]}):g.jsx(V.FormLayout,{error:W,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(V.DraggableList,{list:z,onListChange:q,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(vt,{item:b,commonProps:{onItemChange:te,onItemDelete:K}},b.id),idKey:"id"}),g.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:ue,children:[g.jsx(wt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Vn=[[C.CUSTOM_FORMULA_INPUT_NAME,yn],[C.BASE_FORMULA_INPUT_NAME,In],[C.LIST_FORMULA_INPUT_NAME,wn],[C.CHECKBOX_FORMULA_INPUT_NAME,Cn]],En="LIST_RENDER_MODE_OPTION_INPUT";function ke(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}ke.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function Ne(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:a.t("dataValidation.showTime.label")})})}Ne.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,a)=>{for(var r=a>1?void 0:a?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(n,a)=>t(n,a,e);const Ae=6;let nt=class{constructor(e,t,n,a,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,v;const{vt:n,ht:a}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(a){case o.HorizontalAlign.LEFT:c=Ae;break;case o.HorizontalAlign.RIGHT:c=Ae+(r-s);break;default:c=Ae+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var d,h,v,u,S,p,O,M,R;const{formula1:a=C.CHECKBOX_FORMULA_1,formula2:r=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=C.getFormulaResult((v=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:v[0]),c=C.getFormulaResult((p=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:p[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(a)?C.getFormulaResult((R=(M=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:M[0])==null?void 0:R[0]):a,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var W,A,x,k;const{style:n,primaryWithCoord:a,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=C.getCellValueOrigin(s.getCellRaw(c,l)),v=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u||!((W=u.skipDefaultFontRender)!=null&&W.call(u,v,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(v,r,i),{formula1:p}=S,O=this._calc(d,n),{a:M,d:R}=e.getTransform(),y=P.fixLineWidthByScale(O.left,M),m=P.fixLineWidthByScale(O.top,R),D=P.Transform.create().composeMatrix({left:y,top:m,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=d.endX-d.startX,f=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,I,f),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const F=((A=n==null?void 0:n.fs)!=null?A:10)*1.6,B=String(h)===String(p),j=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:B,width:F,height:F,fill:(k=(x=n==null?void 0:n.cl)==null?void 0:x.rgb)!=null?k:j}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),r=a.top,i=a.top+a.height,s=a.left,c=a.left+a.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:r,worksheet:i,row:s,col:c}=e,l=C.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(a,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,d,l,{unitId:a,subUnitId:r,row:s,column:c})))return;const{formula1:v,formula2:u}=await this._parseFormula(d,a,r),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};nt=Tn([Ce(0,o.ICommandService),Ce(1,o.IUniverInstanceService),Ce(2,o.Inject(C.DataValidationFormulaService)),Ce(3,o.Inject(o.ThemeService)),Ce(4,o.Inject(P.IRenderManagerService)),Ce(5,o.Inject(C.SheetDataValidationModel))],nt);var On=Object.getOwnPropertyDescriptor,An=(e,t,n,a)=>{for(var r=a>1?void 0:a?On(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ln=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=An([Ln(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class Pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(nt));L(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const xn="data-validation.formula-input";class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",xn);L(this,"optionsInput",Ne.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,Ke=4,bt=4,at=6,Be=6,pe=14;function Nn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Mt*2,{ba:r,bd:i}=n,s=r+i;return{width:a,height:s+kn*2,ba:r}}function Ze(e,t,n,a){const r=pe+at*2,i=n-r,s=a-Be*2,c=e.map(u=>({layout:Nn(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:p,height:O}=S;!l||l.width+p+Ke>i?(l={width:p,height:O,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+Ke}),l.width=l.width+p+Ke)});let h=0,v=0;return d.forEach((u,S)=>{v=Math.max(v,u.width),S===d.length-1?h+=u.height:h+=u.height+bt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+Be*2,calcAutoWidth:v+r}}const Bn=8;class Wn extends P.Shape{static drawWith(t,n){const{fontString:a,info:r,fill:i,color:s}=n,{layout:c,text:l}=r;t.save(),P.Rect.drawWith(t,{width:c.width,height:c.height,radius:Bn,fill:i||ve}),t.translateWithPrecision(Mt,c.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var $n=Object.getOwnPropertyDescriptor,Hn=(e,t,n,a)=>{for(var r=a>1?void 0:a?$n(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(n,a)=>t(n,a,e);const Yn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let rt=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r){const i=n-pe+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(a-pe)/2+4;break;case o.VerticalAlign.BOTTOM:s=a-pe+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,n,a){var ae,de;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:p=0,downOffset:O=0}=v||{},M=this._ensureMap(d),R=this._generateKey(i,s),y=r.isMergedMainCell?r.mergeInfo.startRow:i,m=r.isMergedMainCell?r.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,m);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const f={startX:h.startX+u,endX:h.endX-S,startY:h.startY+p,endY:h.endY-O},w=f.endX-f.startX,F=f.endY-f.startY,{cl:B}=c||{},j=(ae=typeof B=="object"?B==null?void 0:B.rgb:B)!=null?ae:"#000",W=P.getFontStyleString(c!=null?c:void 0),{vt:A,ht:x}=c||{},k=A!=null?A:o.VerticalAlign.MIDDLE,z=(de=C.getCellValueOrigin(l))!=null?de:"",q=I.parseCellValue(z),te=I.getListWithColorMap(D),K=Ze(q,W,w,F);this._drawDownIcon(e,f,w,F,k),e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,w-pe,F),e.clip(),e.translateWithPrecision(at,Be);let ne=0;switch(k){case o.VerticalAlign.MIDDLE:ne=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ne=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,ne),K.lines.forEach((ue,Q)=>{e.save();const{width:Z,height:le,items:J}=ue;let b=0;switch(x){case o.HorizontalAlign.RIGHT:b=K.contentWidth-Z;break;case o.HorizontalAlign.CENTER:b=(K.contentWidth-Z)/2;break}e.translate(b,Q*(le+bt)),J.forEach($=>{e.save(),e.translateWithPrecision($.left,0),Wn.drawWith(e,{...W,info:$,color:j,fill:te[$.text]}),e.restore()}),e.restore()}),e.restore(),M.set(R,{left:f.startX,top:f.startY,width:K.contentWidth+at+pe,height:K.contentHeight+Be*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:r}=a,{x:i}=e;return i>=r-pe&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};rt=Hn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(P.IRenderManagerService)),Le(3,o.Inject(C.SheetDataValidationModel))],rt);class Xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(rt));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,n,a)=>{for(var r=a>1?void 0:a?zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Te=(e,t)=>(n,a)=>t(n,a,e);const ye=4,Pe=4,se=14,Ge=1,he=6,Re=3,qe=8,Zn="#565656",mt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function ft(e,t,n,a,r,i,s=!0){let c=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-a-l;break;case o.VerticalAlign.MIDDLE:c=(t-a)/2;break;default:c=l;break}c=Math.max(Re,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-n)/2;break;case o.HorizontalAlign.RIGHT:d=e-n;break}return d=Math.max(he,d),{paddingLeft:d,paddingTop:c}}let it=class{constructor(e,t,n,a,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(a-Pe)/2;break;case o.VerticalAlign.BOTTOM:h=a-l-r-Re+(r/2-Pe/2);break;default:h=c+Re+(r/2-Pe/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(mt),e.restore()}drawWith(e,t,n){var te,K,ne,ae,de,ue;const{primaryWithCoord:a,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=a.isMergedMainCell?a.mergeInfo.startRow:r,v=a.isMergedMainCell?a.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,v);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const p=c==null?void 0:c.fontRenderExtension,{leftOffset:O=0,rightOffset:M=0,topOffset:R=0,downOffset:y=0}=p||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const m={startX:d.startX+O,endX:d.endX-M,startY:d.startY+R,endY:d.endY-y},D=m.endX-m.startX,I=m.endY-m.startY,f=this._ensureMap(l),w=this._generateKey(r,i),F=S.getListWithColorMap(u),B=C.getCellValueOrigin(c),j=`${B!=null?B:""}`,W=F[j];let{tb:A,vt:x,ht:k,pd:z}=s||{};A=A!=null?A:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,z=z!=null?z:o.DEFAULT_STYLES.pd;const q=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:Q=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:le=o.DEFAULT_STYLES.pd.r,b:J=o.DEFAULT_STYLES.pd.b}=z,b=D-Q-le-se-4,$=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,b,1/0);$.calculate();const _=$.getTotalWidth(),U=$.getTotalHeight(),{paddingTop:X,paddingLeft:ie}=ft(b,I-Z-J,_,U,x,k,!0);this._drawDownIcon(e,m,D,I,U,x,z),e.save(),e.translateWithPrecision(m.startX+Q,m.startY+Z),e.beginPath(),e.rect(0,0,D-Q-le,I-Z-J),e.clip(),e.translateWithPrecision(0,X),e.save(),e.translateWithPrecision(ie,0),e.beginPath(),e.rect(0,0,b,U),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:b,height:U,color:(te=s==null?void 0:s.cl)==null?void 0:te.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((ne=s==null?void 0:s.ul)!=null&&ne.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},$),e.restore(),e.restore(),f.set(w,{left:m.endX-se+n.rowHeaderWidth,top:m.startY+Z+n.columnHeaderHeight,width:se,height:I-Z-J})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const Q=D-he*2-ye-se-4,Z=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,Q,1/0);Z.calculate();const le=Z.getTotalWidth(),J=Z.getTotalHeight(),b=J+Ge*2,$=Math.max(D-he*2,1),{paddingTop:_}=ft($,I,le,b,x,k);e.translateWithPrecision(he,_),P.Rect.drawWith(e,{width:$,height:b,fill:W||ve,radius:qe}),e.save(),e.translateWithPrecision(ye,Ge),e.beginPath(),e.rect(0,0,Q,J),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:Q,height:J,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((de=s==null?void 0:s.st)!=null&&de.s),underline:!!((ue=s==null?void 0:s.ul)!=null&&ue.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(Q+ye+4,(J-Pe)/2),e.fillStyle=Zn,e.fill(mt),e.restore(),f.set(w,{left:m.startX+he+n.rowHeaderWidth,top:m.startY+_+n.columnHeaderHeight,width:$,height:b})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{t:m=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(R=R!=null?R:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:f=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},w=p-I-f-se-4,F=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,w,1/0);return F.calculate(),F.getTotalHeight()+m+D+Re*2}else{const I=Math.max(p-he*2-ye-se-4,10),f=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,I,1/0);return f.calculate(),f.getTotalHeight()+Re*2+Ge*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{l:m=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};R=R!=null?R:o.WrapStrategy.WRAP;let I=he*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=se+4+D+m;break;case o.DataValidationRenderMode.CUSTOM:I=se+he*2+ye*2+D+m+qe/2+1;break;default:I=se+he*2+ye*2+D+m+qe/2+1}const f=p-I,w=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,f,1/0);return w.calculate(),w.getTotalWidth()+I}isHit(e,t){const{subUnitId:n,row:a,col:r}=t,s=this._ensureMap(n).get(this._generateKey(a,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:v}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Kn([Te(0,o.IUniverInstanceService),Te(1,o.Inject(o.LocaleService)),Te(2,o.ICommandService),Te(3,o.Inject(P.IRenderManagerService)),Te(4,o.Inject(C.SheetDataValidationModel))],it);class Gn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",ke.componentKey);L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,n,a)=>{for(var r=a>1?void 0:a?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(n,a)=>t(n,a,e);let be=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Dt],[Ue,_n],[ke.componentKey,ke],[Ne.componentKey,Ne],...Vn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Jn,qn,Un,Pn,Gn,Xn,jn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};be=ea([Je(0,o.Inject(o.Injector)),Je(1,o.Inject(E.ComponentManager)),Je(2,o.Inject(Y.DataValidatorRegistryService))],be);var ta=Object.getOwnPropertyDescriptor,na=(e,t,n,a)=>{for(var r=a>1?void 0:a?ta(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(n,a)=>t(n,a,e);const aa="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}},L(je,"pluginName",aa),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=na([Qe(1,o.Inject(o.Injector)),Qe(2,o.ICommandService),Qe(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var ra=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,oa=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sa=(e,t,n,a)=>{for(var r=a>1?void 0:a?ia(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(n,a)=>t(n,a,e),Tt=(e,t,n)=>oa(e,typeof t!="symbol"?t+"":t,n);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[De],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(De),this._injector.get(Oe),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}};Tt(exports.UniverSheetsDataValidationUIPlugin,"pluginName",la);Tt(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=sa([o.DependentOn(C.UniverSheetsDataValidationPlugin),et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
|
|
5
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(R=>l.addShape({range:R,style:O,primary:null})))},onMouseLeave:()=>{var R;u(!1),(R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:d==null?void 0:d.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(R=>tt.serializeRange(R)).join(",")}),v?g.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:M,children:g.jsx(ct,{})}):null]})};function Sn(e){const t=E.useDependency(C.SheetDataValidationModel),n=E.useDependency(o.IUniverInstanceService),a=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(ce),s=E.useDependency(o.LocaleService),[c,l]=T.useState([]),{workbook:d}=e,h=E.useObservable(d.activeSheet$,void 0,!0),v=d.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(v,u));const y=t.ruleChange$.subscribe(m=>{m.unitId===v&&m.subUnitId===u&&l(t.getRules(v,u))});return()=>{y.unsubscribe()}},[v,u,t]);const S=async()=>{const y=C.createDefaultNewRule(r),m={unitId:v,subUnitId:u,rule:y};await a.executeCommand(C.AddSheetDataValidationCommand.id,m),i.setActiveRule({unitId:v,subUnitId:u,rule:y})},p=()=>{a.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},M=(y=>{const m=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=m.getActiveSheet(),I=m.getUnitId(),f=D.getSheetId();return y.map(F=>H.checkRangesEditablePermission(r,I,f,F.ranges)?{...F}:{...F,disable:!0})})(c),R=M==null?void 0:M.some(y=>y.disable);return g.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var m;return g.jsx(fn,{unitId:v,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:v,subUnitId:u,rule:y})},rule:y,disable:(m=y.disable)!=null?m:!1},y.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!R?g.jsx(V.Button,{onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=E.useDependency(ce),t=E.useObservable(e.activeRule$,e.activeRule),n=E.useDependency(o.IUniverInstanceService),a=E.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=a==null?void 0:a.activeSheet$)!=null?i:re.of(null)},void 0,void 0,[]);return!a||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(mn,{},t.rule.uid):g.jsx(Sn,{workbook:a})},In=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({...n,formula1:d})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:d=>{a==null||a({...n,formula2:d})}})})]}):g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({formula1:d})}})})};function Cn(e){const{value:t,onChange:n,showError:a,validResult:r}=e,i=E.useDependency(o.LocaleService),s=a?r==null?void 0:r.formula1:"",c=a?r==null?void 0:r.formula2:"",[l,d]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function yn(e){var v;const{unitId:t,subUnitId:n,value:a,onChange:r,showError:i,validResult:s}=e,c=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[d,h]=T.useState(!1);return E.useSidebarClick(u=>{var p;(p=l.current)!=null&&p.isClickOutSide(u)&&h(!1)}),g.jsx(V.FormLayout,{error:c,children:g.jsx(ot.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:(v=a==null?void 0:a.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(a==null?void 0:a.formula1)&&(r==null||r({...a,formula1:S}))},onFocus:()=>h(!0)})})}const Rn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Dn=e=>{const{value:t,onChange:n,disabled:a}=e,[r,i]=T.useState(!1);return g.jsx(V.Dropdown,{align:"start",disabled:a,open:r,onOpenChange:i,overlay:g.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Rn.map(s=>g.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:g.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",V.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(dt,{})]})})},vt=e=>{const{item:t,commonProps:n,className:a}=e,{onItemChange:r,onItemDelete:i}=n;return g.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",a),children:[!t.isRef&&g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Et,{})}),g.jsx(Dn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(ct,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,v]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[p,O]=T.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),R=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),m=E.useDependency(C.DataValidationFormulaController),[D,I]=T.useState(()=>d.split(",")),f=R.getValidatorItem(o.DataValidationType.LIST),[w,F]=T.useState([]),[B,j]=T.useState(""),W=s?i==null?void 0:i.formula1:"",A=T.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),x=E.useObservable(A),k=E.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const b=y.getRuleById(a,r,c),$=b==null?void 0:b.formula1;if(o.isFormulaString($)&&f&&b){const _=await f.getListAsync(b,a,r);F(_)}})()},[y,x,f,c,r,a]),T.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(S(l),O(p))},[p,l]);const[z,q]=T.useState(()=>{const b=h!=="1"?C.deserializeListOptions(l):[],$=d.split(",");return b.map((_,U)=>({label:_,color:$[U]||ve,isRef:!1,id:o.generateRandomId(4)}))}),te=(b,$,_)=>{const U=z.find(X=>X.id===b);U&&(U.label=$,U.color=_,q([...z]))},K=b=>{const $=z.findIndex(_=>_.id===b);$!==-1&&(z.splice($,1),q([...z]))},ne=d.split(","),ae=T.useMemo(()=>w.map((b,$)=>({label:b,color:ne[$]||ve,id:`${$}`,isRef:!0})),[ne,w]),de=(b,$,_)=>{const U=[...D];U[+b]=_,I(U),k({formula1:l,formula2:U.join(",")})},ue=()=>{q([...z,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,$=[];z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:U})=>{U.forEach(X=>{b.has(X)||(b.add(X),$.push({label:X,color:_.color}))})}),k({formula1:C.serializeListOptions($.map(_=>_.label)),formula2:$.map(_=>_.color===ve?"":_.color).join(",")})},[z,k,h,p,D]);const Q=E.useEvent(async b=>{if(!o.isFormulaString(b)){k==null||k({formula1:"",formula2:d});return}m.getFormulaRefCheck(b)?(k==null||k({formula1:o.isFormulaString(b)?b:"",formula2:d}),j("")):(k==null||k({formula1:"",formula2:d}),S("="),j(M.t("dataValidation.validFail.formulaError")))}),Z=T.useRef(null),[le,J]=T.useState(!1);return E.useSidebarClick(b=>{var _;(_=Z.current)!=null&&_.isClickOutSide(b)&&J(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:b=>{v(b),S(p),b==="1"&&k({formula1:p==="="?"":p,formula2:D.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(V.FormLayout,{error:W||B||void 0,children:[g.jsx(ot.FormulaEditor,{ref:Z,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:u,unitId:a,subUnitId:r,isFocus:le,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(b="")=>{const $=(b!=null?b:"").trim();O($),Q($)}}),ae.length>0&&g.jsx("div",{className:"univer-mt-3",children:ae.map(b=>g.jsx(vt,{className:"univer-mb-3",item:b,commonProps:{onItemChange:de}},b.id))})]}):g.jsx(V.FormLayout,{error:W,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(V.DraggableList,{list:z,onListChange:q,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(vt,{item:b,commonProps:{onItemChange:te,onItemDelete:K}},b.id),idKey:"id"}),g.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:ue,children:[g.jsx(wt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Vn=[[C.CUSTOM_FORMULA_INPUT_NAME,yn],[C.BASE_FORMULA_INPUT_NAME,In],[C.LIST_FORMULA_INPUT_NAME,wn],[C.CHECKBOX_FORMULA_INPUT_NAME,Cn]],En="LIST_RENDER_MODE_OPTION_INPUT";function ke(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}ke.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function Ne(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:a.t("dataValidation.showTime.label")})})}Ne.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,a)=>{for(var r=a>1?void 0:a?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(n,a)=>t(n,a,e);const Ae=6;let nt=class{constructor(e,t,n,a,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,v;const{vt:n,ht:a}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(a){case o.HorizontalAlign.LEFT:c=Ae;break;case o.HorizontalAlign.RIGHT:c=Ae+(r-s);break;default:c=Ae+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var d,h,v,u,S,p,O,M,R;const{formula1:a=C.CHECKBOX_FORMULA_1,formula2:r=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=C.getFormulaResult((v=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:v[0]),c=C.getFormulaResult((p=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:p[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(a)?C.getFormulaResult((R=(M=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:M[0])==null?void 0:R[0]):a,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var W,A,x,k;const{style:n,primaryWithCoord:a,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=C.getCellValueOrigin(s.getCellRaw(c,l)),v=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u||!((W=u.skipDefaultFontRender)!=null&&W.call(u,v,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(v,r,i),{formula1:p}=S,O=this._calc(d,n),{a:M,d:R}=e.getTransform(),y=P.fixLineWidthByScale(O.left,M),m=P.fixLineWidthByScale(O.top,R),D=P.Transform.create().composeMatrix({left:y,top:m,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=d.endX-d.startX,f=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,I,f),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const F=((A=n==null?void 0:n.fs)!=null?A:10)*1.6,B=String(h)===String(p),j=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:B,width:F,height:F,fill:(k=(x=n==null?void 0:n.cl)==null?void 0:x.rgb)!=null?k:j}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),r=a.top,i=a.top+a.height,s=a.left,c=a.left+a.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:r,worksheet:i,row:s,col:c}=e,l=C.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(a,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,d,l,{unitId:a,subUnitId:r,row:s,column:c})))return;const{formula1:v,formula2:u}=await this._parseFormula(d,a,r),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};nt=Tn([Ce(0,o.ICommandService),Ce(1,o.IUniverInstanceService),Ce(2,o.Inject(C.DataValidationFormulaService)),Ce(3,o.Inject(o.ThemeService)),Ce(4,o.Inject(P.IRenderManagerService)),Ce(5,o.Inject(C.SheetDataValidationModel))],nt);var On=Object.getOwnPropertyDescriptor,An=(e,t,n,a)=>{for(var r=a>1?void 0:a?On(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ln=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=An([Ln(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class Pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(nt));L(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const xn="data-validation.formula-input";class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",xn);L(this,"optionsInput",Ne.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,Ke=4,bt=4,at=6,Be=6,pe=14;function Nn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Mt*2,{ba:r,bd:i}=n,s=r+i;return{width:a,height:s+kn*2,ba:r}}function Ze(e,t,n,a){const r=pe+at*2,i=n-r,s=a-Be*2,c=e.map(u=>({layout:Nn(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:p,height:O}=S;!l||l.width+p+Ke>i?(l={width:p,height:O,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+Ke}),l.width=l.width+p+Ke)});let h=0,v=0;return d.forEach((u,S)=>{v=Math.max(v,u.width),S===d.length-1?h+=u.height:h+=u.height+bt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+Be*2,calcAutoWidth:v+r}}const Bn=8;class Wn extends P.Shape{static drawWith(t,n){const{fontString:a,info:r,fill:i,color:s}=n,{layout:c,text:l}=r;t.save(),P.Rect.drawWith(t,{width:c.width,height:c.height,radius:Bn,fill:i||ve}),t.translateWithPrecision(Mt,c.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var $n=Object.getOwnPropertyDescriptor,Hn=(e,t,n,a)=>{for(var r=a>1?void 0:a?$n(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(n,a)=>t(n,a,e);const Yn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let rt=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r){const i=n-pe+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(a-pe)/2+4;break;case o.VerticalAlign.BOTTOM:s=a-pe+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,n,a){var ae,de;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:p=0,downOffset:O=0}=v||{},M=this._ensureMap(d),R=this._generateKey(i,s),y=r.isMergedMainCell?r.mergeInfo.startRow:i,m=r.isMergedMainCell?r.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,m);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const f={startX:h.startX+u,endX:h.endX-S,startY:h.startY+p,endY:h.endY-O},w=f.endX-f.startX,F=f.endY-f.startY,{cl:B}=c||{},j=(ae=typeof B=="object"?B==null?void 0:B.rgb:B)!=null?ae:"#000",W=P.getFontStyleString(c!=null?c:void 0),{vt:A,ht:x}=c||{},k=A!=null?A:o.VerticalAlign.MIDDLE,z=(de=C.getCellValueOrigin(l))!=null?de:"",q=I.parseCellValue(z),te=I.getListWithColorMap(D),K=Ze(q,W,w,F);this._drawDownIcon(e,f,w,F,k),e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,w-pe,F),e.clip(),e.translateWithPrecision(at,Be);let ne=0;switch(k){case o.VerticalAlign.MIDDLE:ne=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ne=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,ne),K.lines.forEach((ue,Q)=>{e.save();const{width:Z,height:le,items:J}=ue;let b=0;switch(x){case o.HorizontalAlign.RIGHT:b=K.contentWidth-Z;break;case o.HorizontalAlign.CENTER:b=(K.contentWidth-Z)/2;break}e.translate(b,Q*(le+bt)),J.forEach($=>{e.save(),e.translateWithPrecision($.left,0),Wn.drawWith(e,{...W,info:$,color:j,fill:te[$.text]}),e.restore()}),e.restore()}),e.restore(),M.set(R,{left:f.startX,top:f.startY,width:K.contentWidth+at+pe,height:K.contentHeight+Be*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:r}=a,{x:i}=e;return i>=r-pe&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};rt=Hn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(P.IRenderManagerService)),Le(3,o.Inject(C.SheetDataValidationModel))],rt);class Xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(rt));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,n,a)=>{for(var r=a>1?void 0:a?zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Te=(e,t)=>(n,a)=>t(n,a,e);const ye=4,Pe=4,se=14,Ge=1,he=6,Re=3,qe=8,Zn="#565656",mt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function ft(e,t,n,a,r,i,s=!0){let c=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-a-l;break;case o.VerticalAlign.MIDDLE:c=(t-a)/2;break;default:c=l;break}c=Math.max(Re,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-n)/2;break;case o.HorizontalAlign.RIGHT:d=e-n;break}return d=Math.max(he,d),{paddingLeft:d,paddingTop:c}}let it=class{constructor(e,t,n,a,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(a-Pe)/2;break;case o.VerticalAlign.BOTTOM:h=a-l-r-Re+(r/2-Pe/2);break;default:h=c+Re+(r/2-Pe/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(mt),e.restore()}drawWith(e,t,n){var te,K,ne,ae,de,ue;const{primaryWithCoord:a,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=a.isMergedMainCell?a.mergeInfo.startRow:r,v=a.isMergedMainCell?a.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,v);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const p=c==null?void 0:c.fontRenderExtension,{leftOffset:O=0,rightOffset:M=0,topOffset:R=0,downOffset:y=0}=p||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const m={startX:d.startX+O,endX:d.endX-M,startY:d.startY+R,endY:d.endY-y},D=m.endX-m.startX,I=m.endY-m.startY,f=this._ensureMap(l),w=this._generateKey(r,i),F=S.getListWithColorMap(u),B=C.getCellValueOrigin(c),j=`${B!=null?B:""}`,W=F[j];let{tb:A,vt:x,ht:k,pd:z}=s||{};A=A!=null?A:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,z=z!=null?z:o.DEFAULT_STYLES.pd;const q=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:Q=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:le=o.DEFAULT_STYLES.pd.r,b:J=o.DEFAULT_STYLES.pd.b}=z,b=D-Q-le-se-4,$=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,b,1/0);$.calculate();const _=$.getTotalWidth(),U=$.getTotalHeight(),{paddingTop:X,paddingLeft:ie}=ft(b,I-Z-J,_,U,x,k,!0);this._drawDownIcon(e,m,D,I,U,x,z),e.save(),e.translateWithPrecision(m.startX+Q,m.startY+Z),e.beginPath(),e.rect(0,0,D-Q-le,I-Z-J),e.clip(),e.translateWithPrecision(0,X),e.save(),e.translateWithPrecision(ie,0),e.beginPath(),e.rect(0,0,b,U),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:b,height:U,color:(te=s==null?void 0:s.cl)==null?void 0:te.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((ne=s==null?void 0:s.ul)!=null&&ne.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},$),e.restore(),e.restore(),f.set(w,{left:m.endX-se+n.rowHeaderWidth,top:m.startY+Z+n.columnHeaderHeight,width:se,height:I-Z-J})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const Q=D-he*2-ye-se-4,Z=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,Q,1/0);Z.calculate();const le=Z.getTotalWidth(),J=Z.getTotalHeight(),b=J+Ge*2,$=Math.max(D-he*2,1),{paddingTop:_}=ft($,I,le,b,x,k);e.translateWithPrecision(he,_),P.Rect.drawWith(e,{width:$,height:b,fill:W||ve,radius:qe}),e.save(),e.translateWithPrecision(ye,Ge),e.beginPath(),e.rect(0,0,Q,J),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:Q,height:J,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((de=s==null?void 0:s.st)!=null&&de.s),underline:!!((ue=s==null?void 0:s.ul)!=null&&ue.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(Q+ye+4,(J-Pe)/2),e.fillStyle=Zn,e.fill(mt),e.restore(),f.set(w,{left:m.startX+he+n.rowHeaderWidth,top:m.startY+_+n.columnHeaderHeight,width:$,height:b})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{t:m=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(R=R!=null?R:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:f=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},w=p-I-f-se-4,F=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,w,1/0);return F.calculate(),F.getTotalHeight()+m+D+Re*2}else{const I=Math.max(p-he*2-ye-se-4,10),f=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,I,1/0);return f.calculate(),f.getTotalHeight()+Re*2+Ge*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{l:m=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};R=R!=null?R:o.WrapStrategy.WRAP;let I=he*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=se+4+D+m;break;case o.DataValidationRenderMode.CUSTOM:I=se+he*2+ye*2+D+m+qe/2+1;break;default:I=se+he*2+ye*2+D+m+qe/2+1}const f=p-I,w=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,f,1/0);return w.calculate(),w.getTotalWidth()+I}isHit(e,t){const{subUnitId:n,row:a,col:r}=t,s=this._ensureMap(n).get(this._generateKey(a,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:v}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Kn([Te(0,o.IUniverInstanceService),Te(1,o.Inject(o.LocaleService)),Te(2,o.ICommandService),Te(3,o.Inject(P.IRenderManagerService)),Te(4,o.Inject(C.SheetDataValidationModel))],it);class Gn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",ke.componentKey);L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,n,a)=>{for(var r=a>1?void 0:a?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(n,a)=>t(n,a,e);let be=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Dt],[Ue,_n],[ke.componentKey,ke],[Ne.componentKey,Ne],...Vn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Jn,qn,Un,Pn,Gn,Xn,jn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};be=ea([Je(0,o.Inject(o.Injector)),Je(1,o.Inject(E.ComponentManager)),Je(2,o.Inject(Y.DataValidatorRegistryService))],be);var ta=Object.getOwnPropertyDescriptor,na=(e,t,n,a)=>{for(var r=a>1?void 0:a?ta(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(n,a)=>t(n,a,e);const aa="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}},L(je,"pluginName",aa),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=na([Qe(1,o.Inject(o.Injector)),Qe(2,o.ICommandService),Qe(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var ra=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,oa=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sa=(e,t,n,a)=>{for(var r=a>1?void 0:a?ia(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(n,a)=>t(n,a,e),Tt=(e,t,n)=>oa(e,typeof t!="symbol"?t+"":t,n);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[De],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(De),this._injector.get(Oe),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}};Tt(exports.UniverSheetsDataValidationUIPlugin,"pluginName",la);Tt(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=sa([o.DependentOn(C.UniverSheetsDataValidationPlugin),et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
|
package/lib/es/index.js
CHANGED
|
@@ -2034,7 +2034,7 @@ function _i(e) {
|
|
|
2034
2034
|
const { unitId: t, subUnitId: n, value: r, onChange: o, showError: i, validResult: a } = e, l = i ? a == null ? void 0 : a.formula1 : void 0, s = ht(null), [d, u] = W(!1);
|
|
2035
2035
|
return dr((c) => {
|
|
2036
2036
|
var h;
|
|
2037
|
-
(
|
|
2037
|
+
(h = s.current) != null && h.isClickOutSide(c) && u(!1);
|
|
2038
2038
|
}), /* @__PURE__ */ C(Y, { error: l, children: /* @__PURE__ */ C(
|
|
2039
2039
|
vr,
|
|
2040
2040
|
{
|
|
@@ -2249,7 +2249,7 @@ function Ii(e) {
|
|
|
2249
2249
|
}), Z = ht(null), [ge, z] = W(!1);
|
|
2250
2250
|
return dr((M) => {
|
|
2251
2251
|
var f;
|
|
2252
|
-
(
|
|
2252
|
+
(f = Z.current) != null && f.isClickOutSide(M) && z(!1);
|
|
2253
2253
|
}), /* @__PURE__ */ H(ct, { children: [
|
|
2254
2254
|
/* @__PURE__ */ C(Y, { label: y.t("dataValidation.list.options"), children: /* @__PURE__ */ H(
|
|
2255
2255
|
fn,
|
package/lib/index.js
CHANGED
|
@@ -2034,7 +2034,7 @@ function _i(e) {
|
|
|
2034
2034
|
const { unitId: t, subUnitId: n, value: r, onChange: o, showError: i, validResult: a } = e, l = i ? a == null ? void 0 : a.formula1 : void 0, s = ht(null), [d, u] = W(!1);
|
|
2035
2035
|
return dr((c) => {
|
|
2036
2036
|
var h;
|
|
2037
|
-
(
|
|
2037
|
+
(h = s.current) != null && h.isClickOutSide(c) && u(!1);
|
|
2038
2038
|
}), /* @__PURE__ */ C(Y, { error: l, children: /* @__PURE__ */ C(
|
|
2039
2039
|
vr,
|
|
2040
2040
|
{
|
|
@@ -2249,7 +2249,7 @@ function Ii(e) {
|
|
|
2249
2249
|
}), Z = ht(null), [ge, z] = W(!1);
|
|
2250
2250
|
return dr((M) => {
|
|
2251
2251
|
var f;
|
|
2252
|
-
(
|
|
2252
|
+
(f = Z.current) != null && f.isClickOutSide(M) && z(!1);
|
|
2253
2253
|
}), /* @__PURE__ */ H(ct, { children: [
|
|
2254
2254
|
/* @__PURE__ */ C(Y, { label: y.t("dataValidation.list.options"), children: /* @__PURE__ */ H(
|
|
2255
2255
|
fn,
|
package/lib/umd/index.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
|
|
3
3
|
univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
|
|
4
4
|
univer-rounded-md univer-p-2 univer-pr-9
|
|
5
|
-
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(w=>l.addShape({range:w,style:A,primary:null})))},onMouseLeave:()=>{var w;u(!1),(w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(w=>Ye.serializeRange(w)).join(",")}),g?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:T,children:p.jsx(Qe,{})}):null]})};function fn(e){const t=b.useDependency(C.SheetDataValidationModel),n=b.useDependency(o.IUniverInstanceService),r=b.useDependency(o.ICommandService),a=b.useDependency(o.Injector),i=b.useDependency(de),s=b.useDependency(o.LocaleService),[d,l]=R.useState([]),{workbook:c}=e,h=b.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();R.useEffect(()=>{l(t.getRules(g,u));const y=t.ruleChange$.subscribe(f=>{f.unitId===g&&f.subUnitId===u&&l(t.getRules(g,u))});return()=>{y.unsubscribe()}},[g,u,t]);const S=async()=>{const y=C.createDefaultNewRule(a),f={unitId:g,subUnitId:u,rule:y};await r.executeCommand(C.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:g,subUnitId:u,rule:y})},v=()=>{r.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},T=(y=>{const f=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=f.getActiveSheet(),I=f.getUnitId(),m=D.getSheetId();return y.map(j=>Y.checkRangesEditablePermission(a,I,m,j.ranges)?{...j}:{...j,disable:!0})})(d),w=T==null?void 0:T.some(y=>y.disable);return p.jsxs("div",{className:"univer-pb-4",children:[T==null?void 0:T.map(y=>{var f;return p.jsx(gn,{unitId:g,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:y})},rule:y,disable:(f=y.disable)!=null?f:!1},y.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!w?p.jsx(M.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(M.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const mn=()=>{const e=b.useDependency(de),t=b.useObservable(e.activeRule$,e.activeRule),n=b.useDependency(o.IUniverInstanceService),r=b.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=b.useObservable(()=>{var i;return(i=r==null?void 0:r.activeSheet$)!=null?i:ae.of(null)},void 0,void 0,[]);return!r||!a?null:t&&t.subUnitId===a.getSheetId()?p.jsx(vn,{},t.rule.uid):p.jsx(fn,{workbook:r})},Sn=e=>{const{isTwoFormula:t=!1,value:n,onChange:r,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({...n,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(M.FormLayout,{error:l,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{r==null||r({...n,formula2:c})}})})]}):p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({formula1:c})}})})};function _n(e){const{value:t,onChange:n,showError:r,validResult:a}=e,i=b.useDependency(o.LocaleService),s=r?a==null?void 0:a.formula1:"",d=r?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function In(e){var g;const{unitId:t,subUnitId:n,value:r,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return b.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(M.FormLayout,{error:d,children:p.jsx(Xe.FormulaEditor,{ref:l,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:(g=r==null?void 0:r.formula1)!=null?g:"=",unitId:t,subUnitId:n,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(r==null?void 0:r.formula1)&&(a==null||a({...r,formula1:S}))},onFocus:()=>h(!0)})})}const Cn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],yn=e=>{const{value:t,onChange:n,disabled:r}=e,[a,i]=R.useState(!1);return p.jsx(M.Dropdown,{align:"start",disabled:r,open:a,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Cn.map(s=>p.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:p.jsxs("div",{className:M.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",M.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(et,{})]})})},Et=e=>{const{item:t,commonProps:n,className:r}=e,{onItemChange:a,onItemDelete:i}=n;return p.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",r),children:[!t.isRef&&p.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Dt,{})}),p.jsx(yn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),p.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(Qe,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:r,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=R.useState(h==="1"?l:"="),[v,A]=R.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),w=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),f=b.useDependency(C.DataValidationFormulaController),[D,I]=R.useState(()=>c.split(",")),m=w.getValidatorItem(o.DataValidationType.LIST),[E,j]=R.useState([]),[$,F]=R.useState(""),H=s?i==null?void 0:i.formula1:"",L=R.useMemo(()=>y.ruleChange$.pipe(ae.debounceTime(16)),[]),k=b.useObservable(L),B=b.useEvent(n);R.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const V=y.getRuleById(r,a,d),x=V==null?void 0:V.formula1;if(o.isFormulaString(x)&&m&&V){const _=await m.getListAsync(V,r,a);j(_)}})()},[y,k,m,d,a,r]),R.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(S(l),A(v))},[v,l]);const[K,J]=R.useState(()=>{const V=h!=="1"?C.deserializeListOptions(l):[],x=c.split(",");return V.map((_,N)=>({label:_,color:x[N]||ve,isRef:!1,id:o.generateRandomId(4)}))}),ne=(V,x,_)=>{const N=K.find(z=>z.id===V);N&&(N.label=x,N.color=_,J([...K]))},Z=V=>{const x=K.findIndex(_=>_.id===V);x!==-1&&(K.splice(x,1),J([...K]))},re=c.split(","),ie=R.useMemo(()=>E.map((V,x)=>({label:V,color:re[x]||ve,id:`${x}`,isRef:!0})),[re,E]),he=(V,x,_)=>{const N=[...D];N[+V]=_,I(N),B({formula1:l,formula2:N.join(",")})},pe=()=>{J([...K,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const V=new Set,x=[];K.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:N})=>{N.forEach(z=>{V.has(z)||(V.add(z),x.push({label:z,color:_.color}))})}),B({formula1:C.serializeListOptions(x.map(_=>_.label)),formula2:x.map(_=>_.color===ve?"":_.color).join(",")})},[K,B,h,v,D]);const ee=b.useEvent(async V=>{if(!o.isFormulaString(V)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(V)?(B==null||B({formula1:o.isFormulaString(V)?V:"",formula2:c}),F("")):(B==null||B({formula1:"",formula2:c}),S("="),F(T.t("dataValidation.validFail.formulaError")))}),q=R.useRef(null),[ce,Q]=R.useState(!1);return b.useSidebarClick(V=>{var _;((_=q.current)==null?void 0:_.isClickOutSide(V))&&Q(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:p.jsxs(M.RadioGroup,{value:h,onChange:V=>{g(V),S(v),V==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),p.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(M.FormLayout,{error:H||$||void 0,children:[p.jsx(Xe.FormulaEditor,{ref:q,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:u,unitId:r,subUnitId:a,isFocus:ce,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(V="")=>{const x=(V!=null?V:"").trim();A(x),ee(x)}}),ie.length>0&&p.jsx("div",{className:"univer-mt-3",children:ie.map(V=>p.jsx(Et,{className:"univer-mb-3",item:V,commonProps:{onItemChange:he}},V.id))})]}):p.jsx(M.FormLayout,{error:H,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(M.DraggableList,{list:K,onListChange:J,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:V=>p.jsx(Et,{item:V,commonProps:{onItemChange:ne,onItemDelete:Z}},V.id),idKey:"id"}),p.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:pe,children:[p.jsx(yt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Dn=[[C.CUSTOM_FORMULA_INPUT_NAME,In],[C.BASE_FORMULA_INPUT_NAME,Sn],[C.LIST_FORMULA_INPUT_NAME,wn],[C.CHECKBOX_FORMULA_INPUT_NAME,_n]],En="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var a;const{value:t,onChange:n}=e,r=b.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{label:r.t("dataValidation.renderMode.label"),children:p.jsxs(M.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:r.t("dataValidation.renderMode.chip")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:r.t("dataValidation.renderMode.arrow")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:r.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function je(e){var a;const{value:t,onChange:n}=e,r=b.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:r.t("dataValidation.showTime.label")})})}je.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,r)=>{for(var a=r>1?void 0:r?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},be=(e,t)=>(n,r)=>t(n,r,e);const Be=6;let tt=class{constructor(e,t,n,r,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,g;const{vt:n,ht:r}=t||{},a=e.endX-e.startX-Be*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(r){case o.HorizontalAlign.LEFT:d=Be;break;case o.HorizontalAlign.RIGHT:d=Be+(a-s);break;default:d=Be+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,g,u,S,v,A,T,w;const{formula1:r=C.CHECKBOX_FORMULA_1,formula2:a=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=C.getFormulaResult((g=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=C.getFormulaResult((v=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:v[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(r)?C.getFormulaResult((w=(T=(A=i==null?void 0:i[0])==null?void 0:A.result)==null?void 0:T[0])==null?void 0:w[0]):r,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var H,L,k,B;const{style:n,primaryWithCoord:r,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=C.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((H=u.skipDefaultFontRender)!=null&&H.call(u,g,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(g,a,i),{formula1:v}=S,A=this._calc(c,n),{a:T,d:w}=e.getTransform(),y=O.fixLineWidthByScale(A.left,T),f=O.fixLineWidthByScale(A.top,w),D=O.Transform.create().composeMatrix({left:y,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=c.endX-c.startX,m=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,I,m),e.clip();const E=D.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);const j=((L=n==null?void 0:n.fs)!=null?L:10)*1.6,$=String(h)===String(v),F=this._themeService.getColorFromTheme("primary.600");O.CheckboxShape.drawWith(e,{checked:$,width:j,height:j,fill:(B=(k=n==null?void 0:n.cl)==null?void 0:k.rgb)!=null?B:F}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),a=r.top,i=r.top+r.height,s=r.left,d=r.left+r.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:n,unitId:r,subUnitId:a,worksheet:i,row:s,col:d}=e,l=C.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(r,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:r,subUnitId:a,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,r,a),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};tt=Tn([be(0,o.ICommandService),be(1,o.IUniverInstanceService),be(2,o.Inject(C.DataValidationFormulaService)),be(3,o.Inject(o.ThemeService)),be(4,o.Inject(O.IRenderManagerService)),be(5,o.Inject(C.SheetDataValidationModel))],tt);var Vn=Object.getOwnPropertyDescriptor,Rn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Vn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},On=(e,t)=>(n,r)=>t(n,r,e);U.BaseSheetDataValidatorView=class{constructor(t){P(this,"canvasRender",null);P(this,"dropdownType");P(this,"optionsInput");P(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Rn([On(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class An extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(tt));P(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class Ln extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CUSTOM);P(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const Pn="data-validation.formula-input";class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DATE);P(this,"formulaInput",Pn);P(this,"optionsInput",je.componentKey);P(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DECIMAL);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,nt=4,bt=4,rt=6,We=6,_e=14;function Nn(e,t){const n=O.FontCache.getTextSize(e,t),r=n.width+Mt*2,{ba:a,bd:i}=n,s=a+i;return{width:r,height:s+kn*2,ba:a}}function at(e,t,n,r){const a=_e+rt*2,i=n-a,s=r-We*2,d=e.map(u=>({layout:Nn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:v,height:A}=S;!l||l.width+v+nt>i?(l={width:v,height:A,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+nt}),l.width=l.width+v+nt)});let h=0,g=0;return c.forEach((u,S)=>{g=Math.max(g,u.width),S===c.length-1?h+=u.height:h+=u.height+bt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:g+a}}const jn=8;class Bn extends O.Shape{static drawWith(t,n){const{fontString:r,info:a,fill:i,color:s}=n,{layout:d,text:l}=a;t.save(),O.Rect.drawWith(t,{width:d.width,height:d.height,radius:jn,fill:i||ve}),t.translateWithPrecision(Mt,d.ba),t.font=r,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Wn=Object.getOwnPropertyDescriptor,$n=(e,t,n,r)=>{for(var a=r>1?void 0:r?Wn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},$e=(e,t)=>(n,r)=>t(n,r,e);const Hn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let it=class{constructor(e,t,n,r){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a){const i=n-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(r-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=r-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Hn),e.restore()}drawWith(e,t,n,r){var ie,he;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:v=0,downOffset:A=0}=g||{},T=this._ensureMap(c),w=this._generateKey(i,s),y=a.isMergedMainCell?a.mergeInfo.startRow:i,f=a.isMergedMainCell?a.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,f);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const m={startX:h.startX+u,endX:h.endX-S,startY:h.startY+v,endY:h.endY-A},E=m.endX-m.startX,j=m.endY-m.startY,{cl:$}=d||{},F=(ie=typeof $=="object"?$==null?void 0:$.rgb:$)!=null?ie:"#000",H=O.getFontStyleString(d!=null?d:void 0),{vt:L,ht:k}=d||{},B=L!=null?L:o.VerticalAlign.MIDDLE,K=(he=C.getCellValueOrigin(l))!=null?he:"",J=I.parseCellValue(K),ne=I.getListWithColorMap(D),Z=at(J,H,E,j);this._drawDownIcon(e,m,E,j,B),e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,E-_e,j),e.clip(),e.translateWithPrecision(rt,We);let re=0;switch(B){case o.VerticalAlign.MIDDLE:re=(Z.contentHeight-Z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:re=Z.contentHeight-Z.totalHeight;break}e.translateWithPrecision(0,re),Z.lines.forEach((pe,ee)=>{e.save();const{width:q,height:ce,items:Q}=pe;let V=0;switch(k){case o.HorizontalAlign.RIGHT:V=Z.contentWidth-q;break;case o.HorizontalAlign.CENTER:V=(Z.contentWidth-q)/2;break}e.translate(V,ee*(ce+bt)),Q.forEach(x=>{e.save(),e.translateWithPrecision(x.left,0),Bn.drawWith(e,{...H,info:x,color:F,fill:ne[x.text]}),e.restore()}),e.restore()}),e.restore(),T.set(w,{left:m.startX,top:m.startY,width:Z.contentWidth+rt+_e,height:Z.contentHeight+We*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const A=u.endX-u.startX,T=u.endY-u.startY,w=(I=C.getCellValueOrigin(r))!=null?I:"",y=v.parseCellValue(w),f=O.getFontStyleString(n!=null?n:void 0);return at(y,f,A,T).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const A=u.endX-u.startX,T=u.endY-u.startY,w=(I=C.getCellValueOrigin(r))!=null?I:"",y=v.parseCellValue(w),f=O.getFontStyleString(n!=null?n:void 0);return at(y,f,A,T).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,r=n.isMergedMainCell?n.mergeInfo:n,{endX:a}=r,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.DEFAULT)}};it=$n([$e(0,o.ICommandService),$e(1,o.IUniverInstanceService),$e(2,o.Inject(O.IRenderManagerService)),$e(3,o.Inject(C.SheetDataValidationModel))],it);class xn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(it));P(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Yn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(n,r)=>t(n,r,e);const Te=4,He=4,se=14,ot=1,ue=6,Ve=3,st=8,zn="#565656",Tt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Vt(e,t,n,r,a,i,s=!0){let d=0;const l=s?Ve:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-r-l;break;case o.VerticalAlign.MIDDLE:d=(t-r)/2;break;default:d=l;break}d=Math.max(Ve,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-n)/2;break;case o.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let lt=class{constructor(e,t,n,r,a){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(r-He)/2;break;case o.VerticalAlign.BOTTOM:h=r-l-a-Ve+(a/2-He/2);break;default:h=d+Ve+(a/2-He/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Tt),e.restore()}drawWith(e,t,n){var ne,Z,re,ie,he,pe;const{primaryWithCoord:r,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=r.isMergedMainCell?r.mergeInfo.startRow:a,g=r.isMergedMainCell?r.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,g);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const v=d==null?void 0:d.fontRenderExtension,{leftOffset:A=0,rightOffset:T=0,topOffset:w=0,downOffset:y=0}=v||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const f={startX:c.startX+A,endX:c.endX-T,startY:c.startY+w,endY:c.endY-y},D=f.endX-f.startX,I=f.endY-f.startY,m=this._ensureMap(l),E=this._generateKey(a,i),j=S.getListWithColorMap(u),$=C.getCellValueOrigin(d),F=`${$!=null?$:""}`,H=j[F];let{tb:L,vt:k,ht:B,pd:K}=s||{};L=L!=null?L:o.WrapStrategy.WRAP,k=k!=null?k:o.VerticalAlign.BOTTOM,B=B!=null?B:o.DEFAULT_STYLES.ht,K=K!=null?K:o.DEFAULT_STYLES.pd;const J=O.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:ee=o.DEFAULT_STYLES.pd.l,t:q=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:Q=o.DEFAULT_STYLES.pd.b}=K,V=D-ee-ce-se-4,x=new O.DocSimpleSkeleton(F,J,L===o.WrapStrategy.WRAP,V,1/0);x.calculate();const _=x.getTotalWidth(),N=x.getTotalHeight(),{paddingTop:z,paddingLeft:le}=Vt(V,I-q-Q,_,N,k,B,!0);this._drawDownIcon(e,f,D,I,N,k,K),e.save(),e.translateWithPrecision(f.startX+ee,f.startY+q),e.beginPath(),e.rect(0,0,D-ee-ce,I-q-Q),e.clip(),e.translateWithPrecision(0,z),e.save(),e.translateWithPrecision(le,0),e.beginPath(),e.rect(0,0,V,N),e.clip(),O.Text.drawWith(e,{text:F,fontStyle:J,width:V,height:N,color:(ne=s==null?void 0:s.cl)==null?void 0:ne.rgb,strokeLine:!!((Z=s==null?void 0:s.st)!=null&&Z.s),underline:!!((re=s==null?void 0:s.ul)!=null&&re.s),warp:L===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},x),e.restore(),e.restore(),m.set(E,{left:f.endX-se+n.rowHeaderWidth,top:f.startY+q+n.columnHeaderHeight,width:se,height:I-q-Q})}else{e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const ee=D-ue*2-Te-se-4,q=new O.DocSimpleSkeleton(F,J,L===o.WrapStrategy.WRAP,ee,1/0);q.calculate();const ce=q.getTotalWidth(),Q=q.getTotalHeight(),V=Q+ot*2,x=Math.max(D-ue*2,1),{paddingTop:_}=Vt(x,I,ce,V,k,B);e.translateWithPrecision(ue,_),O.Rect.drawWith(e,{width:x,height:V,fill:H||ve,radius:st}),e.save(),e.translateWithPrecision(Te,ot),e.beginPath(),e.rect(0,0,ee,Q),e.clip(),O.Text.drawWith(e,{text:F,fontStyle:J,width:ee,height:Q,color:(ie=s==null?void 0:s.cl)==null?void 0:ie.rgb,strokeLine:!!((he=s==null?void 0:s.st)!=null&&he.s),underline:!!((pe=s==null?void 0:s.ul)!=null&&pe.s),warp:L===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},q),e.restore(),e.translateWithPrecision(ee+Te+4,(Q-He)/2),e.fillStyle=zn,e.fill(Tt),e.restore(),m.set(E,{left:f.startX+ue+n.rowHeaderWidth,top:f.startY+_+n.columnHeaderHeight,width:x,height:V})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,A=C.getCellValueOrigin(r),T=`${A!=null?A:""}`;let{tb:w,pd:y}=n||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(w=w!=null?w:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:m=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},E=v-I-m-se-4,j=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,E,1/0);return j.calculate(),j.getTotalHeight()+f+D+Ve*2}else{const I=Math.max(v-ue*2-Te-se-4,10),m=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,I,1/0);return m.calculate(),m.getTotalHeight()+Ve*2+ot*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,A=C.getCellValueOrigin(r),T=`${A!=null?A:""}`;let{tb:w,pd:y}=n||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};w=w!=null?w:o.WrapStrategy.WRAP;let I=ue*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=se+4+D+f;break;case o.DataValidationRenderMode.CUSTOM:I=se+ue*2+Te*2+D+f+st/2+1;break;default:I=se+ue*2+Te*2+D+f+st/2+1}const m=v-I,E=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,m,1/0);return E.calculate(),E.getTotalWidth()+I}isHit(e,t){const{subUnitId:n,row:r,col:a}=t,s=this._ensureMap(n).get(this._generateKey(r,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};lt=Xn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(O.IRenderManagerService)),Ae(4,o.Inject(C.SheetDataValidationModel))],lt);class Kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(lt));P(this,"dropdownType",X.DataValidatorDropdownType.LIST);P(this,"optionsInput",Ne.componentKey);P(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class Zn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class Gn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.WHOLE);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var qn=Object.getOwnPropertyDescriptor,Jn=(e,t,n,r)=>{for(var a=r>1?void 0:r?qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},dt=(e,t)=>(n,r)=>t(n,r,e);let Re=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Ct],[Pe,mn],[Ne.componentKey,Ne],[je.componentKey,je],...Dn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Gn,Zn,Un,An,Kn,xn,Ln].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Re=Jn([dt(0,o.Inject(o.Injector)),dt(1,o.Inject(b.ComponentManager)),dt(2,o.Inject(X.DataValidatorRegistryService))],Re);var Qn=Object.getOwnPropertyDescriptor,er=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(n,r)=>t(n,r,e);const tr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(xe=class extends o.Plugin{constructor(t=Le,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ze,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Re]].forEach(t=>{this._injector.add(t)}),[Fe,Ue,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},P(xe,"pluginName",tr),P(xe,"type",o.UniverInstanceType.UNIVER_SHEET),xe),U.UniverSheetsDataValidationMobileUIPlugin=er([ct(1,o.Inject(o.Injector)),ct(2,o.ICommandService),ct(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ar=(e,t,n)=>t in e?nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ir=(e,t,n,r)=>{for(var a=r>1?void 0:r?rr(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(n,r)=>t(n,r,e),Rt=(e,t,n)=>ar(e,typeof t!="symbol"?t+"":t,n);const or="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Le,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ze,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Ce],[Re]].forEach(t=>{this._injector.add(t)}),[Fe,Ue,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(Ce),this._injector.get(Oe),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},Rt(U.UniverSheetsDataValidationUIPlugin,"pluginName",or),Rt(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=ir([o.DependentOn(C.UniverSheetsDataValidationPlugin),ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
|
5
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(w=>l.addShape({range:w,style:A,primary:null})))},onMouseLeave:()=>{var w;u(!1),(w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(w=>Ye.serializeRange(w)).join(",")}),g?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:T,children:p.jsx(Qe,{})}):null]})};function fn(e){const t=b.useDependency(C.SheetDataValidationModel),n=b.useDependency(o.IUniverInstanceService),r=b.useDependency(o.ICommandService),a=b.useDependency(o.Injector),i=b.useDependency(de),s=b.useDependency(o.LocaleService),[d,l]=R.useState([]),{workbook:c}=e,h=b.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();R.useEffect(()=>{l(t.getRules(g,u));const y=t.ruleChange$.subscribe(f=>{f.unitId===g&&f.subUnitId===u&&l(t.getRules(g,u))});return()=>{y.unsubscribe()}},[g,u,t]);const S=async()=>{const y=C.createDefaultNewRule(a),f={unitId:g,subUnitId:u,rule:y};await r.executeCommand(C.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:g,subUnitId:u,rule:y})},v=()=>{r.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},T=(y=>{const f=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=f.getActiveSheet(),I=f.getUnitId(),m=D.getSheetId();return y.map(j=>Y.checkRangesEditablePermission(a,I,m,j.ranges)?{...j}:{...j,disable:!0})})(d),w=T==null?void 0:T.some(y=>y.disable);return p.jsxs("div",{className:"univer-pb-4",children:[T==null?void 0:T.map(y=>{var f;return p.jsx(gn,{unitId:g,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:y})},rule:y,disable:(f=y.disable)!=null?f:!1},y.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!w?p.jsx(M.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(M.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const mn=()=>{const e=b.useDependency(de),t=b.useObservable(e.activeRule$,e.activeRule),n=b.useDependency(o.IUniverInstanceService),r=b.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=b.useObservable(()=>{var i;return(i=r==null?void 0:r.activeSheet$)!=null?i:ae.of(null)},void 0,void 0,[]);return!r||!a?null:t&&t.subUnitId===a.getSheetId()?p.jsx(vn,{},t.rule.uid):p.jsx(fn,{workbook:r})},Sn=e=>{const{isTwoFormula:t=!1,value:n,onChange:r,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({...n,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(M.FormLayout,{error:l,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{r==null||r({...n,formula2:c})}})})]}):p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({formula1:c})}})})};function _n(e){const{value:t,onChange:n,showError:r,validResult:a}=e,i=b.useDependency(o.LocaleService),s=r?a==null?void 0:a.formula1:"",d=r?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function In(e){var g;const{unitId:t,subUnitId:n,value:r,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return b.useSidebarClick(u=>{var v;(v=l.current)!=null&&v.isClickOutSide(u)&&h(!1)}),p.jsx(M.FormLayout,{error:d,children:p.jsx(Xe.FormulaEditor,{ref:l,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:(g=r==null?void 0:r.formula1)!=null?g:"=",unitId:t,subUnitId:n,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(r==null?void 0:r.formula1)&&(a==null||a({...r,formula1:S}))},onFocus:()=>h(!0)})})}const Cn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],yn=e=>{const{value:t,onChange:n,disabled:r}=e,[a,i]=R.useState(!1);return p.jsx(M.Dropdown,{align:"start",disabled:r,open:a,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Cn.map(s=>p.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:p.jsxs("div",{className:M.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",M.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(et,{})]})})},Et=e=>{const{item:t,commonProps:n,className:r}=e,{onItemChange:a,onItemDelete:i}=n;return p.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",r),children:[!t.isRef&&p.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Dt,{})}),p.jsx(yn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),p.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(Qe,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:r,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=R.useState(h==="1"?l:"="),[v,A]=R.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),w=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),f=b.useDependency(C.DataValidationFormulaController),[D,I]=R.useState(()=>c.split(",")),m=w.getValidatorItem(o.DataValidationType.LIST),[E,j]=R.useState([]),[$,F]=R.useState(""),H=s?i==null?void 0:i.formula1:"",L=R.useMemo(()=>y.ruleChange$.pipe(ae.debounceTime(16)),[]),k=b.useObservable(L),B=b.useEvent(n);R.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const V=y.getRuleById(r,a,d),x=V==null?void 0:V.formula1;if(o.isFormulaString(x)&&m&&V){const _=await m.getListAsync(V,r,a);j(_)}})()},[y,k,m,d,a,r]),R.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(S(l),A(v))},[v,l]);const[K,J]=R.useState(()=>{const V=h!=="1"?C.deserializeListOptions(l):[],x=c.split(",");return V.map((_,N)=>({label:_,color:x[N]||ve,isRef:!1,id:o.generateRandomId(4)}))}),ne=(V,x,_)=>{const N=K.find(z=>z.id===V);N&&(N.label=x,N.color=_,J([...K]))},Z=V=>{const x=K.findIndex(_=>_.id===V);x!==-1&&(K.splice(x,1),J([...K]))},re=c.split(","),ie=R.useMemo(()=>E.map((V,x)=>({label:V,color:re[x]||ve,id:`${x}`,isRef:!0})),[re,E]),he=(V,x,_)=>{const N=[...D];N[+V]=_,I(N),B({formula1:l,formula2:N.join(",")})},pe=()=>{J([...K,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const V=new Set,x=[];K.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:N})=>{N.forEach(z=>{V.has(z)||(V.add(z),x.push({label:z,color:_.color}))})}),B({formula1:C.serializeListOptions(x.map(_=>_.label)),formula2:x.map(_=>_.color===ve?"":_.color).join(",")})},[K,B,h,v,D]);const ee=b.useEvent(async V=>{if(!o.isFormulaString(V)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(V)?(B==null||B({formula1:o.isFormulaString(V)?V:"",formula2:c}),F("")):(B==null||B({formula1:"",formula2:c}),S("="),F(T.t("dataValidation.validFail.formulaError")))}),q=R.useRef(null),[ce,Q]=R.useState(!1);return b.useSidebarClick(V=>{var _;(_=q.current)!=null&&_.isClickOutSide(V)&&Q(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:p.jsxs(M.RadioGroup,{value:h,onChange:V=>{g(V),S(v),V==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),p.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(M.FormLayout,{error:H||$||void 0,children:[p.jsx(Xe.FormulaEditor,{ref:q,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:u,unitId:r,subUnitId:a,isFocus:ce,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(V="")=>{const x=(V!=null?V:"").trim();A(x),ee(x)}}),ie.length>0&&p.jsx("div",{className:"univer-mt-3",children:ie.map(V=>p.jsx(Et,{className:"univer-mb-3",item:V,commonProps:{onItemChange:he}},V.id))})]}):p.jsx(M.FormLayout,{error:H,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(M.DraggableList,{list:K,onListChange:J,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:V=>p.jsx(Et,{item:V,commonProps:{onItemChange:ne,onItemDelete:Z}},V.id),idKey:"id"}),p.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:pe,children:[p.jsx(yt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Dn=[[C.CUSTOM_FORMULA_INPUT_NAME,In],[C.BASE_FORMULA_INPUT_NAME,Sn],[C.LIST_FORMULA_INPUT_NAME,wn],[C.CHECKBOX_FORMULA_INPUT_NAME,_n]],En="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var a;const{value:t,onChange:n}=e,r=b.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{label:r.t("dataValidation.renderMode.label"),children:p.jsxs(M.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:r.t("dataValidation.renderMode.chip")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:r.t("dataValidation.renderMode.arrow")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:r.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function je(e){var a;const{value:t,onChange:n}=e,r=b.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:r.t("dataValidation.showTime.label")})})}je.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,r)=>{for(var a=r>1?void 0:r?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},be=(e,t)=>(n,r)=>t(n,r,e);const Be=6;let tt=class{constructor(e,t,n,r,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,g;const{vt:n,ht:r}=t||{},a=e.endX-e.startX-Be*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(r){case o.HorizontalAlign.LEFT:d=Be;break;case o.HorizontalAlign.RIGHT:d=Be+(a-s);break;default:d=Be+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,g,u,S,v,A,T,w;const{formula1:r=C.CHECKBOX_FORMULA_1,formula2:a=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=C.getFormulaResult((g=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=C.getFormulaResult((v=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:v[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(r)?C.getFormulaResult((w=(T=(A=i==null?void 0:i[0])==null?void 0:A.result)==null?void 0:T[0])==null?void 0:w[0]):r,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var H,L,k,B;const{style:n,primaryWithCoord:r,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=C.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((H=u.skipDefaultFontRender)!=null&&H.call(u,g,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(g,a,i),{formula1:v}=S,A=this._calc(c,n),{a:T,d:w}=e.getTransform(),y=O.fixLineWidthByScale(A.left,T),f=O.fixLineWidthByScale(A.top,w),D=O.Transform.create().composeMatrix({left:y,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=c.endX-c.startX,m=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,I,m),e.clip();const E=D.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);const j=((L=n==null?void 0:n.fs)!=null?L:10)*1.6,$=String(h)===String(v),F=this._themeService.getColorFromTheme("primary.600");O.CheckboxShape.drawWith(e,{checked:$,width:j,height:j,fill:(B=(k=n==null?void 0:n.cl)==null?void 0:k.rgb)!=null?B:F}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),a=r.top,i=r.top+r.height,s=r.left,d=r.left+r.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:n,unitId:r,subUnitId:a,worksheet:i,row:s,col:d}=e,l=C.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(r,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:r,subUnitId:a,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,r,a),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};tt=Tn([be(0,o.ICommandService),be(1,o.IUniverInstanceService),be(2,o.Inject(C.DataValidationFormulaService)),be(3,o.Inject(o.ThemeService)),be(4,o.Inject(O.IRenderManagerService)),be(5,o.Inject(C.SheetDataValidationModel))],tt);var Vn=Object.getOwnPropertyDescriptor,Rn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Vn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},On=(e,t)=>(n,r)=>t(n,r,e);U.BaseSheetDataValidatorView=class{constructor(t){P(this,"canvasRender",null);P(this,"dropdownType");P(this,"optionsInput");P(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Rn([On(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class An extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(tt));P(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class Ln extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CUSTOM);P(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const Pn="data-validation.formula-input";class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DATE);P(this,"formulaInput",Pn);P(this,"optionsInput",je.componentKey);P(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DECIMAL);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,nt=4,bt=4,rt=6,We=6,_e=14;function Nn(e,t){const n=O.FontCache.getTextSize(e,t),r=n.width+Mt*2,{ba:a,bd:i}=n,s=a+i;return{width:r,height:s+kn*2,ba:a}}function at(e,t,n,r){const a=_e+rt*2,i=n-a,s=r-We*2,d=e.map(u=>({layout:Nn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:v,height:A}=S;!l||l.width+v+nt>i?(l={width:v,height:A,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+nt}),l.width=l.width+v+nt)});let h=0,g=0;return c.forEach((u,S)=>{g=Math.max(g,u.width),S===c.length-1?h+=u.height:h+=u.height+bt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:g+a}}const jn=8;class Bn extends O.Shape{static drawWith(t,n){const{fontString:r,info:a,fill:i,color:s}=n,{layout:d,text:l}=a;t.save(),O.Rect.drawWith(t,{width:d.width,height:d.height,radius:jn,fill:i||ve}),t.translateWithPrecision(Mt,d.ba),t.font=r,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Wn=Object.getOwnPropertyDescriptor,$n=(e,t,n,r)=>{for(var a=r>1?void 0:r?Wn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},$e=(e,t)=>(n,r)=>t(n,r,e);const Hn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let it=class{constructor(e,t,n,r){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a){const i=n-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(r-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=r-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Hn),e.restore()}drawWith(e,t,n,r){var ie,he;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:v=0,downOffset:A=0}=g||{},T=this._ensureMap(c),w=this._generateKey(i,s),y=a.isMergedMainCell?a.mergeInfo.startRow:i,f=a.isMergedMainCell?a.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,f);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const m={startX:h.startX+u,endX:h.endX-S,startY:h.startY+v,endY:h.endY-A},E=m.endX-m.startX,j=m.endY-m.startY,{cl:$}=d||{},F=(ie=typeof $=="object"?$==null?void 0:$.rgb:$)!=null?ie:"#000",H=O.getFontStyleString(d!=null?d:void 0),{vt:L,ht:k}=d||{},B=L!=null?L:o.VerticalAlign.MIDDLE,K=(he=C.getCellValueOrigin(l))!=null?he:"",J=I.parseCellValue(K),ne=I.getListWithColorMap(D),Z=at(J,H,E,j);this._drawDownIcon(e,m,E,j,B),e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,E-_e,j),e.clip(),e.translateWithPrecision(rt,We);let re=0;switch(B){case o.VerticalAlign.MIDDLE:re=(Z.contentHeight-Z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:re=Z.contentHeight-Z.totalHeight;break}e.translateWithPrecision(0,re),Z.lines.forEach((pe,ee)=>{e.save();const{width:q,height:ce,items:Q}=pe;let V=0;switch(k){case o.HorizontalAlign.RIGHT:V=Z.contentWidth-q;break;case o.HorizontalAlign.CENTER:V=(Z.contentWidth-q)/2;break}e.translate(V,ee*(ce+bt)),Q.forEach(x=>{e.save(),e.translateWithPrecision(x.left,0),Bn.drawWith(e,{...H,info:x,color:F,fill:ne[x.text]}),e.restore()}),e.restore()}),e.restore(),T.set(w,{left:m.startX,top:m.startY,width:Z.contentWidth+rt+_e,height:Z.contentHeight+We*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const A=u.endX-u.startX,T=u.endY-u.startY,w=(I=C.getCellValueOrigin(r))!=null?I:"",y=v.parseCellValue(w),f=O.getFontStyleString(n!=null?n:void 0);return at(y,f,A,T).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const A=u.endX-u.startX,T=u.endY-u.startY,w=(I=C.getCellValueOrigin(r))!=null?I:"",y=v.parseCellValue(w),f=O.getFontStyleString(n!=null?n:void 0);return at(y,f,A,T).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,r=n.isMergedMainCell?n.mergeInfo:n,{endX:a}=r,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.DEFAULT)}};it=$n([$e(0,o.ICommandService),$e(1,o.IUniverInstanceService),$e(2,o.Inject(O.IRenderManagerService)),$e(3,o.Inject(C.SheetDataValidationModel))],it);class xn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(it));P(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Yn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(n,r)=>t(n,r,e);const Te=4,He=4,se=14,ot=1,ue=6,Ve=3,st=8,zn="#565656",Tt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Vt(e,t,n,r,a,i,s=!0){let d=0;const l=s?Ve:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-r-l;break;case o.VerticalAlign.MIDDLE:d=(t-r)/2;break;default:d=l;break}d=Math.max(Ve,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-n)/2;break;case o.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let lt=class{constructor(e,t,n,r,a){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(r-He)/2;break;case o.VerticalAlign.BOTTOM:h=r-l-a-Ve+(a/2-He/2);break;default:h=d+Ve+(a/2-He/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Tt),e.restore()}drawWith(e,t,n){var ne,Z,re,ie,he,pe;const{primaryWithCoord:r,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=r.isMergedMainCell?r.mergeInfo.startRow:a,g=r.isMergedMainCell?r.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,g);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const v=d==null?void 0:d.fontRenderExtension,{leftOffset:A=0,rightOffset:T=0,topOffset:w=0,downOffset:y=0}=v||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const f={startX:c.startX+A,endX:c.endX-T,startY:c.startY+w,endY:c.endY-y},D=f.endX-f.startX,I=f.endY-f.startY,m=this._ensureMap(l),E=this._generateKey(a,i),j=S.getListWithColorMap(u),$=C.getCellValueOrigin(d),F=`${$!=null?$:""}`,H=j[F];let{tb:L,vt:k,ht:B,pd:K}=s||{};L=L!=null?L:o.WrapStrategy.WRAP,k=k!=null?k:o.VerticalAlign.BOTTOM,B=B!=null?B:o.DEFAULT_STYLES.ht,K=K!=null?K:o.DEFAULT_STYLES.pd;const J=O.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:ee=o.DEFAULT_STYLES.pd.l,t:q=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:Q=o.DEFAULT_STYLES.pd.b}=K,V=D-ee-ce-se-4,x=new O.DocSimpleSkeleton(F,J,L===o.WrapStrategy.WRAP,V,1/0);x.calculate();const _=x.getTotalWidth(),N=x.getTotalHeight(),{paddingTop:z,paddingLeft:le}=Vt(V,I-q-Q,_,N,k,B,!0);this._drawDownIcon(e,f,D,I,N,k,K),e.save(),e.translateWithPrecision(f.startX+ee,f.startY+q),e.beginPath(),e.rect(0,0,D-ee-ce,I-q-Q),e.clip(),e.translateWithPrecision(0,z),e.save(),e.translateWithPrecision(le,0),e.beginPath(),e.rect(0,0,V,N),e.clip(),O.Text.drawWith(e,{text:F,fontStyle:J,width:V,height:N,color:(ne=s==null?void 0:s.cl)==null?void 0:ne.rgb,strokeLine:!!((Z=s==null?void 0:s.st)!=null&&Z.s),underline:!!((re=s==null?void 0:s.ul)!=null&&re.s),warp:L===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},x),e.restore(),e.restore(),m.set(E,{left:f.endX-se+n.rowHeaderWidth,top:f.startY+q+n.columnHeaderHeight,width:se,height:I-q-Q})}else{e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const ee=D-ue*2-Te-se-4,q=new O.DocSimpleSkeleton(F,J,L===o.WrapStrategy.WRAP,ee,1/0);q.calculate();const ce=q.getTotalWidth(),Q=q.getTotalHeight(),V=Q+ot*2,x=Math.max(D-ue*2,1),{paddingTop:_}=Vt(x,I,ce,V,k,B);e.translateWithPrecision(ue,_),O.Rect.drawWith(e,{width:x,height:V,fill:H||ve,radius:st}),e.save(),e.translateWithPrecision(Te,ot),e.beginPath(),e.rect(0,0,ee,Q),e.clip(),O.Text.drawWith(e,{text:F,fontStyle:J,width:ee,height:Q,color:(ie=s==null?void 0:s.cl)==null?void 0:ie.rgb,strokeLine:!!((he=s==null?void 0:s.st)!=null&&he.s),underline:!!((pe=s==null?void 0:s.ul)!=null&&pe.s),warp:L===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},q),e.restore(),e.translateWithPrecision(ee+Te+4,(Q-He)/2),e.fillStyle=zn,e.fill(Tt),e.restore(),m.set(E,{left:f.startX+ue+n.rowHeaderWidth,top:f.startY+_+n.columnHeaderHeight,width:x,height:V})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,A=C.getCellValueOrigin(r),T=`${A!=null?A:""}`;let{tb:w,pd:y}=n||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(w=w!=null?w:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:m=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},E=v-I-m-se-4,j=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,E,1/0);return j.calculate(),j.getTotalHeight()+f+D+Ve*2}else{const I=Math.max(v-ue*2-Te-se-4,10),m=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,I,1/0);return m.calculate(),m.getTotalHeight()+Ve*2+ot*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,A=C.getCellValueOrigin(r),T=`${A!=null?A:""}`;let{tb:w,pd:y}=n||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};w=w!=null?w:o.WrapStrategy.WRAP;let I=ue*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=se+4+D+f;break;case o.DataValidationRenderMode.CUSTOM:I=se+ue*2+Te*2+D+f+st/2+1;break;default:I=se+ue*2+Te*2+D+f+st/2+1}const m=v-I,E=new O.DocSimpleSkeleton(T,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,m,1/0);return E.calculate(),E.getTotalWidth()+I}isHit(e,t){const{subUnitId:n,row:r,col:a}=t,s=this._ensureMap(n).get(this._generateKey(r,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Ue.id,s)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};lt=Xn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(O.IRenderManagerService)),Ae(4,o.Inject(C.SheetDataValidationModel))],lt);class Kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(lt));P(this,"dropdownType",X.DataValidatorDropdownType.LIST);P(this,"optionsInput",Ne.componentKey);P(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class Zn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class Gn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.WHOLE);P(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var qn=Object.getOwnPropertyDescriptor,Jn=(e,t,n,r)=>{for(var a=r>1?void 0:r?qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},dt=(e,t)=>(n,r)=>t(n,r,e);let Re=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Ct],[Pe,mn],[Ne.componentKey,Ne],[je.componentKey,je],...Dn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Gn,Zn,Un,An,Kn,xn,Ln].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Re=Jn([dt(0,o.Inject(o.Injector)),dt(1,o.Inject(b.ComponentManager)),dt(2,o.Inject(X.DataValidatorRegistryService))],Re);var Qn=Object.getOwnPropertyDescriptor,er=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(n,r)=>t(n,r,e);const tr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(xe=class extends o.Plugin{constructor(t=Le,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ze,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Re]].forEach(t=>{this._injector.add(t)}),[Fe,Ue,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},P(xe,"pluginName",tr),P(xe,"type",o.UniverInstanceType.UNIVER_SHEET),xe),U.UniverSheetsDataValidationMobileUIPlugin=er([ct(1,o.Inject(o.Injector)),ct(2,o.ICommandService),ct(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ar=(e,t,n)=>t in e?nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ir=(e,t,n,r)=>{for(var a=r>1?void 0:r?rr(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(n,r)=>t(n,r,e),Rt=(e,t,n)=>ar(e,typeof t!="symbol"?t+"":t,n);const or="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Le,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ze,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Ce],[Re]].forEach(t=>{this._injector.add(t)}),[Fe,Ue,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(Ce),this._injector.get(Oe),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},Rt(U.UniverSheetsDataValidationUIPlugin,"pluginName",or),Rt(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=ir([o.DependentOn(C.UniverSheetsDataValidationPlugin),ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
|
3
|
-
"version": "0.14.0-insiders.
|
|
3
|
+
"version": "0.14.0-insiders.20251227-b250a8d",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@univerjs/icons": "^1.0
|
|
58
|
-
"@univerjs/core": "0.14.0-insiders.
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/engine-
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/sheets-
|
|
65
|
-
"@univerjs/sheets-
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/sheets-
|
|
68
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/icons": "^1.1.0",
|
|
58
|
+
"@univerjs/core": "0.14.0-insiders.20251227-b250a8d",
|
|
59
|
+
"@univerjs/design": "0.14.0-insiders.20251227-b250a8d",
|
|
60
|
+
"@univerjs/engine-render": "0.14.0-insiders.20251227-b250a8d",
|
|
61
|
+
"@univerjs/engine-formula": "0.14.0-insiders.20251227-b250a8d",
|
|
62
|
+
"@univerjs/data-validation": "0.14.0-insiders.20251227-b250a8d",
|
|
63
|
+
"@univerjs/sheets-formula-ui": "0.14.0-insiders.20251227-b250a8d",
|
|
64
|
+
"@univerjs/sheets-ui": "0.14.0-insiders.20251227-b250a8d",
|
|
65
|
+
"@univerjs/sheets-data-validation": "0.14.0-insiders.20251227-b250a8d",
|
|
66
|
+
"@univerjs/ui": "0.14.0-insiders.20251227-b250a8d",
|
|
67
|
+
"@univerjs/sheets-numfmt": "0.14.0-insiders.20251227-b250a8d",
|
|
68
|
+
"@univerjs/sheets": "0.14.0-insiders.20251227-b250a8d"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"postcss": "^8.5.6",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"rxjs": "^7.8.2",
|
|
74
74
|
"tailwindcss": "3.4.18",
|
|
75
75
|
"typescript": "^5.9.3",
|
|
76
|
-
"vite": "^7.
|
|
77
|
-
"vitest": "^4.0.
|
|
76
|
+
"vite": "^7.3.0",
|
|
77
|
+
"vitest": "^4.0.16",
|
|
78
78
|
"@univerjs-infra/shared": "0.14.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|