UNPKG

@ocrv/vue-tailwind-pagination

Version:
2 lines (1 loc) 5.57 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self)["vue-tailwind-pagination"]=t(e.Vue)}(this,(function(e){"use strict";var t=e.defineComponent({name:"Vue Tailwind Pagination",props:{current:{type:Number,default:1},total:{type:Number,default:0},perPage:{type:Number,default:9},pageRange:{type:Number,default:2},textBeforeInput:{type:String,default:"Go to page"},textAfterInput:{type:String,default:"Go"}},data:()=>({input:""}),methods:{hasFirst:function(){return 1!==this.rangeStart},hasLast:function(){return this.rangeEnd<this.totalPages},hasPrev:function(){return this.current>1},hasNext:function(){return this.current<this.totalPages},changePage:function(e){e>0&&e<=this.totalPages&&this.$emit("page-changed",e)}},computed:{pages:function(){for(var e=[],t=this.rangeStart;t<=this.rangeEnd;t++)e.push(t);return e},rangeStart:function(){var e=this.current-this.pageRange;return e>0?e:1},rangeEnd:function(){var e=this.current+this.pageRange;return e<this.totalPages?e:this.totalPages},totalPages:function(){return Math.ceil(this.total/this.perPage)},nextPage:function(){return this.current+1},prevPage:function(){return this.current-1}}});const r=e.withScopeId("data-v-00d7790c");e.pushScopeId("data-v-00d7790c");const o={class:"min-w-max"},a={class:"flex justify-between bg-white rounded-lg border border-gray-200 px-10 py-3 text-gray-700 font-montserrat"},n={class:"flex items-center"},s={key:0,class:"pr-6"},i=e.createVNode("div",{class:"flex items-center justify-center hover:bg-gray-200 rounded-md transform rotate-45 h-6 w-6"},[e.createVNode("div",{class:"transform -rotate-45"},[e.createVNode("svg",{class:"h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})])])],-1),c={key:1,class:"pr-6"},d=e.createVNode("div",{class:"flex hover:bg-gray-200 rounded-md transform rotate-45 h-6 w-6 items-center justify-center"},[e.createVNode("span",{class:"transform -rotate-45"}," 1 ")],-1),l={key:2,class:"pr-6"},u={class:"pr-6"},p={class:"transform -rotate-45"},g={key:3,class:"pr-6"},f={key:4,class:"pr-6"},h={class:"flex hover:bg-gray-200 rounded-md transform rotate-45 h-6 w-6 items-center justify-center"},m={class:"transform -rotate-45"},v={key:5,class:"pr-6"},k=e.createVNode("div",{class:"flex items-center justify-center hover:bg-gray-200 rounded-md transform rotate-45 h-6 w-6"},[e.createVNode("div",{class:"transform -rotate-45"},[e.createVNode("svg",{class:"h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})])])],-1),N={class:"flex items-center"},w={class:"pr-2 text-gray-400 font-medium"},V={id:"text-before-input"},y={class:"w-14 rounded-md border border-indigo-400 px-1 py-1"},x={id:"text-after-input"},P=e.createVNode("svg",{class:"h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e.createVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1);e.popScopeId();const B=r(((t,r,B,b,C,S)=>(e.openBlock(),e.createBlock("div",o,[e.createVNode("section",a,[e.createVNode("ul",n,[t.hasPrev()?(e.openBlock(),e.createBlock("li",s,[e.createVNode("a",{href:"#",onClick:r[1]||(r[1]=e.withModifiers((e=>t.changePage(t.prevPage)),["prevent"]))},[i])])):e.createCommentVNode("",!0),t.hasFirst()?(e.openBlock(),e.createBlock("li",c,[e.createVNode("a",{href:"#",onClick:r[2]||(r[2]=e.withModifiers((e=>t.changePage(1)),["prevent"]))},[d])])):e.createCommentVNode("",!0),t.hasFirst()?(e.openBlock(),e.createBlock("li",l,"...")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(t.pages,(r=>(e.openBlock(),e.createBlock("li",u,[e.createVNode("a",{href:"#",onClick:e.withModifiers((e=>t.changePage(r)),["prevent"])},[e.createVNode("div",{class:[{"bg-gradient-to-r from-blue-400 to-indigo-400":t.current==r},"flex hover:bg-gray-200 rounded-md transform rotate-45 h-6 w-6 items-center justify-center"]},[e.createVNode("span",p,e.toDisplayString(r),1)],2)],8,["onClick"])])))),256)),t.hasLast()?(e.openBlock(),e.createBlock("li",g,"...")):e.createCommentVNode("",!0),t.hasLast()?(e.openBlock(),e.createBlock("li",f,[e.createVNode("a",{href:"#",onClick:r[3]||(r[3]=e.withModifiers((e=>t.changePage(t.totalPages)),["prevent"]))},[e.createVNode("div",h,[e.createVNode("span",m,e.toDisplayString(t.totalPages),1)])])])):e.createCommentVNode("",!0),t.hasNext()?(e.openBlock(),e.createBlock("li",v,[e.createVNode("a",{href:"#",onClick:r[4]||(r[4]=e.withModifiers((e=>t.changePage(t.nextPage)),["prevent"]))},[k])])):e.createCommentVNode("",!0)]),e.createVNode("div",N,[e.createVNode("div",w,[e.createVNode("span",V,e.toDisplayString(t.textBeforeInput),1)]),e.createVNode("div",y,[e.withDirectives(e.createVNode("input",{"onUpdate:modelValue":r[5]||(r[5]=e=>t.input=e),class:"w-12 focus:outline-none px-2",type:"text"},null,512),[[e.vModelText,t.input,void 0,{number:!0}]])]),e.createVNode("div",{onClick:r[6]||(r[6]=e.withModifiers((e=>t.changePage(t.input)),["prevent"])),class:"flex items-center pl-4 font-medium cursor-pointer"},[e.createVNode("span",x,e.toDisplayString(t.textAfterInput),1),P])])])]))));t.render=B,t.__scopeId="data-v-00d7790c";return t}));