@jobinsjp/vue3-datatable
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,1 +0,1 @@ | ||
var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,r=(t,a,n)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n,s=(e,t)=>{for(var a in t||(t={}))d.call(t,a)&&r(e,a,t[a]);if(n)for(var a of n(t))l.call(t,a)&&r(e,a,t[a]);return e},o=(e,n)=>t(e,a(n));import{openBlock as i,createBlock as u,createVNode as c,defineComponent as g,pushScopeId as p,popScopeId as b,withScopeId as v,computed as f,mergeProps as m,toHandlers as y,renderSlot as h,resolveComponent as P,withDirectives as x,toDisplayString as w,vShow as C,withModifiers as k,withCtx as I,Fragment as _,createCommentVNode as O,renderList as q,createTextVNode as $,ref as L,watch as j}from"vue";const S={},B={xmlns:"http://www.w3.org/2000/svg",class:"dt-h-5 dt-w-5",viewBox:"0 0 20 20",fill:"currentColor"},N=c("path",{"fill-rule":"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z","clip-rule":"evenodd"},null,-1);S.render=function(e,t){return i(),u("svg",B,[N])};var D=g({name:"Loading"});const F=v("data-v-f17dff8e");p("data-v-f17dff8e");const Q={class:"spinner dt-absolute dt-h-full dt-w-full dt-flex dt-justify-center"},T=c("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1),M=c("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1);b();const E=F(((e,t,a,n,d,l)=>(i(),u("div",Q,[T,M]))));D.render=E,D.__scopeId="data-v-f17dff8e";var R=g({name:"PaginationLink",props:{active:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},setup:e=>({linkClasses:f((()=>e.active?"dt-bg-gray-200 dt-border-gray-300 dt-text-gray-800 hover:dt-bg-gray-200":e.disabled?"dt-cursor-not-allowed dt-text-gray-400":"dt-border-gray-300 dt-bg-white dt-text-gray-500 hover:dt-bg-gray-50"))})});R.render=function(e,t,a,n,d,l){return i(),u("a",m({href:"#",class:["dt-relative dt-inline-flex dt-items-center dt-px-4 dt-py-2 dt-border dt-text-sm dt-font-medium",e.linkClasses]},y(s({},e.$attrs))),[h(e.$slots,"default")],16)};var z=g({name:"Pagination",components:{PaginationLink:R},props:{total:{type:Number,required:!0},perPage:{type:Number,required:!0},currentPage:{type:Number,required:!1,default:1},maxVisibleButtons:{type:Number,required:!1,default:5}},emits:["changed"],setup(e,{emit:t}){const a=f((()=>(e.currentPage-1)*e.perPage+1)),n=f((()=>e.total>e.currentPage*e.perPage?e.currentPage*e.perPage:e.total)),d=f((()=>Math.ceil(e.total/e.perPage))),l=f((()=>1===e.currentPage?1:e.currentPage===d.value?d.value-e.maxVisibleButtons+1:e.currentPage-1)),r=f((()=>Math.min(l.value+e.maxVisibleButtons-1,d.value))),s=f((()=>{const e=[];for(let t=l.value;t<=r.value;t+=1)t>0&&e.push(t);return e})),o=f((()=>1===e.currentPage)),i=f((()=>e.currentPage===d.value)),u=e=>{t("changed",e)};return{currentStart:a,currentEnd:n,totalPages:d,pages:s,isInFirstPage:o,isInLastPage:i,goToPageNumber:u,gotoFirstPage:()=>u(1),gotoLastPage:()=>u(d.value),gotoNextPage:()=>u(e.currentPage>=d.value?d.value:e.currentPage+1),gotoPreviousPage:()=>u(e.currentPage<=1?1:e.currentPage-1),showDots:(e="left")=>{const t="left"===e?1:d.value,a="left"===e?2:d.value-1;return!s.value.includes(t)||!s.value.includes(a)}}}});const A={key:0,class:"dt-bg-white dt-px-4 dt-py-3 dt-flex dt-items-center dt-justify-between dt-border-t dt-border-gray-200 sm:dt-px-6"},V={class:"dt-hidden sm:dt-flex-1 sm:dt-flex sm:dt-items-center sm:dt-justify-between"},G={class:"dt-text-sm dt-text-gray-700"},H=$(" Showing "),J=$(" to "),K=$(" of "),U=$(" results. "),W={key:0},X={class:"dt-relative dt-z-0 dt-inline-flex dt-rounded-md dt-shadow-sm dt--space-x-px","aria-label":"Pagination"},Y=c("span",{class:"dt-sr-only"},"Go to first",-1),Z=$(" « "),ee=c("span",{class:"dt-sr-only"},"Previous",-1),te=$(" ‹ "),ae=$(" 1 "),ne=$(" ... "),de=$(" ... "),le=c("span",{class:"dt-sr-only"},"Next",-1),re=$(" › "),se=c("span",{class:"dt-sr-only"},"Go to Last",-1),oe=$(" » ");z.render=function(e,t,a,n,d,l){const r=P("pagination-link");return e.totalPages?(i(),u("div",A,[c("div",V,[x(c("div",null,[c("p",G,[h(e.$slots,"pagination-info",{currentStart:e.currentStart,currentEnd:e.currentEnd,total:e.total},(()=>[H,c("span",{class:"dt-font-medium",textContent:w(e.currentStart)},null,8,["textContent"]),J,c("span",{class:"dt-font-medium",textContent:w(e.currentEnd)},null,8,["textContent"]),K,c("span",{class:"dt-font-medium",textContent:w(e.total)},null,8,["textContent"]),U]))])],512),[[C,e.total]]),e.totalPages>1?(i(),u("div",W,[c("nav",X,[c(r,{disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:k(e.gotoFirstPage,["prevent"])},{default:I((()=>[Y,Z])),_:1},8,["disabled","onClick"]),c(r,{disabled:e.isInFirstPage,onClick:k(e.gotoPreviousPage,["prevent"])},{default:I((()=>[ee,te])),_:1},8,["disabled","onClick"]),e.showDots("left")?(i(),u(_,{key:0},[c(r,{class:"dt-block sm:dt-hidden",disabled:e.isInFirstPage,active:e.isInFirstPage,onClick:k(e.gotoFirstPage,["prevent"])},{default:I((()=>[ae])),_:1},8,["disabled","active","onClick"]),c(r,{class:"sm:dt-hidden"},{default:I((()=>[ne])),_:1})],64)):O("",!0),(i(!0),u(_,null,q(e.pages,((t,a)=>(i(),u(r,{key:`pages_${a}`,class:"dt-hidden md:dt-inline-block",active:t===e.currentPage,disabled:t===e.currentPage,onClick:k((a=>e.goToPageNumber(t)),["prevent"])},{default:I((()=>[$(w(t),1)])),_:2},1032,["active","disabled","onClick"])))),128)),e.showDots("right")?(i(),u(_,{key:1},[c(r,{class:"sm:dt-hidden"},{default:I((()=>[de])),_:1}),c(r,{class:"sm:dt-hidden",disabled:e.isInLastPage,active:e.isInLastPage,onClick:k(e.gotoLastPage,["prevent"])},{default:I((()=>[$(w(e.totalPages),1)])),_:1},8,["disabled","active","onClick"])],64)):O("",!0),c(r,{disabled:e.isInLastPage,onClick:k(e.gotoNextPage,["prevent"])},{default:I((()=>[le,re])),_:1},8,["disabled","onClick"]),c(r,{disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:k(e.gotoLastPage,["prevent"])},{default:I((()=>[se,oe])),_:1},8,["disabled","onClick"])])])):O("",!0)])])):O("",!0)};const ie={},ue={class:"dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};ie.render=function(e,t){return i(),u("td",ue,[h(e.$slots,"default")])};const ce={},ge={scope:"col",class:"dt-px-6 dt-py-3 dt-text-left dt-text-xs dt-font-medium dt-text-gray-500 dt-uppercase dt-tracking-wider"};ce.render=function(e,t){return i(),u("th",ge,[h(e.$slots,"default")])};const pe=[5,10,15,25,50,75,100],be=g({components:{SearchIcon:S,Loading:D,Pagination:z,TableBody:ie,TableHead:ce},props:{rows:{type:Array,required:!0},columns:{type:Object,required:!1,default:null},pagination:{type:Object,required:!1,default:null},striped:{type:Boolean,required:!1,default:!1},sn:{type:Boolean,required:!1,default:!1},filter:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},perPageOptions:{type:Array,required:!1,default:()=>pe},query:{type:Object,required:!1,default:()=>({})}},emits:["loadData"],setup(e,{emit:t}){var a,n;const d=L({page:(null==(a=e.pagination)?void 0:a.page)||1,search:e.query.search||"",per_page:(null==(n=e.pagination)?void 0:n.per_page)||10}),l=f((()=>!!e.pagination)),r=f((()=>{var t;return(null==(t=e.pagination)?void 0:t.total)||e.rows.length})),i=f((()=>e.rows)),u=f((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>o(s({},e),{[t]:t})),{}))),c=f((()=>l.value?d.value.per_page*(d.value.page-1):0));j((()=>s({},d.value)),(()=>{t("loadData",d.value)}),{deep:!0,immediate:!0});const g=((e,t=400)=>{let a;return(...n)=>{clearTimeout(a),a=setTimeout((()=>e(...n)),t)}})((e=>{d.value=o(s({},d.value),{page:1,search:e.target.value})}));return{tableQuery:d,showPagination:l,totalData:r,tableRows:i,tableColumns:u,paginatedRowIndex:c,uniqueId:()=>Math.floor(100*Math.random()),handlePageChange:e=>{d.value.page=e},handleOnSearchChange:g,handleOnChange:e=>{const{name:t,value:a}=e.target;d.value=o(s({},d.value),{page:1,[t]:a})}}}});const ve={class:"data-table dt-flex dt-flex-col"},fe={class:"dt-align-middle dt-min-w-full"},me={key:0,class:"dt-filter-wrapper dt-mb-3 dt-w-full"},ye={class:"dt-w-64"},he=c("label",{for:"email",class:"dt-sr-only"},"Search",-1),Pe={class:"dt-relative dt-rounded-md dt-shadow-sm"},xe={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"},we={class:"table-wrapper dt-relative dt-shadow dt-overflow-hidden dt-border-b dt-border-gray-200 sm:dt-rounded-lg"},Ce={key:1,class:"pagination-wrapper md:dt-flex smdt-flex-col dt-bg-white dt-items-center"},ke={class:"dt-pr-4 dt-w-full dt-pb-3 dt-flex dt-justify-end sm:dt-pr-6 sm:dt-pb-0 sm:dt-w-auto"},Ie={class:""},_e=c("label",{for:"location",class:"dt-sr-only"},"Per page",-1),Oe={class:"table-container dt-overflow-auto"},qe={class:"dt-min-w-full dt-divide-y dt-divide-gray-200"},$e={class:"dt-bg-gray-50"},Le={key:2,class:"pagination-wrapper"};be.render=function(e,t,a,n,d,l){const r=P("search-icon"),s=P("Loading"),o=P("pagination"),g=P("table-head"),p=P("table-body");return i(),u("div",ve,[c("div",fe,[e.filter?(i(),u("div",me,[c("div",ye,[he,c("div",Pe,[c("input",{value:e.tableQuery.search,type:"search",name:"search",class:"focus:dt-ring-0 dt-block dt-w-full dt-pr-10 sm:dt-text-sm dt-border-gray-300 dt-rounded-md",onInput:t[1]||(t[1]=(...t)=>e.handleOnSearchChange&&e.handleOnSearchChange(...t))},null,40,["value"]),c("div",xe,[c(r,{class:"dt-text-gray-400"})])])])])):O("",!0),c("div",we,[e.loading?h(e.$slots,"loading",{key:0},(()=>[c(s)])):O("",!0),e.showPagination?(i(),u("div",Ce,[c(o,{class:"dt-flex-1",total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"]),c("div",ke,[c("div",Ie,[_e,c("select",{value:e.tableQuery.per_page,name:"per_page",class:"dt-block dt-w-full dt-pl-3 dt-pr-10 dt-py-2 dt-text-base dt-border-gray-300 sm:dt-text-sm dt-rounded-md",onInput:t[2]||(t[2]=(...t)=>e.handleOnChange&&e.handleOnChange(...t))},[(i(!0),u(_,null,q(e.perPageOptions,(t=>(i(),u("option",{key:`per_page_${t}`,value:t,selected:t===e.tableQuery.per_page,textContent:w(t)},null,8,["value","selected","textContent"])))),128))],40,["value"])])])])):O("",!0),c("div",Oe,[c("table",qe,[c("thead",$e,[c("tr",null,[e.sn?h(e.$slots,"thead-sn",{key:0},(()=>[c(g,{textContent:w("S.N.")},null,8,["textContent"])])):O("",!0),h(e.$slots,"thead",{column:e.tableColumns},(()=>[(i(!0),u(_,null,q(e.tableColumns,((e,t)=>(i(),u(g,{key:`datatable-thead-th-${t}`,textContent:w(e)},null,8,["textContent"])))),128))]))])]),c("tbody",null,[(i(!0),u(_,null,q(e.tableRows,((t,a)=>(i(),u("tr",{key:`datatable-tbody-${e.uniqueId()}-${a}`,class:e.striped&&a%2?"dt-bg-gray-50":"dt-bg-white"},[e.sn?h(e.$slots,"tbody-sn",{key:0,sn:a+1},(()=>[c(p,{textContent:w(a+1+e.paginatedRowIndex)},null,8,["textContent"])])):O("",!0),h(e.$slots,"tbody",{index:a,row:t},(()=>[(i(!0),u(_,null,q(e.tableColumns,((a,n)=>(i(),u(p,{key:`datatable-tbody-td-${e.uniqueId()}-${n}`,name:a,textContent:w(t[n])},null,8,["name","textContent"])))),128))]))],2)))),128))])])]),e.showPagination?(i(),u("div",Le,[c(o,{total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])])):O("",!0)])])])};export{be as DataTable,z as Pagination,R as PaginationLink,ie as TableBody,ce as TableHead}; | ||
var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,d=(t,a,n)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n,o=(e,t)=>{for(var a in t||(t={}))r.call(t,a)&&d(e,a,t[a]);if(n)for(var a of n(t))l.call(t,a)&&d(e,a,t[a]);return e},i=(e,n)=>t(e,a(n));import{defineComponent as s,openBlock as u,createElementBlock as p,createElementVNode as g,mergeProps as c,resolveComponent as f,createVNode as v,pushScopeId as b,popScopeId as m,renderSlot as y,computed as _,toHandlers as h,createBlock as P,withCtx as w,toDisplayString as x,createCommentVNode as C,withModifiers as k,Fragment as I,renderList as T,createTextVNode as q,normalizeClass as $,ref as B,watch as S}from"vue";var O=s({name:"SearchIcon"});const L={xmlns:"http://www.w3.org/2000/svg",class:"dt-h-5 dt-w-5",viewBox:"0 0 20 20",fill:"currentColor"},j=[g("path",{"fill-rule":"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z","clip-rule":"evenodd"},null,-1)];O.render=function(e,t,a,n,r,l){return u(),p("svg",L,j)};var N=s({name:"SearchInput",props:{value:{type:String,required:!0}}});const F=["value"];N.render=function(e,t,a,n,r,l){return u(),p("input",c({value:e.value,type:"search",name:"search",class:"dt__filter__search dt-block dt-border dt-border-gray-300 dt-pr-10 dt-px-2 dt-py-2\n dt-rounded-md dt-w-full dt-outline-none focus:dt-ring-1 focus:dt-ring-inset sm:dt-text-sm"},e.$attrs),null,16,F)};var z=s({name:"Filter",components:{SearchInput:N,SearchIcon:O},props:{search:{type:String,required:!0}},emits:["input"]});const D={class:"dt__filter dt-mb-3 dt-w-full"},W={class:"dt-w-64"},H=g("label",{for:"email",class:"dt-sr-only"},"Search",-1),Q={class:"dt-relative dt-rounded-md dt-shadow-sm"},R={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"};z.render=function(e,t,a,n,r,l){const d=f("SearchInput"),o=f("SearchIcon");return u(),p("div",D,[g("div",W,[H,g("div",Q,[v(d,{value:e.search,onInput:t[0]||(t[0]=t=>e.$emit("input",t.target.value))},null,8,["value"]),g("div",R,[v(o,{class:"dt-text-gray-400"})])])])])};var M=s({name:"Loading"});b("data-v-685865e4");const A={class:"dt__loading dt-absolute dt-h-full dt-w-full"},E=[g("div",{class:"dt-flex dt-justify-center dt-items-center"},[g("div",{class:"dt__loading_item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"}),g("div",{class:"dt__loading_item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"})],-1)];m(),M.render=function(e,t,a,n,r,l){return u(),p("div",A,E)},M.__scopeId="data-v-685865e4";var V=s({name:"BottomPaginationWrapper"});const G={class:"dt__pagination_wrapper--bottom dt-bg-white dt-shadow-inner"},U={class:"dt-px-4 sm:dt-px-6 dt-py-4"};V.render=function(e,t,a,n,r,l){return u(),p("div",G,[g("div",U,[y(e.$slots,"default")])])};var J=s({name:"PaginationButtons"});const K={class:"dt__pagination__nav dt-relative dt-z-0 dt-inline-flex dt-rounded-md dt-shadow-sm dt--space-x-px","aria-label":"Pagination"};J.render=function(e,t,a,n,r,l){return u(),p("nav",K,[y(e.$slots,"default")])};var X=s({name:"PaginationInfo"});const Y={class:"dt__pagination__info"},Z={class:"dt-text-sm dt-text-gray-700"};X.render=function(e,t,a,n,r,l){return u(),p("div",Y,[g("p",Z,[y(e.$slots,"default")])])};var ee=s({name:"PaginationLink",props:{active:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},setup:e=>({linkClasses:_((()=>e.active?"dt-bg-gray-200 dt-border-gray-300 dt-text-gray-800 hover:dt-bg-gray-200":e.disabled?"dt-cursor-not-allowed dt-text-gray-400":"dt-border-gray-300 dt-bg-white dt-text-gray-500 hover:dt-bg-gray-50"))})});ee.render=function(e,t,a,n,r,l){return u(),p("a",c({href:"#",class:["dt__pagination__link dt-relative dt-inline-flex dt-items-center dt-px-4 dt-py-2 dt-border dt-text-sm dt-font-medium",e.linkClasses]},h(o({},e.$attrs))),[y(e.$slots,"default")],16)};var te=s({name:"Pagination",components:{PaginationButtons:J,PaginationInfo:X,PaginationLink:ee},props:{total:{type:Number,required:!0},perPage:{type:Number,required:!0},currentPage:{type:Number,required:!1,default:1},maxVisibleButtons:{type:Number,required:!1,default:5}},emits:["changed"],setup(e,{emit:t}){const a=_((()=>(e.currentPage-1)*e.perPage+1)),n=_((()=>e.total>e.currentPage*e.perPage?e.currentPage*e.perPage:e.total)),r=_((()=>Math.ceil(e.total/e.perPage))),l=_((()=>1===e.currentPage?1:e.currentPage===r.value?r.value-e.maxVisibleButtons+1:e.currentPage-1)),d=_((()=>Math.min(l.value+e.maxVisibleButtons-1,r.value))),o=_((()=>{const e=[];for(let t=l.value;t<=d.value;t+=1)t>0&&e.push(t);return e})),i=_((()=>1===e.currentPage)),s=_((()=>e.currentPage===r.value)),u=e=>{t("changed",e)};return{currentStart:a,currentEnd:n,totalPages:r,pages:o,isInFirstPage:i,isInLastPage:s,goToPageNumber:u,gotoFirstPage:()=>u(1),gotoLastPage:()=>u(r.value),gotoNextPage:()=>u(e.currentPage>=r.value?r.value:e.currentPage+1),gotoPreviousPage:()=>u(e.currentPage<=1?1:e.currentPage-1),showDots:(e="left")=>{const t="left"===e?1:r.value,a="left"===e?2:r.value-1;return!o.value.includes(t)||!o.value.includes(a)}}}});const ae={key:0,class:"dt__pagination dt-bg-white dt-flex dt-items-center dt-justify-between"},ne={class:"dt-hidden sm:dt-flex-1 sm:dt-flex sm:dt-items-center sm:dt-justify-between"},re=q(" Showing "),le=["textContent"],de=q(" to "),oe=["textContent"],ie=q(" of "),se=["textContent"],ue=q(" results. "),pe=g("span",{class:"dt-sr-only"},"Go to first",-1),ge=q(" « "),ce=g("span",{class:"dt-sr-only"},"Previous",-1),fe=q(" ‹ "),ve=q(" 1 "),be=q(" ... "),me=q(" ... "),ye=g("span",{class:"dt-sr-only"},"Next",-1),_e=q(" › "),he=g("span",{class:"dt-sr-only"},"Go to Last",-1),Pe=q(" » ");te.render=function(e,t,a,n,r,l){const d=f("PaginationInfo"),o=f("pagination-link"),i=f("PaginationButtons");return e.totalPages?(u(),p("div",ae,[g("div",ne,[e.total?(u(),P(d,{key:0},{default:w((()=>[y(e.$slots,"pagination-info",{start:e.currentStart,end:e.currentEnd,total:e.total},(()=>[re,g("span",{class:"dt-font-medium",textContent:x(e.currentStart)},null,8,le),de,g("span",{class:"dt-font-medium",textContent:x(e.currentEnd)},null,8,oe),ie,g("span",{class:"dt-font-medium",textContent:x(e.total)},null,8,se),ue]))])),_:3})):C("",!0),e.totalPages>1?(u(),P(i,{key:1},{default:w((()=>[v(o,{key:"page_first",disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:k(e.gotoFirstPage,["prevent"])},{default:w((()=>[pe,ge])),_:1},8,["disabled","onClick"]),v(o,{key:"page_previous",disabled:e.isInFirstPage,onClick:k(e.gotoPreviousPage,["prevent"])},{default:w((()=>[ce,fe])),_:1},8,["disabled","onClick"]),e.showDots("left")?(u(),p(I,{key:0},[v(o,{key:"page_1",class:"dt-block sm:dt-hidden",disabled:e.isInFirstPage,active:e.isInFirstPage,onClick:k(e.gotoFirstPage,["prevent"])},{default:w((()=>[ve])),_:1},8,["disabled","active","onClick"]),v(o,{key:"page_divider_left",class:"sm:dt-hidden"},{default:w((()=>[be])),_:1})],64)):C("",!0),(u(!0),p(I,null,T(e.pages,(t=>(u(),P(o,{key:`pages_${t}`,class:"dt-hidden md:dt-inline-block",active:t===e.currentPage,disabled:t===e.currentPage,onClick:k((a=>e.goToPageNumber(t)),["prevent"])},{default:w((()=>[q(x(t),1)])),_:2},1032,["active","disabled","onClick"])))),128)),e.showDots("right")?(u(),p(I,{key:1},[v(o,{key:"page_divider_right",class:"sm:dt-hidden"},{default:w((()=>[me])),_:1}),v(o,{key:`page_${e.totalPages}`,class:"sm:dt-hidden",disabled:e.isInLastPage,active:e.isInLastPage,onClick:k(e.gotoLastPage,["prevent"])},{default:w((()=>[q(x(e.totalPages),1)])),_:1},8,["disabled","active","onClick"])],64)):C("",!0),v(o,{key:"page_next",disabled:e.isInLastPage,onClick:k(e.gotoNextPage,["prevent"])},{default:w((()=>[ye,_e])),_:1},8,["disabled","onClick"]),v(o,{key:"page_last",disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:k(e.gotoLastPage,["prevent"])},{default:w((()=>[he,Pe])),_:1},8,["disabled","onClick"])])),_:1})):C("",!0)])])):C("",!0)};var we=s({name:"PaginationSize",props:{value:{type:[Number,String],required:!0},options:{type:Array,required:!0}},emits:["input"]});const xe={class:"dt__pagination_size_wrapper dt-w-full dt-flex dt-justify-end sm:dt-w-auto"},Ce=g("label",{for:"location",class:"dt-sr-only"},"Per page",-1),ke=["value"],Ie=["value","selected","textContent"];we.render=function(e,t,a,n,r,l){return u(),p("div",xe,[g("div",null,[Ce,g("select",{value:e.value,name:"per_page",class:"dt__pagination_size dt-block dt-w-full dt-pl-3 dt-pr-5 dt-py-2 dt-text-base dt-border\n dt-border-gray-300 sm:dt-text-sm dt-rounded-md dt-outline-none focus:dt-ring-1 focus:dt-ring-inset",onInput:t[0]||(t[0]=t=>e.$emit("input",t.target.value))},[(u(!0),p(I,null,T(e.options,(t=>(u(),p("option",{key:`per_page_${t}`,value:t,selected:t===e.value,textContent:x(t)},null,8,Ie)))),128))],40,ke)])])};var Te=s({name:"TopPaginationWrapper",props:{withPagination:{type:Boolean,required:!1,default:!1}}});Te.render=function(e,t,a,n,r,l){return u(),p("div",{class:$(["dt__pagination_wrapper--top md:dt-flex xs:dt-flex-col dt-items-center",{"dt-bg-white dt-py-4 dt-px-4 sm:dt-px-6":e.withPagination}])},[y(e.$slots,"default")],2)};var qe=s({name:"TableBodyCell"});const $e={class:"dt__table__tbody_td dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};qe.render=function(e,t,a,n,r,l){return u(),p("td",$e,[y(e.$slots,"default")])};var Be=s({name:"TableHeadCell"});const Se={scope:"col",class:"dt__table__thead__th dt-px-6 dt-py-3 dt-text-left dt-text-xs dt-font-medium dt-text-gray-500 dt-uppercase dt-tracking-wider"};Be.render=function(e,t,a,n,r,l){return u(),p("th",Se,[y(e.$slots,"default")])};var Oe=s({name:"TableRow",props:{rowIndex:{type:Number,required:!0},striped:{type:Boolean,required:!1,default:!1}}});Oe.render=function(e,t,a,n,r,l){return u(),p("tr",{class:$(["dt__table__row",e.striped&&e.rowIndex%2?"dt-bg-gray-50":"dt-bg-white"])},[y(e.$slots,"default")],2)};var Le=s({name:"TableWrapper"});const je={class:"dt__table_wrapper dt-overflow-auto"},Ne={class:"dt__table dt-min-w-full dt-divide-y dt-divide-gray-200"};Le.render=function(e,t,a,n,r,l){return u(),p("div",je,[g("table",Ne,[y(e.$slots,"default")])])};var Fe=s({name:"TBody"});const ze={class:"dt__table__tbody"};Fe.render=function(e,t,a,n,r,l){return u(),p("tbody",ze,[y(e.$slots,"default")])};var De=s({name:"THead"});const We={class:"dt__table__thead dt-bg-gray-50"},He={class:"dt__table__thead__tr"};De.render=function(e,t,a,n,r,l){return u(),p("thead",We,[g("tr",He,[y(e.$slots,"default")])])};const Qe=[5,10,15,25,50,75,100],Re=s({name:"DataTable",components:{TableHeadCell:Be,TableBodyCell:qe,TBody:Fe,TableRow:Oe,THead:De,BottomPaginationWrapper:V,TableWrapper:Le,PaginationSize:we,TopPaginationWrapper:Te,Filter:z,Loading:M,Pagination:te},props:{rows:{type:Array,required:!0},columns:{type:Object,required:!1,default:null},pagination:{type:Object,required:!1,default:null},striped:{type:Boolean,required:!1,default:!1},sn:{type:Boolean,required:!1,default:!1},filter:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},perPageOptions:{type:Array,required:!1,default:()=>Qe},query:{type:Object,required:!1,default:()=>({})},topPagination:{type:Boolean,required:!1,default:!1},bottomPagination:{type:Boolean,required:!1,default:!0}},emits:["loadData"],setup(e,{emit:t}){var a,n;const r=B({page:(null==(a=e.pagination)?void 0:a.page)||1,search:e.query.search||"",per_page:(null==(n=e.pagination)?void 0:n.per_page)||10}),l=_((()=>!!e.pagination)),d=_((()=>{var t;return(null==(t=e.pagination)?void 0:t.total)||e.rows.length})),s=_((()=>e.rows)),u=_((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>{return i(o({},e),{[t]:(a=t,a.toLowerCase().replace(/[-_]/g," ").split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "))});var a}),{}))),p=_((()=>l.value?r.value.per_page*(r.value.page-1):0));S((()=>o({},r.value)),(()=>{t("loadData",r.value)}),{deep:!0,immediate:!0});const g=((e,t=400)=>{let a;return(...n)=>{clearTimeout(a),a=setTimeout((()=>e(...n)),t)}})((e=>{r.value=i(o({},r.value),{page:1,search:e})}));return{tableQuery:r,showPagination:l,totalData:d,tableRows:s,tableColumns:u,paginatedRowIndex:p,uniqueId:()=>Math.floor(100*Math.random()),handlePageChange:e=>{r.value.page=e},handleOnSearchChange:g,handleOnPaginationSizeChange:e=>{r.value=i(o({},r.value),{page:1,per_page:e})}}}});const Me={class:"data-table dt-flex dt-flex-col"},Ae={class:"dt-align-middle dt-min-w-full"},Ee={class:"dt__wrapper dt-relative dt-overflow-hidden sm:dt-rounded-lg"};Re.render=function(e,t,a,n,r,l){const d=f("Filter"),o=f("Loading"),i=f("Pagination"),s=f("PaginationSize"),c=f("TopPaginationWrapper"),b=f("TableHeadCell"),m=f("THead"),_=f("TableBodyCell"),h=f("TableRow"),k=f("TBody"),q=f("TableWrapper"),$=f("pagination"),B=f("BottomPaginationWrapper");return u(),p("div",Me,[g("div",Ae,[e.filter&&e.topPagination?(u(),P(d,{key:0,search:e.tableQuery.search,onInput:e.handleOnSearchChange},null,8,["search","onInput"])):C("",!0),g("div",Ee,[e.loading?y(e.$slots,"loading",{key:0},(()=>[v(o)])):C("",!0),e.showPagination?(u(),P(c,{key:1,"with-pagination":e.topPagination},{default:w((()=>[e.topPagination?(u(),P(i,{key:0,class:"dt-flex-1 dt-pr-4",total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])):C("",!0),e.filter&&!e.topPagination?(u(),P(d,{key:1,search:e.tableQuery.search,onInput:e.handleOnSearchChange},null,8,["search","onInput"])):C("",!0),v(s,{value:e.tableQuery.per_page,options:e.perPageOptions,onInput:e.handleOnPaginationSizeChange},null,8,["value","options","onInput"])])),_:1},8,["with-pagination"])):C("",!0),v(q,null,{default:w((()=>[v(m,null,{default:w((()=>[e.sn?y(e.$slots,"thead-sn",{key:0},(()=>[v(b,{textContent:x("S.N.")},null,8,["textContent"])])):C("",!0),y(e.$slots,"thead",{column:e.tableColumns},(()=>[(u(!0),p(I,null,T(e.tableColumns,((e,t)=>(u(),P(b,{key:`datatable-thead-th-${t}`,textContent:x(e)},null,8,["textContent"])))),128))]))])),_:3}),v(k,null,{default:w((()=>[(u(!0),p(I,null,T(e.tableRows,((t,a)=>(u(),P(h,{key:`datatable-row-${e.uniqueId()}-${a}`,"row-index":a,striped:e.striped},{default:w((()=>[e.sn?y(e.$slots,"tbody-sn",{key:0,sn:a+1},(()=>[v(_,{textContent:x(a+1+e.paginatedRowIndex)},null,8,["textContent"])])):C("",!0),y(e.$slots,"tbody",{index:a,row:t},(()=>[(u(!0),p(I,null,T(e.tableColumns,((a,n)=>(u(),P(_,{key:`datatable-tbody-td-${e.uniqueId()}-${n}`,name:a,textContent:x(t[n])},null,8,["name","textContent"])))),128))]))])),_:2},1032,["row-index","striped"])))),128))])),_:3})])),_:3}),e.showPagination&&e.bottomPagination?(u(),P(B,{key:2},{default:w((()=>[v($,{total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])])),_:1})):C("",!0)])])])};export{Re as DataTable,te as Pagination,ee as PaginationLink,qe as TableBody,qe as TableBodyCell,Be as TableHead,Be as TableHeadCell}; |
@@ -1,1 +0,1 @@ | ||
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,a)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,__spreadValues=(e,t)=>{for(var a in t||(t={}))__hasOwnProp.call(t,a)&&__defNormalProp(e,a,t[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(t))__propIsEnum.call(t,a)&&__defNormalProp(e,a,t[a]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@jobinsjp/vue3-datatable"]={},e.Vue)}(this,(function(e,t){"use strict";const a={},o={xmlns:"http://www.w3.org/2000/svg",class:"dt-h-5 dt-w-5",viewBox:"0 0 20 20",fill:"currentColor"},r=t.createVNode("path",{"fill-rule":"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z","clip-rule":"evenodd"},null,-1);a.render=function(e,a){return t.openBlock(),t.createBlock("svg",o,[r])};var d=t.defineComponent({name:"Loading"});const n=t.withScopeId("data-v-f17dff8e");t.pushScopeId("data-v-f17dff8e");const l={class:"spinner dt-absolute dt-h-full dt-w-full dt-flex dt-justify-center"},s=t.createVNode("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1),c=t.createVNode("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1);t.popScopeId();const i=n(((e,a,o,r,d,n)=>(t.openBlock(),t.createBlock("div",l,[s,c]))));d.render=i,d.__scopeId="data-v-f17dff8e";var u=t.defineComponent({name:"PaginationLink",props:{active:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},setup:e=>({linkClasses:t.computed((()=>e.active?"dt-bg-gray-200 dt-border-gray-300 dt-text-gray-800 hover:dt-bg-gray-200":e.disabled?"dt-cursor-not-allowed dt-text-gray-400":"dt-border-gray-300 dt-bg-white dt-text-gray-500 hover:dt-bg-gray-50"))})});u.render=function(e,a,o,r,d,n){return t.openBlock(),t.createBlock("a",t.mergeProps({href:"#",class:["dt-relative dt-inline-flex dt-items-center dt-px-4 dt-py-2 dt-border dt-text-sm dt-font-medium",e.linkClasses]},t.toHandlers(__spreadValues({},e.$attrs))),[t.renderSlot(e.$slots,"default")],16)};const p="left";var g=t.defineComponent({name:"Pagination",components:{PaginationLink:u},props:{total:{type:Number,required:!0},perPage:{type:Number,required:!0},currentPage:{type:Number,required:!1,default:1},maxVisibleButtons:{type:Number,required:!1,default:5}},emits:["changed"],setup(e,{emit:a}){const o=t.computed((()=>(e.currentPage-1)*e.perPage+1)),r=t.computed((()=>e.total>e.currentPage*e.perPage?e.currentPage*e.perPage:e.total)),d=t.computed((()=>Math.ceil(e.total/e.perPage))),n=t.computed((()=>1===e.currentPage?1:e.currentPage===d.value?d.value-e.maxVisibleButtons+1:e.currentPage-1)),l=t.computed((()=>Math.min(n.value+e.maxVisibleButtons-1,d.value))),s=t.computed((()=>{const e=[];for(let t=n.value;t<=l.value;t+=1)t>0&&e.push(t);return e})),c=t.computed((()=>1===e.currentPage)),i=t.computed((()=>e.currentPage===d.value)),u=e=>{a("changed",e)};return{currentStart:o,currentEnd:r,totalPages:d,pages:s,isInFirstPage:c,isInLastPage:i,goToPageNumber:u,gotoFirstPage:()=>u(1),gotoLastPage:()=>u(d.value),gotoNextPage:()=>u(e.currentPage>=d.value?d.value:e.currentPage+1),gotoPreviousPage:()=>u(e.currentPage<=1?1:e.currentPage-1),showDots:(e=p)=>{const t=e===p?1:d.value,a=e===p?2:d.value-1;return!s.value.includes(t)||!s.value.includes(a)}}}});const m={key:0,class:"dt-bg-white dt-px-4 dt-py-3 dt-flex dt-items-center dt-justify-between dt-border-t dt-border-gray-200 sm:dt-px-6"},f={class:"dt-hidden sm:dt-flex-1 sm:dt-flex sm:dt-items-center sm:dt-justify-between"},b={class:"dt-text-sm dt-text-gray-700"},y=t.createTextVNode(" Showing "),v=t.createTextVNode(" to "),h=t.createTextVNode(" of "),P=t.createTextVNode(" results. "),x={key:0},k={class:"dt-relative dt-z-0 dt-inline-flex dt-rounded-md dt-shadow-sm dt--space-x-px","aria-label":"Pagination"},w=t.createVNode("span",{class:"dt-sr-only"},"Go to first",-1),N=t.createTextVNode(" « "),C=t.createVNode("span",{class:"dt-sr-only"},"Previous",-1),V=t.createTextVNode(" ‹ "),_=t.createTextVNode(" 1 "),B=t.createTextVNode(" ... "),S=t.createTextVNode(" ... "),O=t.createVNode("span",{class:"dt-sr-only"},"Next",-1),I=t.createTextVNode(" › "),T=t.createVNode("span",{class:"dt-sr-only"},"Go to Last",-1),D=t.createTextVNode(" » ");g.render=function(e,a,o,r,d,n){const l=t.resolveComponent("pagination-link");return e.totalPages?(t.openBlock(),t.createBlock("div",m,[t.createVNode("div",f,[t.withDirectives(t.createVNode("div",null,[t.createVNode("p",b,[t.renderSlot(e.$slots,"pagination-info",{currentStart:e.currentStart,currentEnd:e.currentEnd,total:e.total},(()=>[y,t.createVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.currentStart)},null,8,["textContent"]),v,t.createVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.currentEnd)},null,8,["textContent"]),h,t.createVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.total)},null,8,["textContent"]),P]))])],512),[[t.vShow,e.total]]),e.totalPages>1?(t.openBlock(),t.createBlock("div",x,[t.createVNode("nav",k,[t.createVNode(l,{disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:t.withModifiers(e.gotoFirstPage,["prevent"])},{default:t.withCtx((()=>[w,N])),_:1},8,["disabled","onClick"]),t.createVNode(l,{disabled:e.isInFirstPage,onClick:t.withModifiers(e.gotoPreviousPage,["prevent"])},{default:t.withCtx((()=>[C,V])),_:1},8,["disabled","onClick"]),e.showDots("left")?(t.openBlock(),t.createBlock(t.Fragment,{key:0},[t.createVNode(l,{class:"dt-block sm:dt-hidden",disabled:e.isInFirstPage,active:e.isInFirstPage,onClick:t.withModifiers(e.gotoFirstPage,["prevent"])},{default:t.withCtx((()=>[_])),_:1},8,["disabled","active","onClick"]),t.createVNode(l,{class:"sm:dt-hidden"},{default:t.withCtx((()=>[B])),_:1})],64)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.pages,((a,o)=>(t.openBlock(),t.createBlock(l,{key:`pages_${o}`,class:"dt-hidden md:dt-inline-block",active:a===e.currentPage,disabled:a===e.currentPage,onClick:t.withModifiers((t=>e.goToPageNumber(a)),["prevent"])},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(a),1)])),_:2},1032,["active","disabled","onClick"])))),128)),e.showDots("right")?(t.openBlock(),t.createBlock(t.Fragment,{key:1},[t.createVNode(l,{class:"sm:dt-hidden"},{default:t.withCtx((()=>[S])),_:1}),t.createVNode(l,{class:"sm:dt-hidden",disabled:e.isInLastPage,active:e.isInLastPage,onClick:t.withModifiers(e.gotoLastPage,["prevent"])},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.totalPages),1)])),_:1},8,["disabled","active","onClick"])],64)):t.createCommentVNode("",!0),t.createVNode(l,{disabled:e.isInLastPage,onClick:t.withModifiers(e.gotoNextPage,["prevent"])},{default:t.withCtx((()=>[O,I])),_:1},8,["disabled","onClick"]),t.createVNode(l,{disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:t.withModifiers(e.gotoLastPage,["prevent"])},{default:t.withCtx((()=>[T,D])),_:1},8,["disabled","onClick"])])])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)};const q={},L={class:"dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};q.render=function(e,a){return t.openBlock(),t.createBlock("td",L,[t.renderSlot(e.$slots,"default")])};const j={},$={scope:"col",class:"dt-px-6 dt-py-3 dt-text-left dt-text-xs dt-font-medium dt-text-gray-500 dt-uppercase dt-tracking-wider"};j.render=function(e,a){return t.openBlock(),t.createBlock("th",$,[t.renderSlot(e.$slots,"default")])};const F=[5,10,15,25,50,75,100],M=t.defineComponent({components:{SearchIcon:a,Loading:d,Pagination:g,TableBody:q,TableHead:j},props:{rows:{type:Array,required:!0},columns:{type:Object,required:!1,default:null},pagination:{type:Object,required:!1,default:null},striped:{type:Boolean,required:!1,default:!1},sn:{type:Boolean,required:!1,default:!1},filter:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},perPageOptions:{type:Array,required:!1,default:()=>F},query:{type:Object,required:!1,default:()=>({})}},emits:["loadData"],setup(e,{emit:a}){var o,r;const d=t.ref({page:(null==(o=e.pagination)?void 0:o.page)||1,search:e.query.search||"",per_page:(null==(r=e.pagination)?void 0:r.per_page)||10}),n=t.computed((()=>!!e.pagination)),l=t.computed((()=>{var t;return(null==(t=e.pagination)?void 0:t.total)||e.rows.length})),s=t.computed((()=>e.rows)),c=t.computed((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>__spreadProps(__spreadValues({},e),{[t]:t})),{}))),i=t.computed((()=>n.value?d.value.per_page*(d.value.page-1):0));t.watch((()=>__spreadValues({},d.value)),(()=>{a("loadData",d.value)}),{deep:!0,immediate:!0});const u=((e,t=400)=>{let a;return(...o)=>{clearTimeout(a),a=setTimeout((()=>e(...o)),t)}})((e=>{d.value=__spreadProps(__spreadValues({},d.value),{page:1,search:e.target.value})}));return{tableQuery:d,showPagination:n,totalData:l,tableRows:s,tableColumns:c,paginatedRowIndex:i,uniqueId:()=>Math.floor(100*Math.random()),handlePageChange:e=>{d.value.page=e},handleOnSearchChange:u,handleOnChange:e=>{const{name:t,value:a}=e.target;d.value=__spreadProps(__spreadValues({},d.value),{page:1,[t]:a})}}}});const Q={class:"data-table dt-flex dt-flex-col"},E={class:"dt-align-middle dt-min-w-full"},R={key:0,class:"dt-filter-wrapper dt-mb-3 dt-w-full"},z={class:"dt-w-64"},A=t.createVNode("label",{for:"email",class:"dt-sr-only"},"Search",-1),H={class:"dt-relative dt-rounded-md dt-shadow-sm"},G={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"},J={class:"table-wrapper dt-relative dt-shadow dt-overflow-hidden dt-border-b dt-border-gray-200 sm:dt-rounded-lg"},K={key:1,class:"pagination-wrapper md:dt-flex smdt-flex-col dt-bg-white dt-items-center"},U={class:"dt-pr-4 dt-w-full dt-pb-3 dt-flex dt-justify-end sm:dt-pr-6 sm:dt-pb-0 sm:dt-w-auto"},W={class:""},X=t.createVNode("label",{for:"location",class:"dt-sr-only"},"Per page",-1),Y={class:"table-container dt-overflow-auto"},Z={class:"dt-min-w-full dt-divide-y dt-divide-gray-200"},ee={class:"dt-bg-gray-50"},te={key:2,class:"pagination-wrapper"};M.render=function(e,a,o,r,d,n){const l=t.resolveComponent("search-icon"),s=t.resolveComponent("Loading"),c=t.resolveComponent("pagination"),i=t.resolveComponent("table-head"),u=t.resolveComponent("table-body");return t.openBlock(),t.createBlock("div",Q,[t.createVNode("div",E,[e.filter?(t.openBlock(),t.createBlock("div",R,[t.createVNode("div",z,[A,t.createVNode("div",H,[t.createVNode("input",{value:e.tableQuery.search,type:"search",name:"search",class:"focus:dt-ring-0 dt-block dt-w-full dt-pr-10 sm:dt-text-sm dt-border-gray-300 dt-rounded-md",onInput:a[1]||(a[1]=(...t)=>e.handleOnSearchChange&&e.handleOnSearchChange(...t))},null,40,["value"]),t.createVNode("div",G,[t.createVNode(l,{class:"dt-text-gray-400"})])])])])):t.createCommentVNode("",!0),t.createVNode("div",J,[e.loading?t.renderSlot(e.$slots,"loading",{key:0},(()=>[t.createVNode(s)])):t.createCommentVNode("",!0),e.showPagination?(t.openBlock(),t.createBlock("div",K,[t.createVNode(c,{class:"dt-flex-1",total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"]),t.createVNode("div",U,[t.createVNode("div",W,[X,t.createVNode("select",{value:e.tableQuery.per_page,name:"per_page",class:"dt-block dt-w-full dt-pl-3 dt-pr-10 dt-py-2 dt-text-base dt-border-gray-300 sm:dt-text-sm dt-rounded-md",onInput:a[2]||(a[2]=(...t)=>e.handleOnChange&&e.handleOnChange(...t))},[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.perPageOptions,(a=>(t.openBlock(),t.createBlock("option",{key:`per_page_${a}`,value:a,selected:a===e.tableQuery.per_page,textContent:t.toDisplayString(a)},null,8,["value","selected","textContent"])))),128))],40,["value"])])])])):t.createCommentVNode("",!0),t.createVNode("div",Y,[t.createVNode("table",Z,[t.createVNode("thead",ee,[t.createVNode("tr",null,[e.sn?t.renderSlot(e.$slots,"thead-sn",{key:0},(()=>[t.createVNode(i,{textContent:t.toDisplayString("S.N.")},null,8,["textContent"])])):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"thead",{column:e.tableColumns},(()=>[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.tableColumns,((e,a)=>(t.openBlock(),t.createBlock(i,{key:`datatable-thead-th-${a}`,textContent:t.toDisplayString(e)},null,8,["textContent"])))),128))]))])]),t.createVNode("tbody",null,[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.tableRows,((a,o)=>(t.openBlock(),t.createBlock("tr",{key:`datatable-tbody-${e.uniqueId()}-${o}`,class:e.striped&&o%2?"dt-bg-gray-50":"dt-bg-white"},[e.sn?t.renderSlot(e.$slots,"tbody-sn",{key:0,sn:o+1},(()=>[t.createVNode(u,{textContent:t.toDisplayString(o+1+e.paginatedRowIndex)},null,8,["textContent"])])):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"tbody",{index:o,row:a},(()=>[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.tableColumns,((o,r)=>(t.openBlock(),t.createBlock(u,{key:`datatable-tbody-td-${e.uniqueId()}-${r}`,name:o,textContent:t.toDisplayString(a[r])},null,8,["name","textContent"])))),128))]))],2)))),128))])])]),e.showPagination?(t.openBlock(),t.createBlock("div",te,[t.createVNode(c,{total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])])):t.createCommentVNode("",!0)])])])},e.DataTable=M,e.Pagination=g,e.PaginationLink=u,e.TableBody=q,e.TableHead=j,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"})); | ||
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@jobinsjp/vue3-datatable"]={},e.Vue)}(this,(function(e,t){"use strict";var n=t.defineComponent({name:"SearchIcon"});const a={xmlns:"http://www.w3.org/2000/svg",class:"dt-h-5 dt-w-5",viewBox:"0 0 20 20",fill:"currentColor"},o=[t.createElementVNode("path",{"fill-rule":"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z","clip-rule":"evenodd"},null,-1)];n.render=function(e,n,r,l,d,i){return t.openBlock(),t.createElementBlock("svg",a,o)};var r=t.defineComponent({name:"SearchInput",props:{value:{type:String,required:!0}}});const l=["value"];r.render=function(e,n,a,o,r,d){return t.openBlock(),t.createElementBlock("input",t.mergeProps({value:e.value,type:"search",name:"search",class:"dt__filter__search dt-block dt-border dt-border-gray-300 dt-pr-10 dt-px-2 dt-py-2\n dt-rounded-md dt-w-full dt-outline-none focus:dt-ring-1 focus:dt-ring-inset sm:dt-text-sm"},e.$attrs),null,16,l)};var d=t.defineComponent({name:"Filter",components:{SearchInput:r,SearchIcon:n},props:{search:{type:String,required:!0}},emits:["input"]});const i={class:"dt__filter dt-mb-3 dt-w-full"},s={class:"dt-w-64"},c=t.createElementVNode("label",{for:"email",class:"dt-sr-only"},"Search",-1),p={class:"dt-relative dt-rounded-md dt-shadow-sm"},u={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"};d.render=function(e,n,a,o,r,l){const d=t.resolveComponent("SearchInput"),m=t.resolveComponent("SearchIcon");return t.openBlock(),t.createElementBlock("div",i,[t.createElementVNode("div",s,[c,t.createElementVNode("div",p,[t.createVNode(d,{value:e.search,onInput:n[0]||(n[0]=t=>e.$emit("input",t.target.value))},null,8,["value"]),t.createElementVNode("div",u,[t.createVNode(m,{class:"dt-text-gray-400"})])])])])};var m=t.defineComponent({name:"Loading"});t.pushScopeId("data-v-685865e4");const g={class:"dt__loading dt-absolute dt-h-full dt-w-full"},f=[t.createElementVNode("div",{class:"dt-flex dt-justify-center dt-items-center"},[t.createElementVNode("div",{class:"dt__loading_item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"}),t.createElementVNode("div",{class:"dt__loading_item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"})],-1)];t.popScopeId(),m.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",g,f)},m.__scopeId="data-v-685865e4";var _=t.defineComponent({name:"BottomPaginationWrapper"});const v={class:"dt__pagination_wrapper--bottom dt-bg-white dt-shadow-inner"},y={class:"dt-px-4 sm:dt-px-6 dt-py-4"};_.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",v,[t.createElementVNode("div",y,[t.renderSlot(e.$slots,"default")])])};var b=t.defineComponent({name:"PaginationButtons"});const h={class:"dt__pagination__nav dt-relative dt-z-0 dt-inline-flex dt-rounded-md dt-shadow-sm dt--space-x-px","aria-label":"Pagination"};b.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("nav",h,[t.renderSlot(e.$slots,"default")])};var k=t.defineComponent({name:"PaginationInfo"});const C={class:"dt__pagination__info"},P={class:"dt-text-sm dt-text-gray-700"};k.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",C,[t.createElementVNode("p",P,[t.renderSlot(e.$slots,"default")])])};var w=t.defineComponent({name:"PaginationLink",props:{active:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},setup:e=>({linkClasses:t.computed((()=>e.active?"dt-bg-gray-200 dt-border-gray-300 dt-text-gray-800 hover:dt-bg-gray-200":e.disabled?"dt-cursor-not-allowed dt-text-gray-400":"dt-border-gray-300 dt-bg-white dt-text-gray-500 hover:dt-bg-gray-50"))})});w.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("a",t.mergeProps({href:"#",class:["dt__pagination__link dt-relative dt-inline-flex dt-items-center dt-px-4 dt-py-2 dt-border dt-text-sm dt-font-medium",e.linkClasses]},t.toHandlers(__spreadValues({},e.$attrs))),[t.renderSlot(e.$slots,"default")],16)};const x="left";var B=t.defineComponent({name:"Pagination",components:{PaginationButtons:b,PaginationInfo:k,PaginationLink:w},props:{total:{type:Number,required:!0},perPage:{type:Number,required:!0},currentPage:{type:Number,required:!1,default:1},maxVisibleButtons:{type:Number,required:!1,default:5}},emits:["changed"],setup(e,{emit:n}){const a=t.computed((()=>(e.currentPage-1)*e.perPage+1)),o=t.computed((()=>e.total>e.currentPage*e.perPage?e.currentPage*e.perPage:e.total)),r=t.computed((()=>Math.ceil(e.total/e.perPage))),l=t.computed((()=>1===e.currentPage?1:e.currentPage===r.value?r.value-e.maxVisibleButtons+1:e.currentPage-1)),d=t.computed((()=>Math.min(l.value+e.maxVisibleButtons-1,r.value))),i=t.computed((()=>{const e=[];for(let t=l.value;t<=d.value;t+=1)t>0&&e.push(t);return e})),s=t.computed((()=>1===e.currentPage)),c=t.computed((()=>e.currentPage===r.value)),p=e=>{n("changed",e)};return{currentStart:a,currentEnd:o,totalPages:r,pages:i,isInFirstPage:s,isInLastPage:c,goToPageNumber:p,gotoFirstPage:()=>p(1),gotoLastPage:()=>p(r.value),gotoNextPage:()=>p(e.currentPage>=r.value?r.value:e.currentPage+1),gotoPreviousPage:()=>p(e.currentPage<=1?1:e.currentPage-1),showDots:(e=x)=>{const t=e===x?1:r.value,n=e===x?2:r.value-1;return!i.value.includes(t)||!i.value.includes(n)}}}});const N={key:0,class:"dt__pagination dt-bg-white dt-flex dt-items-center dt-justify-between"},V={class:"dt-hidden sm:dt-flex-1 sm:dt-flex sm:dt-items-center sm:dt-justify-between"},S=t.createTextVNode(" Showing "),E=["textContent"],T=t.createTextVNode(" to "),I=["textContent"],q=t.createTextVNode(" of "),$=["textContent"],O=t.createTextVNode(" results. "),D=t.createElementVNode("span",{class:"dt-sr-only"},"Go to first",-1),L=t.createTextVNode(" « "),j=t.createElementVNode("span",{class:"dt-sr-only"},"Previous",-1),F=t.createTextVNode(" ‹ "),M=t.createTextVNode(" 1 "),z=t.createTextVNode(" ... "),H=t.createTextVNode(" ... "),W=t.createElementVNode("span",{class:"dt-sr-only"},"Next",-1),Q=t.createTextVNode(" › "),R=t.createElementVNode("span",{class:"dt-sr-only"},"Go to Last",-1),A=t.createTextVNode(" » ");B.render=function(e,n,a,o,r,l){const d=t.resolveComponent("PaginationInfo"),i=t.resolveComponent("pagination-link"),s=t.resolveComponent("PaginationButtons");return e.totalPages?(t.openBlock(),t.createElementBlock("div",N,[t.createElementVNode("div",V,[e.total?(t.openBlock(),t.createBlock(d,{key:0},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"pagination-info",{start:e.currentStart,end:e.currentEnd,total:e.total},(()=>[S,t.createElementVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.currentStart)},null,8,E),T,t.createElementVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.currentEnd)},null,8,I),q,t.createElementVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.total)},null,8,$),O]))])),_:3})):t.createCommentVNode("",!0),e.totalPages>1?(t.openBlock(),t.createBlock(s,{key:1},{default:t.withCtx((()=>[t.createVNode(i,{key:"page_first",disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:t.withModifiers(e.gotoFirstPage,["prevent"])},{default:t.withCtx((()=>[D,L])),_:1},8,["disabled","onClick"]),t.createVNode(i,{key:"page_previous",disabled:e.isInFirstPage,onClick:t.withModifiers(e.gotoPreviousPage,["prevent"])},{default:t.withCtx((()=>[j,F])),_:1},8,["disabled","onClick"]),e.showDots("left")?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createVNode(i,{key:"page_1",class:"dt-block sm:dt-hidden",disabled:e.isInFirstPage,active:e.isInFirstPage,onClick:t.withModifiers(e.gotoFirstPage,["prevent"])},{default:t.withCtx((()=>[M])),_:1},8,["disabled","active","onClick"]),t.createVNode(i,{key:"page_divider_left",class:"sm:dt-hidden"},{default:t.withCtx((()=>[z])),_:1})],64)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.pages,(n=>(t.openBlock(),t.createBlock(i,{key:`pages_${n}`,class:"dt-hidden md:dt-inline-block",active:n===e.currentPage,disabled:n===e.currentPage,onClick:t.withModifiers((t=>e.goToPageNumber(n)),["prevent"])},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(n),1)])),_:2},1032,["active","disabled","onClick"])))),128)),e.showDots("right")?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createVNode(i,{key:"page_divider_right",class:"sm:dt-hidden"},{default:t.withCtx((()=>[H])),_:1}),t.createVNode(i,{key:`page_${e.totalPages}`,class:"sm:dt-hidden",disabled:e.isInLastPage,active:e.isInLastPage,onClick:t.withModifiers(e.gotoLastPage,["prevent"])},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.totalPages),1)])),_:1},8,["disabled","active","onClick"])],64)):t.createCommentVNode("",!0),t.createVNode(i,{key:"page_next",disabled:e.isInLastPage,onClick:t.withModifiers(e.gotoNextPage,["prevent"])},{default:t.withCtx((()=>[W,Q])),_:1},8,["disabled","onClick"]),t.createVNode(i,{key:"page_last",disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:t.withModifiers(e.gotoLastPage,["prevent"])},{default:t.withCtx((()=>[R,A])),_:1},8,["disabled","onClick"])])),_:1})):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)};var G=t.defineComponent({name:"PaginationSize",props:{value:{type:[Number,String],required:!0},options:{type:Array,required:!0}},emits:["input"]});const U={class:"dt__pagination_size_wrapper dt-w-full dt-flex dt-justify-end sm:dt-w-auto"},J=t.createElementVNode("label",{for:"location",class:"dt-sr-only"},"Per page",-1),K=["value"],X=["value","selected","textContent"];G.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",U,[t.createElementVNode("div",null,[J,t.createElementVNode("select",{value:e.value,name:"per_page",class:"dt__pagination_size dt-block dt-w-full dt-pl-3 dt-pr-5 dt-py-2 dt-text-base dt-border\n dt-border-gray-300 sm:dt-text-sm dt-rounded-md dt-outline-none focus:dt-ring-1 focus:dt-ring-inset",onInput:n[0]||(n[0]=t=>e.$emit("input",t.target.value))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.options,(n=>(t.openBlock(),t.createElementBlock("option",{key:`per_page_${n}`,value:n,selected:n===e.value,textContent:t.toDisplayString(n)},null,8,X)))),128))],40,K)])])};var Y=t.defineComponent({name:"TopPaginationWrapper",props:{withPagination:{type:Boolean,required:!1,default:!1}}});Y.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["dt__pagination_wrapper--top md:dt-flex xs:dt-flex-col dt-items-center",{"dt-bg-white dt-py-4 dt-px-4 sm:dt-px-6":e.withPagination}])},[t.renderSlot(e.$slots,"default")],2)};var Z=t.defineComponent({name:"TableBodyCell"});const ee={class:"dt__table__tbody_td dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};Z.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("td",ee,[t.renderSlot(e.$slots,"default")])};var te=t.defineComponent({name:"TableHeadCell"});const ne={scope:"col",class:"dt__table__thead__th dt-px-6 dt-py-3 dt-text-left dt-text-xs dt-font-medium dt-text-gray-500 dt-uppercase dt-tracking-wider"};te.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("th",ne,[t.renderSlot(e.$slots,"default")])};var ae=t.defineComponent({name:"TableRow",props:{rowIndex:{type:Number,required:!0},striped:{type:Boolean,required:!1,default:!1}}});ae.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("tr",{class:t.normalizeClass(["dt__table__row",e.striped&&e.rowIndex%2?"dt-bg-gray-50":"dt-bg-white"])},[t.renderSlot(e.$slots,"default")],2)};var oe=t.defineComponent({name:"TableWrapper"});const re={class:"dt__table_wrapper dt-overflow-auto"},le={class:"dt__table dt-min-w-full dt-divide-y dt-divide-gray-200"};oe.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("div",re,[t.createElementVNode("table",le,[t.renderSlot(e.$slots,"default")])])};var de=t.defineComponent({name:"TBody"});const ie={class:"dt__table__tbody"};de.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("tbody",ie,[t.renderSlot(e.$slots,"default")])};var se=t.defineComponent({name:"THead"});const ce={class:"dt__table__thead dt-bg-gray-50"},pe={class:"dt__table__thead__tr"};se.render=function(e,n,a,o,r,l){return t.openBlock(),t.createElementBlock("thead",ce,[t.createElementVNode("tr",pe,[t.renderSlot(e.$slots,"default")])])};const ue=[5,10,15,25,50,75,100],me=t.defineComponent({name:"DataTable",components:{TableHeadCell:te,TableBodyCell:Z,TBody:de,TableRow:ae,THead:se,BottomPaginationWrapper:_,TableWrapper:oe,PaginationSize:G,TopPaginationWrapper:Y,Filter:d,Loading:m,Pagination:B},props:{rows:{type:Array,required:!0},columns:{type:Object,required:!1,default:null},pagination:{type:Object,required:!1,default:null},striped:{type:Boolean,required:!1,default:!1},sn:{type:Boolean,required:!1,default:!1},filter:{type:Boolean,required:!1,default:!1},loading:{type:Boolean,required:!1,default:!1},perPageOptions:{type:Array,required:!1,default:()=>ue},query:{type:Object,required:!1,default:()=>({})},topPagination:{type:Boolean,required:!1,default:!1},bottomPagination:{type:Boolean,required:!1,default:!0}},emits:["loadData"],setup(e,{emit:n}){var a,o;const r=t.ref({page:(null==(a=e.pagination)?void 0:a.page)||1,search:e.query.search||"",per_page:(null==(o=e.pagination)?void 0:o.per_page)||10}),l=t.computed((()=>!!e.pagination)),d=t.computed((()=>{var t;return(null==(t=e.pagination)?void 0:t.total)||e.rows.length})),i=t.computed((()=>e.rows)),s=t.computed((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>{return __spreadProps(__spreadValues({},e),{[t]:(n=t,n.toLowerCase().replace(/[-_]/g," ").split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "))});var n}),{}))),c=t.computed((()=>l.value?r.value.per_page*(r.value.page-1):0));t.watch((()=>__spreadValues({},r.value)),(()=>{n("loadData",r.value)}),{deep:!0,immediate:!0});const p=((e,t=400)=>{let n;return(...a)=>{clearTimeout(n),n=setTimeout((()=>e(...a)),t)}})((e=>{r.value=__spreadProps(__spreadValues({},r.value),{page:1,search:e})}));return{tableQuery:r,showPagination:l,totalData:d,tableRows:i,tableColumns:s,paginatedRowIndex:c,uniqueId:()=>Math.floor(100*Math.random()),handlePageChange:e=>{r.value.page=e},handleOnSearchChange:p,handleOnPaginationSizeChange:e=>{r.value=__spreadProps(__spreadValues({},r.value),{page:1,per_page:e})}}}});const ge={class:"data-table dt-flex dt-flex-col"},fe={class:"dt-align-middle dt-min-w-full"},_e={class:"dt__wrapper dt-relative dt-overflow-hidden sm:dt-rounded-lg"};me.render=function(e,n,a,o,r,l){const d=t.resolveComponent("Filter"),i=t.resolveComponent("Loading"),s=t.resolveComponent("Pagination"),c=t.resolveComponent("PaginationSize"),p=t.resolveComponent("TopPaginationWrapper"),u=t.resolveComponent("TableHeadCell"),m=t.resolveComponent("THead"),g=t.resolveComponent("TableBodyCell"),f=t.resolveComponent("TableRow"),_=t.resolveComponent("TBody"),v=t.resolveComponent("TableWrapper"),y=t.resolveComponent("pagination"),b=t.resolveComponent("BottomPaginationWrapper");return t.openBlock(),t.createElementBlock("div",ge,[t.createElementVNode("div",fe,[e.filter&&e.topPagination?(t.openBlock(),t.createBlock(d,{key:0,search:e.tableQuery.search,onInput:e.handleOnSearchChange},null,8,["search","onInput"])):t.createCommentVNode("",!0),t.createElementVNode("div",_e,[e.loading?t.renderSlot(e.$slots,"loading",{key:0},(()=>[t.createVNode(i)])):t.createCommentVNode("",!0),e.showPagination?(t.openBlock(),t.createBlock(p,{key:1,"with-pagination":e.topPagination},{default:t.withCtx((()=>[e.topPagination?(t.openBlock(),t.createBlock(s,{key:0,class:"dt-flex-1 dt-pr-4",total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])):t.createCommentVNode("",!0),e.filter&&!e.topPagination?(t.openBlock(),t.createBlock(d,{key:1,search:e.tableQuery.search,onInput:e.handleOnSearchChange},null,8,["search","onInput"])):t.createCommentVNode("",!0),t.createVNode(c,{value:e.tableQuery.per_page,options:e.perPageOptions,onInput:e.handleOnPaginationSizeChange},null,8,["value","options","onInput"])])),_:1},8,["with-pagination"])):t.createCommentVNode("",!0),t.createVNode(v,null,{default:t.withCtx((()=>[t.createVNode(m,null,{default:t.withCtx((()=>[e.sn?t.renderSlot(e.$slots,"thead-sn",{key:0},(()=>[t.createVNode(u,{textContent:t.toDisplayString("S.N.")},null,8,["textContent"])])):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"thead",{column:e.tableColumns},(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.tableColumns,((e,n)=>(t.openBlock(),t.createBlock(u,{key:`datatable-thead-th-${n}`,textContent:t.toDisplayString(e)},null,8,["textContent"])))),128))]))])),_:3}),t.createVNode(_,null,{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.tableRows,((n,a)=>(t.openBlock(),t.createBlock(f,{key:`datatable-row-${e.uniqueId()}-${a}`,"row-index":a,striped:e.striped},{default:t.withCtx((()=>[e.sn?t.renderSlot(e.$slots,"tbody-sn",{key:0,sn:a+1},(()=>[t.createVNode(g,{textContent:t.toDisplayString(a+1+e.paginatedRowIndex)},null,8,["textContent"])])):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"tbody",{index:a,row:n},(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.tableColumns,((a,o)=>(t.openBlock(),t.createBlock(g,{key:`datatable-tbody-td-${e.uniqueId()}-${o}`,name:a,textContent:t.toDisplayString(n[o])},null,8,["name","textContent"])))),128))]))])),_:2},1032,["row-index","striped"])))),128))])),_:3})])),_:3}),e.showPagination&&e.bottomPagination?(t.openBlock(),t.createBlock(b,{key:2},{default:t.withCtx((()=>[t.createVNode(y,{total:e.totalData,"current-page":e.tableQuery.page,"per-page":parseInt(e.tableQuery.per_page.toString()),onChanged:e.handlePageChange},null,8,["total","current-page","per-page","onChanged"])])),_:1})):t.createCommentVNode("",!0)])])])},e.DataTable=me,e.Pagination=B,e.PaginationLink=w,e.TableBody=Z,e.TableBodyCell=Z,e.TableHead=te,e.TableHeadCell=te,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"})); |
{ | ||
"name": "@jobinsjp/vue3-datatable", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "DataTable component with basic pagination, search filters etc for Vue3", | ||
@@ -47,7 +47,6 @@ "keywords": [ | ||
"peerDependencies": { | ||
"vue": "^3.0.0" | ||
"vue": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@tailwindcss/forms": "^0.3.3", | ||
"@types/node": "^15.12.5", | ||
"@types/node": "^16.7.10", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
@@ -62,3 +61,3 @@ "@typescript-eslint/parser": "^4.28.1", | ||
"eslint": "^7.29.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-vue": "^7.12.1", | ||
@@ -79,3 +78,3 @@ "gh-pages": "^3.2.3", | ||
"vue": "^3.1.2", | ||
"vue-tsc": "^0.2.0" | ||
"vue-tsc": "^0.3.0" | ||
}, | ||
@@ -82,0 +81,0 @@ "husky": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
54634
27
193
1
6