2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{Q as q,R as U,a as z,V as S,o as u,h as C,t as B,c as w,k as O,D as Y,u as n,G as Z,Z as L,T as ie,a0 as X,bd as ee,aH as re,S as K,af as I,r as N,M as H,j as ae,H as ne,b9 as te,Y as x,m as J,q as oe,bz as le,p as F,bA as ue,bB as G,bC as ce,bD as de,b7 as ge,b8 as pe,N as fe,ag as be,aL as me,bE as T,ap as ve}from"./entry.834fe740.js";import{i as Pe,E as Ce,a as he}from"./index.2ae5e8a1.js";const se=Symbol("elPaginationKey"),ye=q({disabled:Boolean,currentPage:{type:Number,default:1},prevText:{type:String},prevIcon:{type:U}}),_e={click:e=>e instanceof MouseEvent},ke=["disabled","aria-disabled"],ze={key:0},Se=z({name:"ElPaginationPrev"}),Ne=z({...Se,props:ye,emits:_e,setup(e){const o=e,t=S(()=>o.disabled||o.currentPage<=1);return(r,l)=>(u(),C("button",{type:"button",class:"btn-prev",disabled:n(t),"aria-disabled":n(t),onClick:l[0]||(l[0]=g=>r.$emit("click",g))},[r.prevText?(u(),C("span",ze,B(r.prevText),1)):(u(),w(n(Z),{key:1},{default:O(()=>[(u(),w(Y(r.prevIcon)))]),_:1}))],8,ke))}});var xe=L(Ne,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/prev.vue"]]);const Ee=q({disabled:Boolean,currentPage:{type:Number,default:1},pageCount:{type:Number,default:50},nextText:{type:String},nextIcon:{type:U}}),$e=["disabled","aria-disabled"],we={key:0},Te=z({name:"ElPaginationNext"}),Me=z({...Te,props:Ee,emits:["click"],setup(e){const o=e,t=S(()=>o.disabled||o.currentPage===o.pageCount||o.pageCount===0);return(r,l)=>(u(),C("button",{type:"button",class:"btn-next",disabled:n(t),"aria-disabled":n(t),onClick:l[0]||(l[0]=g=>r.$emit("click",g))},[r.nextText?(u(),C("span",we,B(r.nextText),1)):(u(),w(n(Z),{key:1},{default:O(()=>[(u(),w(Y(r.nextIcon)))]),_:1}))],8,$e))}});var Be=L(Me,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/next.vue"]]);const R=()=>ie(se,{}),Ie=q({pageSize:{type:Number,required:!0},pageSizes:{type:X(Array),default:()=>ee([10,20,30,40,50,100])},popperClass:{type:String},disabled:Boolean,size:{type:String,values:re}}),qe=z({name:"ElPaginationSizes"}),Le=z({...qe,props:Ie,emits:["page-size-change"],setup(e,{emit:o}){const t=e,{t:r}=K(),l=I("pagination"),g=R(),h=N(t.pageSize);H(()=>t.pageSizes,(c,y)=>{if(!Pe(c,y)&&Array.isArray(c)){const p=c.includes(t.pageSize)?t.pageSize:t.pageSizes[0];o("page-size-change",p)}}),H(()=>t.pageSize,c=>{h.value=c});const k=S(()=>t.pageSizes);function E(c){var y;c!==h.value&&(h.value=c,(y=g.handleSizeChange)==null||y.call(g,Number(c)))}return(c,y)=>(u(),C("span",{class:x(n(l).e("sizes"))},[ae(n(he),{"model-value":h.value,disabled:c.disabled,"popper-class":c.popperClass,size:c.size,"validate-event":!1,onChange:E},{default:O(()=>[(u(!0),C(ne,null,te(n(k),p=>(u(),w(n(Ce),{key:p,value:p,label:p+n(r)("el.pagination.pagesize")},null,8,["value","label"]))),128))]),_:1},8,["model-value","disabled","popper-class","size"])],2))}});var Ae=L(Le,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/sizes.vue"]]);const je=["disabled"],De=z({name:"ElPaginationJumper"}),Fe=z({...De,setup(e){const{t:o}=K(),t=I("pagination"),{pageCount:r,disabled:l,currentPage:g,changeEvent:h}=R(),k=N(),E=S(()=>{var p;return(p=k.value)!=null?p:g==null?void 0:g.value});function c(p){k.value=+p}function y(p){p=Math.trunc(+p),h==null||h(+p),k.value=void 0}return(p,b)=>(u(),C("span",{class:x(n(t).e("jump")),disabled:n(l)},[J(B(n(o)("el.pagination.goto"))+" ",1),ae(n(oe),{size:"small",class:x([n(t).e("editor"),n(t).is("in-pagination")]),min:1,max:n(r),disabled:n(l),"model-value":n(E),"validate-event":!1,type:"number","onUpdate:modelValue":c,onChange:y},null,8,["class","max","disabled","model-value"]),J(" "+B(n(o)("el.pagination.pageClassifier")),1)],10,je))}});var Ue=L(Fe,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/jumper.vue"]]);const Ke=q({total:{type:Number,default:1e3}}),Ve=["disabled"],We=z({name:"ElPaginationTotal"}),He=z({...We,props:Ke,setup(e){const{t:o}=K(),t=I("pagination"),{disabled:r}=R();return(l,g)=>(u(),C("span",{class:x(n(t).e("total")),disabled:n(r)},B(n(o)("el.pagination.total",{total:l.total})),11,Ve))}});var Oe=L(He,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/total.vue"]]);const Re=q({currentPage:{type:Number,default:1},pageCount:{type:Number,required:!0},pagerCount:{type:Number,default:7},disabled:Boolean}),Je=["onKeyup"],Ge=["aria-current","tabindex"],Qe=["tabindex"],Ye=["aria-current","tabindex"],Ze=["tabindex"],Xe=["aria-current","tabindex"],ea=z({name:"ElPaginationPager"}),aa=z({...ea,props:Re,emits:["change"],setup(e,{emit:o}){const t=e,r=I("pager"),l=I("icon"),g=N(!1),h=N(!1),k=N(!1),E=N(!1),c=N(!1),y=N(!1),p=S(()=>{const s=t.pagerCount,i=(s-1)/2,a=Number(t.currentPage),d=Number(t.pageCount);let m=!1,_=!1;d>s&&(a>s-i&&(m=!0),a<d-i&&(_=!0));const M=[];if(m&&!_){const v=d-(s-2);for(let $=v;$<d;$++)M.push($)}else if(!m&&_)for(let v=2;v<s;v++)M.push(v);else if(m&&_){const v=Math.floor(s/2)-1;for(let $=a-v;$<=a+v;$++)M.push($)}else for(let v=2;v<d;v++)M.push(v);return M}),b=S(()=>t.disabled?-1:0);le(()=>{const s=(t.pagerCount-1)/2;g.value=!1,h.value=!1,t.pageCount>t.pagerCount&&(t.currentPage>t.pagerCount-s&&(g.value=!0),t.currentPage<t.pageCount-s&&(h.value=!0))});function f(s=!1){t.disabled||(s?k.value=!0:E.value=!0)}function A(s=!1){s?c.value=!0:y.value=!0}function V(s){const i=s.target;if(i.tagName.toLowerCase()==="li"&&Array.from(i.classList).includes("number")){const a=Number(i.textContent);a!==t.currentPage&&o("change",a)}else i.tagName.toLowerCase()==="li"&&Array.from(i.classList).includes("more")&&D(s)}function D(s){const i=s.target;if(i.tagName.toLowerCase()==="ul"||t.disabled)return;let a=Number(i.textContent);const d=t.pageCount,m=t.currentPage,_=t.pagerCount-2;i.className.includes("more")&&(i.className.includes("quickprev")?a=m-_:i.className.includes("quicknext")&&(a=m+_)),Number.isNaN(+a)||(a<1&&(a=1),a>d&&(a=d)),a!==m&&o("change",a)}return(s,i)=>(u(),C("ul",{class:x(n(r).b()),onClick:D,onKeyup:de(V,["enter"])},[s.pageCount>0?(u(),C("li",{key:0,class:x([[n(r).is("active",s.currentPage===1),n(r).is("disabled",s.disabled)],"number"]),"aria-current":s.currentPage===1,tabindex:n(b)}," 1 ",10,Ge)):F("v-if",!0),g.value?(u(),C("li",{key:1,class:x(["more","btn-quickprev",n(l).b(),n(r).is("disabled",s.disabled)]),tabindex:n(b),onMouseenter:i[0]||(i[0]=a=>f(!0)),onMouseleave:i[1]||(i[1]=a=>k.value=!1),onFocus:i[2]||(i[2]=a=>A(!0)),onBlur:i[3]||(i[3]=a=>c.value=!1)},[k.value||c.value?(u(),w(n(ue),{key:0})):(u(),w(n(G),{key:1}))],42,Qe)):F("v-if",!0),(u(!0),C(ne,null,te(n(p),a=>(u(),C("li",{key:a,class:x([[n(r).is("active",s.currentPage===a),n(r).is("disabled",s.disabled)],"number"]),"aria-current":s.currentPage===a,tabindex:n(b)},B(a),11,Ye))),128)),h.value?(u(),C("li",{key:2,class:x(["more","btn-quicknext",n(l).b(),n(r).is("disabled",s.disabled)]),tabindex:n(b),onMouseenter:i[4]||(i[4]=a=>f()),onMouseleave:i[5]||(i[5]=a=>E.value=!1),onFocus:i[6]||(i[6]=a=>A()),onBlur:i[7]||(i[7]=a=>y.value=!1)},[E.value||y.value?(u(),w(n(ce),{key:0})):(u(),w(n(G),{key:1}))],42,Ze)):F("v-if",!0),s.pageCount>1?(u(),C("li",{key:3,class:x([[n(r).is("active",s.currentPage===s.pageCount),n(r).is("disabled",s.disabled)],"number"]),"aria-current":s.currentPage===s.pageCount,tabindex:n(b)},B(s.pageCount),11,Xe)):F("v-if",!0)],42,Je))}});var na=L(aa,[["__file","/home/runner/work/element-plus/element-plus/packages/components/pagination/src/components/pager.vue"]]);const P=e=>typeof e!="number",ta=q({total:Number,pageSize:Number,defaultPageSize:Number,currentPage:Number,defaultCurrentPage:Number,pageCount:Number,pagerCount:{type:Number,validator:e=>typeof e=="number"&&Math.trunc(e)===e&&e>4&&e<22&&e%2===1,default:7},layout:{type:String,default:["prev","pager","next","jumper","->","total"].join(", ")},pageSizes:{type:X(Array),default:()=>ee([10,20,30,40,50,100])},popperClass:{type:String,default:""},prevText:{type:String,default:""},prevIcon:{type:U,default:()=>ge},nextText:{type:String,default:""},nextIcon:{type:U,default:()=>pe},small:Boolean,background:Boolean,disabled:Boolean,hideOnSinglePage:Boolean}),sa={"update:current-page":e=>typeof e=="number","update:page-size":e=>typeof e=="number","size-change":e=>typeof e=="number","current-change":e=>typeof e=="number","prev-click":e=>typeof e=="number","next-click":e=>typeof e=="number"},Q="ElPagination";var ia=z({name:Q,props:ta,emits:sa,setup(e,{emit:o,slots:t}){const{t:r}=K(),l=I("pagination"),g=fe().vnode.props||{},h="onUpdate:currentPage"in g||"onUpdate:current-page"in g||"onCurrentChange"in g,k="onUpdate:pageSize"in g||"onUpdate:page-size"in g||"onSizeChange"in g,E=S(()=>{if(P(e.total)&&P(e.pageCount)||!P(e.currentPage)&&!h)return!1;if(e.layout.includes("sizes")){if(P(e.pageCount)){if(!P(e.total)&&!P(e.pageSize)&&!k)return!1}else if(!k)return!1}return!0}),c=N(P(e.defaultPageSize)?10:e.defaultPageSize),y=N(P(e.defaultCurrentPage)?1:e.defaultCurrentPage),p=S({get(){return P(e.pageSize)?c.value:e.pageSize},set(a){P(e.pageSize)&&(c.value=a),k&&(o("update:page-size",a),o("size-change",a))}}),b=S(()=>{let a=0;return P(e.pageCount)?P(e.total)||(a=Math.max(1,Math.ceil(e.total/p.value))):a=e.pageCount,a}),f=S({get(){return P(e.currentPage)?y.value:e.currentPage},set(a){let d=a;a<1?d=1:a>b.value&&(d=b.value),P(e.currentPage)&&(y.value=d),h&&(o("update:current-page",d),o("current-change",d))}});H(b,a=>{f.value>a&&(f.value=a)});function A(a){f.value=a}function V(a){p.value=a;const d=b.value;f.value>d&&(f.value=d)}function D(){e.disabled||(f.value-=1,o("prev-click",f.value))}function s(){e.disabled||(f.value+=1,o("next-click",f.value))}function i(a,d){a&&(a.props||(a.props={}),a.props.class=[a.props.class,d].join(" "))}return be(se,{pageCount:b,disabled:S(()=>e.disabled),currentPage:f,changeEvent:A,handleSizeChange:V}),()=>{var a,d;if(!E.value)return me(Q,r("el.pagination.deprecationWarning")),null;if(!e.layout||e.hideOnSinglePage&&b.value<=1)return null;const m=[],_=[],M=T("div",{class:l.e("rightwrapper")},_),v={prev:T(xe,{disabled:e.disabled,currentPage:f.value,prevText:e.prevText,prevIcon:e.prevIcon,onClick:D}),jumper:T(Ue),pager:T(na,{currentPage:f.value,pageCount:b.value,pagerCount:e.pagerCount,onChange:A,disabled:e.disabled}),next:T(Be,{disabled:e.disabled,currentPage:f.value,pageCount:b.value,nextText:e.nextText,nextIcon:e.nextIcon,onClick:s}),sizes:T(Ae,{pageSize:p.value,pageSizes:e.pageSizes,popperClass:e.popperClass,disabled:e.disabled,size:e.small?"small":"default"}),slot:(d=(a=t==null?void 0:t.default)==null?void 0:a.call(t))!=null?d:null,total:T(Oe,{total:P(e.total)?0:e.total})},$=e.layout.split(",").map(j=>j.trim());let W=!1;return $.forEach(j=>{if(j==="->"){W=!0;return}W?_.push(v[j]):m.push(v[j])}),i(m[0],l.is("first")),i(m[m.length-1],l.is("last")),W&&_.length>0&&(i(_[0],l.is("first")),i(_[_.length-1],l.is("last")),m.push(M)),T("div",{role:"pagination","aria-label":"pagination",class:[l.b(),l.is("background",e.background),{[l.m("small")]:e.small}]},m)}}});const la=ve(ia);export{la as E};
|