@univerjs/preset-sheets-data-validation 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/umd/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
|
|
16
16
|
univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
|
|
17
17
|
univer-rounded-md univer-p-2 univer-pr-9
|
|
18
|
-
`,{"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"})}));
|
|
18
|
+
`,{"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"})}));
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-data-validation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/data-validation": "0.
|
|
62
|
-
"@univerjs/sheets-data-validation": "0.
|
|
63
|
-
"@univerjs/sheets-data-validation-ui": "0.
|
|
61
|
+
"@univerjs/data-validation": "0.15.0",
|
|
62
|
+
"@univerjs/sheets-data-validation": "0.15.0",
|
|
63
|
+
"@univerjs/sheets-data-validation-ui": "0.15.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@univerjs/core": "0.
|
|
66
|
+
"@univerjs/core": "0.15.0",
|
|
67
67
|
"react": "18.3.1",
|
|
68
68
|
"react-dom": "18.3.1",
|
|
69
69
|
"rxjs": "7.8.2",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
|
-
"@univerjs-infra/shared": "0.
|
|
71
|
+
"@univerjs-infra/shared": "0.15.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"prebuild:preset": "tsx prepare.ts",
|