import{defineComponent as z,ref as $,computed as S,createVNode as u}from"vue";import P from"../_util/BaseInput.mjs";import d from"../_util/vue-types/index.mjs";import q from"./KeyCode.mjs";const I=z({compatConfig:{MODE:3},props:{disabled:{type:Boolean,default:void 0},changeSize:Function,quickGo:Function,selectComponentClass:d.any,current:Number,pageSizeOptions:d.array.def(["10","20","50","100"]),pageSize:Number,buildOptionText:Function,locale:d.object,rootPrefixCls:String,selectPrefixCls:String,goButton:d.any},setup(a){const n=$(""),m=S(()=>!n.value||isNaN(n.value)?void 0:Number(n.value)),x=e=>`${e.value} ${a.locale.items_per_page}`,g=e=>{const{value:t}=e.target;n.value!==t&&(n.value=t)},y=e=>{const{goButton:t,quickGo:o,rootPrefixCls:l}=a;t||n.value===""||(e.relatedTarget&&(e.relatedTarget.className.includes(`${l}-item-link`)||e.relatedTarget.className.includes(`${l}-item`))||o(m.value),n.value="")},r=e=>{n.value!==""&&(e.keyCode===q.ENTER||e.type==="click")&&(a.quickGo(m.value),n.value="")},b=S(()=>{const{pageSize:e,pageSizeOptions:t}=a;return t.some(o=>o.toString()===e.toString())?t:t.concat([e.toString()]).sort((o,l)=>{const s=isNaN(Number(o))?0:Number(o),c=isNaN(Number(l))?0:Number(l);return s-c})});return()=>{const{rootPrefixCls:e,locale:t,changeSize:o,quickGo:l,goButton:s,selectComponentClass:c,selectPrefixCls:h,pageSize:k,disabled:f}=a,p=`${e}-options`;let v=null,C=null,N=null;if(!o&&!l)return null;if(o&&c){const O=a.buildOptionText||x,B=b.value.map((i,T)=>u(c.Option,{key:T,value:i},{default:()=>[O({value:i})]}));v=u(c,{disabled:f,prefixCls:h,showSearch:!1,class:`${p}-size-changer`,optionLabelProp:"children",value:(k||b.value[0]).toString(),onChange:i=>o(Number(i)),getPopupContainer:i=>i.parentNode},{default:()=>[B]})}return l&&(s&&(N=typeof s=="boolean"?u("button",{type:"button",onClick:r,onKeyup:r,disabled:f,class:`${p}-quick-jumper-button`},[t.jump_to_confirm]):u("span",{onClick:r,onKeyup:r},[s])),C=u("div",{class:`${p}-quick-jumper`},[t.jump_to,u(P,{disabled:f,type:"text",value:n.value,onInput:g,onChange:g,onKeyup:r,onBlur:y},null),t.page,N])),u("li",{class:`${p}`},[v,C])}}});export{I as default};
