Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jobinsjp/vue3-datatable

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jobinsjp/vue3-datatable - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

dist/vue3-datatable.es.js

@@ -1,1 +0,1 @@

var e=Object.defineProperty,t=Object.prototype.hasOwnProperty,a=Object.getOwnPropertySymbols,n=Object.prototype.propertyIsEnumerable,d=(t,a,n)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n,l=(e,l)=>{for(var r in l||(l={}))t.call(l,r)&&d(e,r,l[r]);if(a)for(var r of a(l))n.call(l,r)&&d(e,r,l[r]);return e};import{openBlock as r,createBlock as s,createVNode as o,defineComponent as i,pushScopeId as u,popScopeId as c,withScopeId as g,computed as p,mergeProps as b,toHandlers as v,renderSlot as f,resolveComponent as m,withDirectives as y,toDisplayString as h,vShow as P,withModifiers as x,withCtx as w,Fragment as C,createCommentVNode as k,renderList as _,createTextVNode as I,ref as q,watch as O}from"vue";const $={},L={xmlns:"http://www.w3.org/2000/svg",class:"dt-h-5 dt-w-5",viewBox:"0 0 20 20",fill:"currentColor"},S=o("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);$.render=function(e,t){return r(),s("svg",L,[S])};var j=i({name:"Loading"});const B=g("data-v-f17dff8e");u("data-v-f17dff8e");const N={class:"spinner dt-absolute dt-h-full dt-w-full dt-flex dt-justify-center"},D=o("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1),F=o("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1);c();const Q=B(((e,t,a,n,d,l)=>(r(),s("div",N,[D,F]))));j.render=Q,j.__scopeId="data-v-f17dff8e";var T=i({name:"PaginationLink",props:{active:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1}},setup:e=>({linkClasses:p((()=>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"))})});T.render=function(e,t,a,n,d,o){return r(),s("a",b({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]},v(l({},e.$attrs))),[f(e.$slots,"default")],16)};var M=i({name:"Pagination",components:{PaginationLink:T},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=p((()=>(e.currentPage-1)*e.perPage+1)),n=p((()=>e.total>e.currentPage*e.perPage?e.currentPage*e.perPage:e.total)),d=p((()=>Math.ceil(e.total/e.perPage))),l=p((()=>1===e.currentPage?1:e.currentPage===d.value?d.value-e.maxVisibleButtons+1:e.currentPage-1)),r=p((()=>Math.min(l.value+e.maxVisibleButtons-1,d.value))),s=p((()=>{const e=[];for(let t=l.value;t<=r.value;t+=1)t>0&&e.push(t);return e})),o=p((()=>1===e.currentPage)),i=p((()=>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 E={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"},R={class:"dt-hidden sm:dt-flex-1 sm:dt-flex sm:dt-items-center sm:dt-justify-between"},z={class:"dt-text-sm dt-text-gray-700"},A=I(" Showing "),V=I(" to "),G=I(" of "),H=I(" results. "),J={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"},U=o("span",{class:"dt-sr-only"},"Go to first",-1),W=I(" « "),X=o("span",{class:"dt-sr-only"},"Previous",-1),Y=I(" ‹ "),Z=I(" 1 "),ee=I(" ... "),te=I(" ... "),ae=o("span",{class:"dt-sr-only"},"Next",-1),ne=I(" › "),de=o("span",{class:"dt-sr-only"},"Go to Last",-1),le=I(" » ");M.render=function(e,t,a,n,d,l){const i=m("pagination-link");return e.totalPages?(r(),s("div",E,[o("div",R,[y(o("div",null,[o("p",z,[f(e.$slots,"pagination-info",{currentStart:e.currentStart,currentEnd:e.currentEnd,total:e.total},(()=>[A,o("span",{class:"dt-font-medium",textContent:h(e.currentStart)},null,8,["textContent"]),V,o("span",{class:"dt-font-medium",textContent:h(e.currentEnd)},null,8,["textContent"]),G,o("span",{class:"dt-font-medium",textContent:h(e.total)},null,8,["textContent"]),H]))])],512),[[P,e.total]]),e.totalPages>1?(r(),s("div",J,[o("nav",K,[o(i,{disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:x(e.gotoFirstPage,["prevent"])},{default:w((()=>[U,W])),_:1},8,["disabled","onClick"]),o(i,{disabled:e.isInFirstPage,onClick:x(e.gotoPreviousPage,["prevent"])},{default:w((()=>[X,Y])),_:1},8,["disabled","onClick"]),e.showDots("left")?(r(),s(C,{key:0},[o(i,{class:"dt-block sm:dt-hidden",disabled:e.isInFirstPage,active:e.isInFirstPage,onClick:x(e.gotoFirstPage,["prevent"])},{default:w((()=>[Z])),_:1},8,["disabled","active","onClick"]),o(i,{class:"sm:dt-hidden"},{default:w((()=>[ee])),_:1})],64)):k("",!0),(r(!0),s(C,null,_(e.pages,((t,a)=>(r(),s(i,{key:`pages_${a}`,class:"dt-hidden md:dt-inline-block",active:t===e.currentPage,disabled:t===e.currentPage,onClick:x((a=>e.goToPageNumber(t)),["prevent"])},{default:w((()=>[I(h(t),1)])),_:2},1032,["active","disabled","onClick"])))),128)),e.showDots("right")?(r(),s(C,{key:1},[o(i,{class:"sm:dt-hidden"},{default:w((()=>[te])),_:1}),o(i,{class:"sm:dt-hidden",disabled:e.isInLastPage,active:e.isInLastPage,onClick:x(e.gotoLastPage,["prevent"])},{default:w((()=>[I(h(e.totalPages),1)])),_:1},8,["disabled","active","onClick"])],64)):k("",!0),o(i,{disabled:e.isInLastPage,onClick:x(e.gotoNextPage,["prevent"])},{default:w((()=>[ae,ne])),_:1},8,["disabled","onClick"]),o(i,{disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:x(e.gotoLastPage,["prevent"])},{default:w((()=>[de,le])),_:1},8,["disabled","onClick"])])])):k("",!0)])])):k("",!0)};const re={},se={class:"dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};re.render=function(e,t){return r(),s("td",se,[f(e.$slots,"default")])};const oe={},ie={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"};oe.render=function(e,t){return r(),s("th",ie,[f(e.$slots,"default")])};const ue=[5,10,15,25,50,75,100],ce=i({components:{SearchIcon:$,Loading:j,Pagination:M,TableBody:re,TableHead:oe},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:()=>({})}},emits:["loadData"],setup(e,{emit:t}){var a,n;const d=q({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}),r=p((()=>!!e.pagination)),s=p((()=>{var t;return(null==(t=e.pagination)?void 0:t.total)||e.rows.length})),o=p((()=>e.rows)),i=p((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>l(l({},e),{[t]:t})),{}))),u=p((()=>r.value?d.value.per_page*(d.value.page-1):0));O((()=>l({},d.value)),(()=>{t("loadData",d.value)}),{deep:!0,immediate:!0});const c=((e,t=400)=>{let a;return(...n)=>{clearTimeout(a),a=setTimeout((()=>e(...n)),t)}})((e=>{d.value=l(l({},d.value),{page:1,search:e.target.value})}));return{tableQuery:d,showPagination:r,totalData:s,tableRows:o,tableColumns:i,paginatedRowIndex:u,uniqueId:()=>Math.floor(100*Math.random()),handlePageChange:e=>{d.value.page=e},handleOnSearchChange:c,handleOnChange:e=>{const{name:t,value:a}=e.target;d.value=l(l({},d.value),{page:1,[t]:a})}}}});const ge=g("data-v-0bb37481");u("data-v-0bb37481");const pe={class:"data-table dt-flex dt-flex-col"},be={class:"dt-align-middle dt-min-w-full"},ve={key:0,class:"dt-filter-wrapper dt-mb-3 dt-w-full"},fe={class:"dt-w-64"},me=o("label",{for:"email",class:"dt-sr-only"},"Search",-1),ye={class:"dt-relative dt-rounded-md dt-shadow-sm"},he={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"},Pe={class:"table-wrapper dt-relative dt-shadow dt-overflow-hidden dt-border-b dt-border-gray-200 sm:dt-rounded-lg"},xe={key:1,class:"pagination-wrapper md:dt-flex smdt-flex-col dt-bg-white dt-items-center"},we={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"},Ce={class:""},ke=o("label",{for:"location",class:"dt-sr-only"},"Per page",-1),_e={class:"table-container dt-overflow-auto"},Ie={class:"dt-min-w-full dt-divide-y dt-divide-gray-200"},qe={class:"dt-bg-gray-50"},Oe={key:2,class:"pagination-wrapper"};c();const $e=ge(((e,t,a,n,d,l)=>{const i=m("search-icon"),u=m("Loading"),c=m("pagination"),g=m("table-head"),p=m("table-body");return r(),s("div",pe,[o("div",be,[e.filter?(r(),s("div",ve,[o("div",fe,[me,o("div",ye,[o("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"]),o("div",he,[o(i,{class:"dt-text-gray-400"})])])])])):k("",!0),o("div",Pe,[e.loading?f(e.$slots,"loading",{key:0},(()=>[o(u)]),{},!0):k("",!0),e.showPagination?(r(),s("div",xe,[o(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"]),o("div",we,[o("div",Ce,[ke,o("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))},[(r(!0),s(C,null,_(e.perPageOptions,(t=>(r(),s("option",{key:`per_page_${t}`,value:t,selected:t===e.tableQuery.per_page,textContent:h(t)},null,8,["value","selected","textContent"])))),128))],40,["value"])])])])):k("",!0),o("div",_e,[o("table",Ie,[o("thead",qe,[o("tr",null,[e.sn?f(e.$slots,"thead-sn",{key:0},(()=>[o(g,{textContent:h("S.N.")},null,8,["textContent"])]),{},!0):k("",!0),f(e.$slots,"thead",{column:e.tableColumns},(()=>[(r(!0),s(C,null,_(e.tableColumns,((e,t)=>(r(),s(g,{key:`datatable-thead-th-${t}`,textContent:h(e)},null,8,["textContent"])))),128))]),!0)])]),o("tbody",null,[(r(!0),s(C,null,_(e.tableRows,((t,a)=>(r(),s("tr",{key:`datatable-tbody-${e.uniqueId()}-${a}`,class:e.striped&&a%2?"dt-bg-gray-50":"dt-bg-white"},[e.sn?f(e.$slots,"tbody-sn",{key:0,sn:a+1},(()=>[o(p,{textContent:h(a+1+e.paginatedRowIndex)},null,8,["textContent"])]),!0):k("",!0),f(e.$slots,"tbody",{index:a,row:t},(()=>[(r(!0),s(C,null,_(e.tableColumns,((a,n)=>(r(),s(p,{key:`datatable-tbody-td-${e.uniqueId()}-${n}`,name:a,textContent:h(t[n])},null,8,["name","textContent"])))),128))]),!0)],2)))),128))])])]),e.showPagination?(r(),s("div",Oe,[o(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"])])):k("",!0)])])])}));ce.render=$e,ce.__scopeId="data-v-0bb37481";export{ce as DataTable,M as Pagination,T as PaginationLink,re as TableBody,oe as TableHead};
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};

@@ -1,1 +0,1 @@

var __defProp=Object.defineProperty,__hasOwnProp=Object.prototype.hasOwnProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__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,__assign=(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};!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),i=t.createVNode("div",{class:"spinner-item dt-absolute dt-w-20 dt-h-20 dt-rounded-full"},null,-1);t.popScopeId();const c=n(((e,a,o,r,d,n)=>(t.openBlock(),t.createBlock("div",l,[s,i]))));d.render=c,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(__assign({},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})),i=t.computed((()=>1===e.currentPage)),c=t.computed((()=>e.currentPage===d.value)),u=e=>{a("changed",e)};return{currentStart:o,currentEnd:r,totalPages:d,pages:s,isInFirstPage:i,isInLastPage:c,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"},v=t.createTextVNode(" Showing "),y=t.createTextVNode(" to "),h=t.createTextVNode(" of "),x=t.createTextVNode(" results. "),k={key:0},w={class:"dt-relative dt-z-0 dt-inline-flex dt-rounded-md dt-shadow-sm dt--space-x-px","aria-label":"Pagination"},N=t.createVNode("span",{class:"dt-sr-only"},"Go to first",-1),P=t.createTextVNode(" « "),C=t.createVNode("span",{class:"dt-sr-only"},"Previous",-1),V=t.createTextVNode(" ‹ "),_=t.createTextVNode(" 1 "),B=t.createTextVNode(" ... "),S=t.createTextVNode(" ... "),I=t.createVNode("span",{class:"dt-sr-only"},"Next",-1),T=t.createTextVNode(" › "),O=t.createVNode("span",{class:"dt-sr-only"},"Go to Last",-1),q=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},(()=>[v,t.createVNode("span",{class:"dt-font-medium",textContent:t.toDisplayString(e.currentStart)},null,8,["textContent"]),y,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"]),x]))])],512),[[t.vShow,e.total]]),e.totalPages>1?(t.openBlock(),t.createBlock("div",k,[t.createVNode("nav",w,[t.createVNode(l,{disabled:e.isInFirstPage,class:"dt-rounded-l-md",onClick:t.withModifiers(e.gotoFirstPage,["prevent"])},{default:t.withCtx((()=>[N,P])),_: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((()=>[I,T])),_:1},8,["disabled","onClick"]),t.createVNode(l,{disabled:e.isInLastPage,class:"dt-rounded-r-md",onClick:t.withModifiers(e.gotoLastPage,["prevent"])},{default:t.withCtx((()=>[O,q])),_:1},8,["disabled","onClick"])])])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)};const D={},L={class:"dt-px-6 dt-py-4 dt-whitespace-nowrap dt-text-sm dt-font-medium dt-text-gray-500"};D.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"};$.render=function(e,a){return t.openBlock(),t.createBlock("th",j,[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:D,TableHead:$},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)),i=t.computed((()=>e.columns?e.columns:0===e.rows.length?{}:Object.keys(e.rows[0]).reduce(((e,t)=>__assign(__assign({},e),{[t]:t})),{}))),c=t.computed((()=>n.value?d.value.per_page*(d.value.page-1):0));t.watch((()=>__assign({},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=__assign(__assign({},d.value),{page:1,search:e.target.value})}));return{tableQuery:d,showPagination:n,totalData:l,tableRows:s,tableColumns:i,paginatedRowIndex:c,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=__assign(__assign({},d.value),{page:1,[t]:a})}}}});const Q=t.withScopeId("data-v-0bb37481");t.pushScopeId("data-v-0bb37481");const E={class:"data-table dt-flex dt-flex-col"},R={class:"dt-align-middle dt-min-w-full"},z={key:0,class:"dt-filter-wrapper dt-mb-3 dt-w-full"},A={class:"dt-w-64"},H=t.createVNode("label",{for:"email",class:"dt-sr-only"},"Search",-1),G={class:"dt-relative dt-rounded-md dt-shadow-sm"},J={class:"dt-absolute dt-inset-y-0 dt-right-0 dt-pr-3 dt-flex dt-items-center dt-pointer-events-none"},K={class:"table-wrapper dt-relative dt-shadow dt-overflow-hidden dt-border-b dt-border-gray-200 sm:dt-rounded-lg"},U={key:1,class:"pagination-wrapper md:dt-flex smdt-flex-col dt-bg-white dt-items-center"},W={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"},X={class:""},Y=t.createVNode("label",{for:"location",class:"dt-sr-only"},"Per page",-1),Z={class:"table-container dt-overflow-auto"},ee={class:"dt-min-w-full dt-divide-y dt-divide-gray-200"},te={class:"dt-bg-gray-50"},ae={key:2,class:"pagination-wrapper"};t.popScopeId();const oe=Q(((e,a,o,r,d,n)=>{const l=t.resolveComponent("search-icon"),s=t.resolveComponent("Loading"),i=t.resolveComponent("pagination"),c=t.resolveComponent("table-head"),u=t.resolveComponent("table-body");return t.openBlock(),t.createBlock("div",E,[t.createVNode("div",R,[e.filter?(t.openBlock(),t.createBlock("div",z,[t.createVNode("div",A,[H,t.createVNode("div",G,[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",J,[t.createVNode(l,{class:"dt-text-gray-400"})])])])])):t.createCommentVNode("",!0),t.createVNode("div",K,[e.loading?t.renderSlot(e.$slots,"loading",{key:0},(()=>[t.createVNode(s)]),{},!0):t.createCommentVNode("",!0),e.showPagination?(t.openBlock(),t.createBlock("div",U,[t.createVNode(i,{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",W,[t.createVNode("div",X,[Y,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",Z,[t.createVNode("table",ee,[t.createVNode("thead",te,[t.createVNode("tr",null,[e.sn?t.renderSlot(e.$slots,"thead-sn",{key:0},(()=>[t.createVNode(c,{textContent:t.toDisplayString("S.N.")},null,8,["textContent"])]),{},!0):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(c,{key:`datatable-thead-th-${a}`,textContent:t.toDisplayString(e)},null,8,["textContent"])))),128))]),!0)])]),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"])]),!0):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))]),!0)],2)))),128))])])]),e.showPagination?(t.openBlock(),t.createBlock("div",ae,[t.createVNode(i,{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)])])])}));M.render=oe,M.__scopeId="data-v-0bb37481",e.DataTable=M,e.Pagination=g,e.PaginationLink=u,e.TableBody=D,e.TableHead=$,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,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"}));
{
"name": "@jobinsjp/vue3-datatable",
"version": "1.0.6",
"version": "1.0.7",
"description": "DataTable component with basic pagination, search filters etc for Vue3",

@@ -43,37 +43,37 @@ "keywords": [

"lint:style": "stylelint .",
"lint:prettier": "prettier -w -u ."
"lint:prettier": "prettier -w -u .",
"release": "npx bumpp --tag --commit --push && npm publish"
},
"peerDependencies": {
"vue": "^3.0.5"
"vue": "^3.0.0"
},
"devDependencies": {
"@tailwindcss/forms": "^0.3.2",
"@tailwindcss/jit": "^0.1.18",
"@types/node": "^15.0.1",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@vitejs/plugin-vue": "^1.2.2",
"@vue/compiler-sfc": "^3.0.5",
"@tailwindcss/forms": "^0.3.3",
"@types/node": "^15.12.5",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"@vitejs/plugin-vue": "^1.2.4",
"@vue/compiler-sfc": "^3.1.2",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"autoprefixer": "^10.2.5",
"autoprefixer": "^10.2.6",
"axios": "^0.21.1",
"eslint": "^7.24.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.8.0",
"gh-pages": "^3.1.0",
"husky": "^6.0.0",
"lint-staged": "^10.5.4",
"postcss": "^8.2.10",
"prettier": "^2.2.1",
"eslint": "^7.29.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.12.1",
"gh-pages": "^3.2.3",
"husky": "^7.0.0",
"lint-staged": "^11.0.0",
"postcss": "^8.3.5",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"sass": "^1.32.8",
"stylelint": "^13.12.0",
"stylelint-config-recommended": "^4.0.0",
"stylelint-config-standard": "^21.0.0",
"tailwindcss": "^2.1.1",
"typescript": "^4.2.4",
"vite": "^2.1.5",
"vue": "^3.0.5",
"vue-tsc": "^0.0.23"
"sass": "^1.35.1",
"stylelint": "^13.13.1",
"stylelint-config-recommended": "^5.0.0",
"stylelint-config-standard": "^22.0.0",
"tailwindcss": "^2.2.4",
"typescript": "^4.3.5",
"vite": "^2.3.8",
"vue": "^3.1.2",
"vue-tsc": "^0.2.0"
},

@@ -80,0 +80,0 @@ "husky": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc