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

vue3-easy-data-table

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-easy-data-table - npm Package Compare versions

Comparing version 1.2.19 to 1.2.20

3

dist/vue3-easy-data-table.es.js

@@ -1206,2 +1206,5 @@ var __defProp = Object.defineProperty;

var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-20b07e6b"]]);
if (typeof window !== "undefined" && window.Vue) {
window.Vue.createApp({}).component("Vue3EasyDataTable", DataTable);
}
export { DataTable as default };

2

dist/vue3-easy-data-table.umd.js

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

(function(e,y){typeof exports=="object"&&typeof module!="undefined"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=y(e.Vue))})(this,function(e){"use strict";var Nt=Object.defineProperty,$t=Object.defineProperties;var It=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var ye=(e,y,g)=>y in e?Nt(e,y,{enumerable:!0,configurable:!0,writable:!0,value:g}):e[y]=g,C=(e,y)=>{for(var g in y||(y={}))Et.call(y,g)&&ye(e,g,y[g]);if(_e)for(var g of _e(y))Vt.call(y,g)&&ye(e,g,y[g]);return e},H=(e,y)=>$t(e,It(y));var y="",g=(a,k)=>{const l=a.__vccOpts||a;for(const[n,p]of k)l[n]=p;return l};const ke=a=>(e.pushScopeId("data-v-566775ba"),a=a(),e.popScopeId(),a),xe=["onClick"],be=["checked"],Ce=ke(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Se=g(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(a,{emit:k}){const l=a;e.useCssVars(w=>({"7f84b28f":e.unref(b)}));const n=e.computed(()=>l.status==="allSelected"),p=()=>{k("change",!n.value)},b=e.inject("themeColor");return(w,T)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(p,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(n),class:e.normalizeClass(a.status)},null,10,be),Ce],8,xe))}}),[["__scopeId","data-v-566775ba"]]),Tt="";const Be=a=>(e.pushScopeId("data-v-39f156fd"),a=a(),e.popScopeId(),a),Pe=["checked"],we=Be(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Ne=g(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(a,{emit:k}){e.useCssVars(n=>({"20cfc5a0":e.unref(l)}));const l=e.inject("themeColor");return(n,p)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:p[0]||(p[0]=e.withModifiers(b=>k("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:a.checked},null,8,Pe),we]))}}),[["__scopeId","data-v-39f156fd"]]),Ht="";const $e=a=>(e.pushScopeId("data-v-0ed08e20"),a=a(),e.popScopeId(),a),Ie={class:"easy-data-table__rows-selector"},Ee={class:"rows-input"},Ve=$e(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Fe=["onClick"];var Te=g(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(a,{emit:k}){const l=a;e.useCssVars(h=>({"83c11052":e.unref(m),"6b60f418":e.unref(s),"346ac97c":e.unref(d)}));const n=e.ref(!1),p=e.ref(!1),b=e.inject("dataTable");e.watch(n,h=>{if(h&&b){const S=window.innerHeight,x=b.value.getBoundingClientRect().height,I=b.value.getBoundingClientRect().top;S-(x+I)<=100?p.value=!0:p.value=!1}});const w=e.computed({get:()=>l.modelValue,set:h=>{k("update:modelValue",h)}}),T=h=>{w.value=h,n.value=!1},O=(h,S)=>{let x=h.parentNode;for(;x!=null;){if(x.classList&&x.classList.contains(S))return!0;x=x.parentNode}return!1},z=h=>{O(h.target,"easy-data-table__rows-selector")||(n.value=!1)};e.onMounted(()=>{document.addEventListener("click",z)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",z)});const d=e.inject("themeColor"),s=e.inject("footerBackgroundColor"),m=e.inject("footerFontColor");return(h,S)=>(e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:S[0]||(S[0]=x=>n.value=!n.value)},[e.createElementVNode("div",Ee,e.toDisplayString(e.unref(w)),1),Ve]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:n.value,inside:p.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.rowsItems,x=>(e.openBlock(),e.createElementBlock("li",{key:x,class:e.normalizeClass({selected:x===e.unref(w)}),onClick:I=>T(x)},e.toDisplayString(x),11,Fe))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),Lt="";const A=a=>(e.pushScopeId("data-v-969989cc"),a=a(),e.popScopeId(),a),ze={class:"lds-ring"},He=[A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1))];var Oe=g(e.defineComponent({setup(a){e.useCssVars(n=>({"284c10f4":e.unref(l),"90c4d0a4":e.unref(k)}));const k=e.inject("themeColor"),l=e.inject("loadingEntitySizePx");return(n,p)=>(e.openBlock(),e.createElementBlock("div",ze,He))}}),[["__scopeId","data-v-969989cc"]]),qt="";const Le={class:"buttons-pagination"},Re=["onClick"];var Ae=g(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(a,{emit:k}){const l=a;e.useCssVars(d=>({aa5730a0:e.unref(T),"24829312":e.unref(O),"98a0e762":e.unref(z)}));const n=7,p=d=>{d.type==="button"&&!d.active&&k("updatePage",d.page)},b=e.computed(()=>{const d=[];if(l.maxPaginationNumber<=n)for(let s=1;s<=l.maxPaginationNumber;s+=1)d.push({type:"button",page:s,active:s===l.currentPaginationNumber});else if([1,2,l.maxPaginationNumber,l.maxPaginationNumber-1].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)if(s<=3)d.push({type:"button",page:s,active:s===l.currentPaginationNumber});else if(s===4)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-s);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else if([3,4].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)s<=5?d.push({type:"button",page:s,active:s===l.currentPaginationNumber}):s===6?d.push({type:"omission"}):d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else if([l.maxPaginationNumber-2,l.maxPaginationNumber-3].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)if(s===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(s===2)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-s);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else for(let s=1;s<=n;s+=1)if(s===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(s===2||s===6)d.push({type:"omission"});else if(s===7)d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else{const m=4-s,h=l.currentPaginationNumber-m;d.push({type:"button",page:h,active:h===l.currentPaginationNumber})}return d}),w=e.inject("rowHeight"),T=e.computed(()=>`${w*.6}px`),O=e.inject("rowBorderColor"),z=e.inject("themeColor");return(d,s)=>(e.openBlock(),e.createElementBlock("div",Le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:m.type==="button",active:m.type==="button"&&m.active,omission:m.type==="omission"}]),onClick:S=>p(m)},e.toDisplayString(m.type==="button"?m.page:"..."),11,Re))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Jt="";const v=a=>(e.pushScopeId("data-v-c9da5286"),a=a(),e.popScopeId(),a),De=[v(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Me=[v(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var je=g(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(a,{emit:k}){const l=e.useSlots();return(n,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":a.isFirstPage}]),onClick:p[0]||(p[0]=b=>k("clickPrevPage"))},De,2),e.unref(l).buttonsPagination?e.renderSlot(n.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":a.isLastPage}]),onClick:p[1]||(p[1]=b=>k("clickNextPage"))},Me,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),Qt="";const qe={key:0},We=["onClick"],Je={key:1,class:"header-text__wrapper"},Ue={class:"header-text"},Ge=["onClick"],Ke={class:"loading-entity"},Qe={key:1,class:"data-table__message"},Xe={key:0,class:"data-table__footer"},Ye={key:0,class:"footer__rows-per-page"},Ze=e.createTextVNode(" rows per page: "),ve={class:"footer__items-index"};var et=g(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},filterOptions:{type:Array,default:null},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},checkboxColumnWidth:{type:Number,default:null},hideRowsPerPage:{type:Boolean,default:!1}},emits:["update:itemsSelected","update:serverOptions","clickRow"],setup(a,{expose:k,emit:l}){const n=a;e.useCssVars(o=>({"17231b25":e.unref(b),"522d8976":e.unref(rt),"5cb25bd7":e.unref(s),c73f587e:e.unref(nt),"03eb8bbc":e.unref(it),a0fd7266:e.unref(tt),"4749c154":e.unref(x),"438d5ad6":e.unref(T),c7147770:e.unref(ot),"1e7ebc99":e.unref(p),"3de3cb8b":e.unref(w),"41869e68":a.headerBackgroundColor,a66323d4:e.unref(at),"483712ce":e.unref(lt),"49aaf451":e.unref(st),"72483237":e.unref(O),"5a5b7936":e.unref(z),"501ce9e0":e.unref(h),"3d5bf891":e.unref(m),"5acc9ffe":e.unref(d),"39c8ef86":e.unref(S)}));const{rowBorderColor:p,tableBorderColor:b,headerFontColor:w,rowFontColor:T,rowHoverBackgroundColor:O,rowHoverFontColor:z,footerBackgroundColor:d,rowBackgroundColor:s,evenRowBackgroundColor:m,evenRowFontColor:h,footerFontColor:S}=e.toRefs(n),x=e.computed(()=>`${n.tableFontSize}px`),I=e.computed(()=>n.tableFontSize*(n.dense?2:3)),tt=e.computed(()=>`${I.value}px`),ot=e.computed(()=>`-${I.value}px`),nt=e.computed(()=>n.tableHeight?`${n.tableHeight}px`:null),rt=e.computed(()=>`${I.value*5}px`),ee=e.computed(()=>Math.round(n.tableFontSize/2.5)),at=e.computed(()=>`${ee.value}px`),te=e.computed(()=>Math.round(ee.value)),lt=e.computed(()=>`-${te.value}px`),st=e.computed(()=>`${te.value}px`),ct=e.computed(()=>`${n.tableFontSize*5}px`),it=e.computed(()=>n.tableHeight?`${n.tableHeight-I.value}px`:`${n.tableFontSize*5*2}px`),dt=e.computed(()=>{var o;return(o=n.checkboxColumnWidth)!=null?o:1.3*n.tableFontSize+20});e.provide("themeColor",n.themeColor),e.provide("loadingEntitySizePx",ct.value),e.provide("rowHeight",I.value),e.provide("rowBorderColor",p.value),e.provide("footerBackgroundColor",d.value),e.provide("footerFontColor",S.value);const D=e.useSlots(),ut=e.computed(()=>D.body),pt=e.computed(()=>D.pagination),ft=e.computed(()=>D.loading),oe=e.ref(),U=e.ref();e.provide("dataTable",oe);const ne=e.ref(!1);e.onMounted(()=>{U.value.addEventListener("scroll",()=>{ne.value=U.value.scrollLeft>0})});const u=e.computed({get:()=>{if(n.serverOptions){const{page:o,rowsPerPage:r,sortBy:t,sortType:c}=n.serverOptions;return{page:o,rowsPerPage:r,sortBy:t!=null?t:null,sortType:c!=null?c:null}}return null},set:o=>{l("update:serverOptions",o)}}),G=e.computed(()=>n.itemsSelected!==null),B=e.computed(()=>u.value!==null),mt=e.computed(()=>!B.value&&n.rowsItems.findIndex(o=>o===n.rowsPerPage)===-1?[n.rowsPerPage,...n.rowsItems]:n.rowsItems),gt=()=>n.sortBy!==""?{sortBy:n.sortBy,sortDesc:n.sortType==="desc"}:null,E=e.ref(gt()),K=e.computed(()=>n.headers.findIndex(o=>o.fixed)!==-1),ht=e.computed(()=>K.value?n.headers.filter(o=>o.fixed):[]),_t=e.computed(()=>n.headers.filter(o=>!o.fixed)),L=e.computed(()=>{const r=[...ht.value,..._t.value].map(i=>{const f=i;return i.sortable&&(f.sortType="none"),u.value&&i.value===u.value.sortBy&&u.value.sortType&&(f.sortType=u.value.sortType),!B.value&&E.value&&i.value===E.value.sortBy&&(f.sortType=E.value.sortDesc?"desc":"asc"),f});let t=[];n.showIndex?t=[n.fixedIndex||K.value?{text:"#",value:"index",fixed:!0,width:n.indexColumnWidth}:{text:"#",value:"index"},...r]:t=r;let c=[];return G.value?c=[n.fixedCheckbox||K.value?{text:"checkbox",value:"checkbox",fixed:!0,width:dt.value}:{text:"checkbox",value:"checkbox"},...t]:c=t,c}),N=e.computed(()=>L.value.filter(o=>o.fixed)),re=e.computed(()=>N.value.length?N.value[N.value.length-1].value:""),yt=o=>{var t;const r=(t=o.width)!=null?t:N.value.length?100:null;if(r)return`width: ${r}px; min-width: ${r}px;`},kt=e.computed(()=>{if(!N.value.length)return[];const o=N.value.map(r=>{var t;return(t=r.width)!=null?t:100});return N.value.map((r,t)=>{var c,i;return{value:r.value,fixed:(c=r.fixed)!=null?c:!0,width:(i=r.width)!=null?i:100,distance:t===0?0:o.reduce((f,ge,wt)=>{let he=f;return wt<t&&(he+=ge),he})}})}),ae=(o,r="th")=>{if(!N.value.length)return;const t=kt.value.find(c=>c.value===o);if(t)return`left: ${t.distance}px;z-index: ${r==="th"?3:1}; position: sticky`},le=e.computed(()=>L.value.map(o=>o.value)),R=(o,r)=>{if(o.includes(".")){let t="";return o.split(".").forEach((i,f)=>{t=f===0?r[i]:t[i]}),t}return r[o]},xt=(o,r)=>{const t=R(o,r);return Array.isArray(t)?t.join(","):t},P=e.computed({get:()=>{var o;return(o=n.itemsSelected)!=null?o:[]},set:o=>{l("update:itemsSelected",o)}}),se=e.computed(()=>{if(!B.value&&n.searchValue!==""){const o=new RegExp(n.searchValue,"i");return n.items.filter(r=>o.test(n.searchField!==""?r[n.searchField]:Object.values(r).join(" ")))}return n.items}),V=e.computed(()=>{let o=[...se.value];return n.filterOptions?(n.filterOptions.forEach(r=>{o=o.filter(t=>{const{field:c,comparison:i,criteria:f}=r;switch(i){case"=":return t[c]===f;case"!=":return t[c]!==f;case">":return t[c]>f;case"<":return t[c]<f;case"<=":return t[c]<=f;case">=":return t[c]>=f;case"between":return t[c]>=Math.min(...f)&&t[c]<=Math.max(...f);default:return t[c]===f}})}),o):se.value}),M=e.computed(()=>P.value.length===0||P.value.every(r=>V.value.findIndex(t=>JSON.stringify(r)===JSON.stringify(t))===-1)?"noneSelected":P.value.length===V.value.length&&P.value.every(t=>V.value.findIndex(c=>JSON.stringify(t)===JSON.stringify(c))!==-1)?"allSelected":"partSelected"),_=e.ref(B.value?n.serverOptions.page:1),{items:Q}=e.toRefs(n);e.watch(Q,()=>{B.value||(_.value=1)},{deep:!0});const $=e.ref(B.value?n.serverOptions.rowsPerPage:n.rowsPerPage);e.watch($,o=>{u.value&&(u.value=H(C({},u.value),{page:1,rowsPerPage:o})),_.value=1});const bt=(o,r)=>{let t=null;r==="none"?t="asc":r==="asc"?t="desc":t=null,u.value?u.value=H(C({},u.value),{sortBy:t!==null?o:null,sortType:t}):t===null?E.value=null:E.value={sortBy:o,sortDesc:t==="desc"}},ce=e.computed(()=>{if(B.value)return n.items;if(E.value===null)return V.value;const{sortBy:o,sortDesc:r}=E.value;return[...V.value].sort((c,i)=>R(o,c)<R(o,i)?r?1:-1:R(o,c)>R(o,i)?r?-1:1:0)}),X=e.computed(()=>B.value?n.serverItemsLength:V.value.length),ie=e.computed(()=>B.value?_.value*$.value:Math.min(V.value.length,_.value*$.value)),de=e.computed(()=>(_.value-1)*$.value+1),j=e.computed(()=>Math.ceil(X.value/$.value)),q=e.computed(()=>_.value===j.value),W=e.computed(()=>_.value===1),{loading:F}=e.toRefs(n),Y=()=>{if(!q.value&&!F.value)if(u.value){const o=_.value+1;u.value=H(C({},u.value),{page:o})}else _.value+=1},Z=()=>{if(!W.value&&!F.value)if(u.value){const o=_.value-1;u.value=H(C({},u.value),{page:o})}else _.value-=1},ue=o=>{F.value||(u.value?u.value=H(C({},u.value),{page:o}):_.value=o)};e.watch(F,(o,r)=>{u.value&&o===!1&&r===!0&&(_.value=u.value.page)});const pe=e.computed(()=>B.value?n.items:ce.value.slice(de.value-1,ie.value)),fe=e.computed(()=>$.value*(_.value-1)+1),Ct=e.computed(()=>$.value*_.value),J=e.computed(()=>n.showIndex?pe.value.map((o,r)=>C({index:fe.value+r},o)):pe.value),me=e.computed(()=>G.value?M.value==="allSelected"?J.value.map(o=>C({checkbox:!0},o)):M.value==="noneSelected"?J.value.map(o=>C({checkbox:!1},o)):J.value.map(o=>{const r=P.value.findIndex(t=>{const c=C({},o);return delete c.index,JSON.stringify(t)===JSON.stringify(c)})!==-1;return C({checkbox:r},o)}):J.value),St=o=>{P.value=o?ce.value:[]},Bt=o=>{const r=o.checkbox;if(delete o.checkbox,delete o.index,r)P.value=P.value.filter(t=>JSON.stringify(t)!==JSON.stringify(o));else{const t=P.value;t.unshift(o),P.value=t}},Pt=o=>{const r=C({},o);if(G.value){const{checkbox:t}=o;delete r.checkbox,r.isSelected=t}if(n.showIndex){const{index:t}=o;delete r.index,r.indexInCurrentPage=t}l("clickRow",r)};return k({clientItemsLength:X,currentPageFirstIndex:fe,currentPageLastIndex:Ct,maxPaginationNumber:j,currentPaginationNumber:_,isLastPage:q,isFirstPage:W,nextPage:Y,prevPage:Z,updatePage:ue}),(o,r)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:oe,class:"vue3-easy-data-table"},[e.createElementVNode("div",{ref_key:"tableBody",ref:U,class:e.normalizeClass(["data-table__body",{"fixed-header":a.fixedHeader,"fixed-height":a.tableHeight,"show-shadow":ne.value}])},[e.createElementVNode("table",{class:e.normalizeClass({fixed:e.unref(N).length})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,c)=>(e.openBlock(),e.createElementBlock("col",{key:c,style:e.normalizeStyle(yt(t))},null,4))),128))]),e.unref(L).length?(e.openBlock(),e.createElementBlock("thead",qe,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,c)=>(e.openBlock(),e.createElementBlock("th",{key:c,class:e.normalizeClass({sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",fixed:t.fixed,hasShadow:t.value===e.unref(re)}),style:e.normalizeStyle(ae(t.value)),onClick:i=>t.sortable&&t.sortType?bt(t.value,t.sortType):null},[t.text==="checkbox"?(e.openBlock(),e.createBlock(Se,{key:e.unref(M),status:e.unref(M),onChange:St},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Je,[e.createElementVNode("span",Ue,e.toDisplayString(t.text),1),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,We))),128))])])):e.createCommentVNode("",!0),e.unref(ut)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.unref(Q).length&&e.unref(le).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":a.alternating,"hover-to-change-color":a.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(me),(t,c)=>(e.openBlock(),e.createElementBlock("tr",{key:c,onClick:i=>Pt(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(le),(i,f)=>(e.openBlock(),e.createElementBlock("td",{key:f,style:e.normalizeStyle(ae(i,"td")),class:e.normalizeClass({hasShadow:i===e.unref(re)})},[e.unref(D)[i]?e.renderSlot(o.$slots,i,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):i==="checkbox"?(e.openBlock(),e.createBlock(Ne,{key:1,checked:t[i],onChange:ge=>Bt(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(xt(i,t)),1)],64))],6))),128))],8,Ge))),128))],2)):e.createCommentVNode("",!0)],64))],2),e.unref(F)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!e.unref(Q).length&&e.unref(F)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":a.hideFooter}])},null,2),e.createElementVNode("div",Ke,[e.unref(ft)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Oe,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(me).length&&!e.unref(F)?(e.openBlock(),e.createElementBlock("div",Qe,e.toDisplayString(a.emptyMessage),1)):e.createCommentVNode("",!0)],2),a.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Xe,[a.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ye,[Ze,e.createVNode(Te,{modelValue:$.value,"onUpdate:modelValue":r[0]||(r[0]=t=>$.value=t),"rows-items":e.unref(mt)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",ve,e.toDisplayString(`${e.unref(de)}-${e.unref(ie)}`)+" of "+e.toDisplayString(e.unref(X)),1),e.unref(pt)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(W),isLastPage:e.unref(q),currentPaginationNumber:_.value,maxPaginationNumber:e.unref(j),nextPage:Y,prevPage:Z})),void 0,!0):(e.openBlock(),e.createBlock(je,{key:2,"is-first-page":e.unref(W),"is-last-page":e.unref(q),onClickNextPage:Y,onClickPrevPage:Z},e.createSlots({_:2},[a.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Ae,{"current-pagination-number":_.value,"max-pagination-number":e.unref(j),onUpdatePage:ue},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],512))}}),[["__scopeId","data-v-20b07e6b"]]);return et});
(function(e,_){typeof exports=="object"&&typeof module!="undefined"?module.exports=_(require("vue")):typeof define=="function"&&define.amd?define(["vue"],_):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=_(e.Vue))})(this,function(e){"use strict";var Nt=Object.defineProperty,$t=Object.defineProperties;var It=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var ke=(e,_,g)=>_ in e?Nt(e,_,{enumerable:!0,configurable:!0,writable:!0,value:g}):e[_]=g,C=(e,_)=>{for(var g in _||(_={}))Et.call(_,g)&&ke(e,g,_[g]);if(_e)for(var g of _e(_))Vt.call(_,g)&&ke(e,g,_[g]);return e},H=(e,_)=>$t(e,It(_));var _="",g=(a,k)=>{const l=a.__vccOpts||a;for(const[n,p]of k)l[n]=p;return l};const xe=a=>(e.pushScopeId("data-v-566775ba"),a=a(),e.popScopeId(),a),be=["onClick"],Ce=["checked"],Se=xe(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Be=g(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(a,{emit:k}){const l=a;e.useCssVars(P=>({"7f84b28f":e.unref(b)}));const n=e.computed(()=>l.status==="allSelected"),p=()=>{k("change",!n.value)},b=e.inject("themeColor");return(P,T)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(p,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(n),class:e.normalizeClass(a.status)},null,10,Ce),Se],8,be))}}),[["__scopeId","data-v-566775ba"]]),Tt="";const we=a=>(e.pushScopeId("data-v-39f156fd"),a=a(),e.popScopeId(),a),Pe=["checked"],Ne=we(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var $e=g(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(a,{emit:k}){e.useCssVars(n=>({"20cfc5a0":e.unref(l)}));const l=e.inject("themeColor");return(n,p)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:p[0]||(p[0]=e.withModifiers(b=>k("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:a.checked},null,8,Pe),Ne]))}}),[["__scopeId","data-v-39f156fd"]]),Ht="";const Ie=a=>(e.pushScopeId("data-v-0ed08e20"),a=a(),e.popScopeId(),a),Ee={class:"easy-data-table__rows-selector"},Ve={class:"rows-input"},Fe=Ie(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Te=["onClick"];var ze=g(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(a,{emit:k}){const l=a;e.useCssVars(h=>({"83c11052":e.unref(m),"6b60f418":e.unref(s),"346ac97c":e.unref(d)}));const n=e.ref(!1),p=e.ref(!1),b=e.inject("dataTable");e.watch(n,h=>{if(h&&b){const S=window.innerHeight,x=b.value.getBoundingClientRect().height,I=b.value.getBoundingClientRect().top;S-(x+I)<=100?p.value=!0:p.value=!1}});const P=e.computed({get:()=>l.modelValue,set:h=>{k("update:modelValue",h)}}),T=h=>{P.value=h,n.value=!1},O=(h,S)=>{let x=h.parentNode;for(;x!=null;){if(x.classList&&x.classList.contains(S))return!0;x=x.parentNode}return!1},z=h=>{O(h.target,"easy-data-table__rows-selector")||(n.value=!1)};e.onMounted(()=>{document.addEventListener("click",z)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",z)});const d=e.inject("themeColor"),s=e.inject("footerBackgroundColor"),m=e.inject("footerFontColor");return(h,S)=>(e.openBlock(),e.createElementBlock("div",Ee,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:S[0]||(S[0]=x=>n.value=!n.value)},[e.createElementVNode("div",Ve,e.toDisplayString(e.unref(P)),1),Fe]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:n.value,inside:p.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.rowsItems,x=>(e.openBlock(),e.createElementBlock("li",{key:x,class:e.normalizeClass({selected:x===e.unref(P)}),onClick:I=>T(x)},e.toDisplayString(x),11,Te))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),Lt="";const A=a=>(e.pushScopeId("data-v-969989cc"),a=a(),e.popScopeId(),a),He={class:"lds-ring"},Oe=[A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1)),A(()=>e.createElementVNode("div",null,null,-1))];var Le=g(e.defineComponent({setup(a){e.useCssVars(n=>({"284c10f4":e.unref(l),"90c4d0a4":e.unref(k)}));const k=e.inject("themeColor"),l=e.inject("loadingEntitySizePx");return(n,p)=>(e.openBlock(),e.createElementBlock("div",He,Oe))}}),[["__scopeId","data-v-969989cc"]]),qt="";const Re={class:"buttons-pagination"},Ae=["onClick"];var De=g(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(a,{emit:k}){const l=a;e.useCssVars(d=>({aa5730a0:e.unref(T),"24829312":e.unref(O),"98a0e762":e.unref(z)}));const n=7,p=d=>{d.type==="button"&&!d.active&&k("updatePage",d.page)},b=e.computed(()=>{const d=[];if(l.maxPaginationNumber<=n)for(let s=1;s<=l.maxPaginationNumber;s+=1)d.push({type:"button",page:s,active:s===l.currentPaginationNumber});else if([1,2,l.maxPaginationNumber,l.maxPaginationNumber-1].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)if(s<=3)d.push({type:"button",page:s,active:s===l.currentPaginationNumber});else if(s===4)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-s);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else if([3,4].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)s<=5?d.push({type:"button",page:s,active:s===l.currentPaginationNumber}):s===6?d.push({type:"omission"}):d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else if([l.maxPaginationNumber-2,l.maxPaginationNumber-3].includes(l.currentPaginationNumber))for(let s=1;s<=n;s+=1)if(s===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(s===2)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-s);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else for(let s=1;s<=n;s+=1)if(s===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(s===2||s===6)d.push({type:"omission"});else if(s===7)d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else{const m=4-s,h=l.currentPaginationNumber-m;d.push({type:"button",page:h,active:h===l.currentPaginationNumber})}return d}),P=e.inject("rowHeight"),T=e.computed(()=>`${P*.6}px`),O=e.inject("rowBorderColor"),z=e.inject("themeColor");return(d,s)=>(e.openBlock(),e.createElementBlock("div",Re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:m.type==="button",active:m.type==="button"&&m.active,omission:m.type==="omission"}]),onClick:S=>p(m)},e.toDisplayString(m.type==="button"?m.page:"..."),11,Ae))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Jt="";const v=a=>(e.pushScopeId("data-v-c9da5286"),a=a(),e.popScopeId(),a),Me=[v(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],je=[v(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var qe=g(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(a,{emit:k}){const l=e.useSlots();return(n,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":a.isFirstPage}]),onClick:p[0]||(p[0]=b=>k("clickPrevPage"))},Me,2),e.unref(l).buttonsPagination?e.renderSlot(n.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":a.isLastPage}]),onClick:p[1]||(p[1]=b=>k("clickNextPage"))},je,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),Qt="";const We={key:0},Je=["onClick"],Ue={key:1,class:"header-text__wrapper"},Ge={class:"header-text"},Ke=["onClick"],Qe={class:"loading-entity"},Xe={key:1,class:"data-table__message"},Ye={key:0,class:"data-table__footer"},Ze={key:0,class:"footer__rows-per-page"},ve=e.createTextVNode(" rows per page: "),et={class:"footer__items-index"};var ee=g(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},filterOptions:{type:Array,default:null},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},checkboxColumnWidth:{type:Number,default:null},hideRowsPerPage:{type:Boolean,default:!1}},emits:["update:itemsSelected","update:serverOptions","clickRow"],setup(a,{expose:k,emit:l}){const n=a;e.useCssVars(o=>({"17231b25":e.unref(b),"522d8976":e.unref(rt),"5cb25bd7":e.unref(s),c73f587e:e.unref(nt),"03eb8bbc":e.unref(it),a0fd7266:e.unref(tt),"4749c154":e.unref(x),"438d5ad6":e.unref(T),c7147770:e.unref(ot),"1e7ebc99":e.unref(p),"3de3cb8b":e.unref(P),"41869e68":a.headerBackgroundColor,a66323d4:e.unref(at),"483712ce":e.unref(lt),"49aaf451":e.unref(st),"72483237":e.unref(O),"5a5b7936":e.unref(z),"501ce9e0":e.unref(h),"3d5bf891":e.unref(m),"5acc9ffe":e.unref(d),"39c8ef86":e.unref(S)}));const{rowBorderColor:p,tableBorderColor:b,headerFontColor:P,rowFontColor:T,rowHoverBackgroundColor:O,rowHoverFontColor:z,footerBackgroundColor:d,rowBackgroundColor:s,evenRowBackgroundColor:m,evenRowFontColor:h,footerFontColor:S}=e.toRefs(n),x=e.computed(()=>`${n.tableFontSize}px`),I=e.computed(()=>n.tableFontSize*(n.dense?2:3)),tt=e.computed(()=>`${I.value}px`),ot=e.computed(()=>`-${I.value}px`),nt=e.computed(()=>n.tableHeight?`${n.tableHeight}px`:null),rt=e.computed(()=>`${I.value*5}px`),te=e.computed(()=>Math.round(n.tableFontSize/2.5)),at=e.computed(()=>`${te.value}px`),oe=e.computed(()=>Math.round(te.value)),lt=e.computed(()=>`-${oe.value}px`),st=e.computed(()=>`${oe.value}px`),ct=e.computed(()=>`${n.tableFontSize*5}px`),it=e.computed(()=>n.tableHeight?`${n.tableHeight-I.value}px`:`${n.tableFontSize*5*2}px`),dt=e.computed(()=>{var o;return(o=n.checkboxColumnWidth)!=null?o:1.3*n.tableFontSize+20});e.provide("themeColor",n.themeColor),e.provide("loadingEntitySizePx",ct.value),e.provide("rowHeight",I.value),e.provide("rowBorderColor",p.value),e.provide("footerBackgroundColor",d.value),e.provide("footerFontColor",S.value);const D=e.useSlots(),ut=e.computed(()=>D.body),pt=e.computed(()=>D.pagination),ft=e.computed(()=>D.loading),ne=e.ref(),U=e.ref();e.provide("dataTable",ne);const re=e.ref(!1);e.onMounted(()=>{U.value.addEventListener("scroll",()=>{re.value=U.value.scrollLeft>0})});const u=e.computed({get:()=>{if(n.serverOptions){const{page:o,rowsPerPage:r,sortBy:t,sortType:c}=n.serverOptions;return{page:o,rowsPerPage:r,sortBy:t!=null?t:null,sortType:c!=null?c:null}}return null},set:o=>{l("update:serverOptions",o)}}),G=e.computed(()=>n.itemsSelected!==null),B=e.computed(()=>u.value!==null),mt=e.computed(()=>!B.value&&n.rowsItems.findIndex(o=>o===n.rowsPerPage)===-1?[n.rowsPerPage,...n.rowsItems]:n.rowsItems),gt=()=>n.sortBy!==""?{sortBy:n.sortBy,sortDesc:n.sortType==="desc"}:null,E=e.ref(gt()),K=e.computed(()=>n.headers.findIndex(o=>o.fixed)!==-1),ht=e.computed(()=>K.value?n.headers.filter(o=>o.fixed):[]),yt=e.computed(()=>n.headers.filter(o=>!o.fixed)),L=e.computed(()=>{const r=[...ht.value,...yt.value].map(i=>{const f=i;return i.sortable&&(f.sortType="none"),u.value&&i.value===u.value.sortBy&&u.value.sortType&&(f.sortType=u.value.sortType),!B.value&&E.value&&i.value===E.value.sortBy&&(f.sortType=E.value.sortDesc?"desc":"asc"),f});let t=[];n.showIndex?t=[n.fixedIndex||K.value?{text:"#",value:"index",fixed:!0,width:n.indexColumnWidth}:{text:"#",value:"index"},...r]:t=r;let c=[];return G.value?c=[n.fixedCheckbox||K.value?{text:"checkbox",value:"checkbox",fixed:!0,width:dt.value}:{text:"checkbox",value:"checkbox"},...t]:c=t,c}),N=e.computed(()=>L.value.filter(o=>o.fixed)),ae=e.computed(()=>N.value.length?N.value[N.value.length-1].value:""),_t=o=>{var t;const r=(t=o.width)!=null?t:N.value.length?100:null;if(r)return`width: ${r}px; min-width: ${r}px;`},kt=e.computed(()=>{if(!N.value.length)return[];const o=N.value.map(r=>{var t;return(t=r.width)!=null?t:100});return N.value.map((r,t)=>{var c,i;return{value:r.value,fixed:(c=r.fixed)!=null?c:!0,width:(i=r.width)!=null?i:100,distance:t===0?0:o.reduce((f,he,Pt)=>{let ye=f;return Pt<t&&(ye+=he),ye})}})}),le=(o,r="th")=>{if(!N.value.length)return;const t=kt.value.find(c=>c.value===o);if(t)return`left: ${t.distance}px;z-index: ${r==="th"?3:1}; position: sticky`},se=e.computed(()=>L.value.map(o=>o.value)),R=(o,r)=>{if(o.includes(".")){let t="";return o.split(".").forEach((i,f)=>{t=f===0?r[i]:t[i]}),t}return r[o]},xt=(o,r)=>{const t=R(o,r);return Array.isArray(t)?t.join(","):t},w=e.computed({get:()=>{var o;return(o=n.itemsSelected)!=null?o:[]},set:o=>{l("update:itemsSelected",o)}}),ce=e.computed(()=>{if(!B.value&&n.searchValue!==""){const o=new RegExp(n.searchValue,"i");return n.items.filter(r=>o.test(n.searchField!==""?r[n.searchField]:Object.values(r).join(" ")))}return n.items}),V=e.computed(()=>{let o=[...ce.value];return n.filterOptions?(n.filterOptions.forEach(r=>{o=o.filter(t=>{const{field:c,comparison:i,criteria:f}=r;switch(i){case"=":return t[c]===f;case"!=":return t[c]!==f;case">":return t[c]>f;case"<":return t[c]<f;case"<=":return t[c]<=f;case">=":return t[c]>=f;case"between":return t[c]>=Math.min(...f)&&t[c]<=Math.max(...f);default:return t[c]===f}})}),o):ce.value}),M=e.computed(()=>w.value.length===0||w.value.every(r=>V.value.findIndex(t=>JSON.stringify(r)===JSON.stringify(t))===-1)?"noneSelected":w.value.length===V.value.length&&w.value.every(t=>V.value.findIndex(c=>JSON.stringify(t)===JSON.stringify(c))!==-1)?"allSelected":"partSelected"),y=e.ref(B.value?n.serverOptions.page:1),{items:Q}=e.toRefs(n);e.watch(Q,()=>{B.value||(y.value=1)},{deep:!0});const $=e.ref(B.value?n.serverOptions.rowsPerPage:n.rowsPerPage);e.watch($,o=>{u.value&&(u.value=H(C({},u.value),{page:1,rowsPerPage:o})),y.value=1});const bt=(o,r)=>{let t=null;r==="none"?t="asc":r==="asc"?t="desc":t=null,u.value?u.value=H(C({},u.value),{sortBy:t!==null?o:null,sortType:t}):t===null?E.value=null:E.value={sortBy:o,sortDesc:t==="desc"}},ie=e.computed(()=>{if(B.value)return n.items;if(E.value===null)return V.value;const{sortBy:o,sortDesc:r}=E.value;return[...V.value].sort((c,i)=>R(o,c)<R(o,i)?r?1:-1:R(o,c)>R(o,i)?r?-1:1:0)}),X=e.computed(()=>B.value?n.serverItemsLength:V.value.length),de=e.computed(()=>B.value?y.value*$.value:Math.min(V.value.length,y.value*$.value)),ue=e.computed(()=>(y.value-1)*$.value+1),j=e.computed(()=>Math.ceil(X.value/$.value)),q=e.computed(()=>y.value===j.value),W=e.computed(()=>y.value===1),{loading:F}=e.toRefs(n),Y=()=>{if(!q.value&&!F.value)if(u.value){const o=y.value+1;u.value=H(C({},u.value),{page:o})}else y.value+=1},Z=()=>{if(!W.value&&!F.value)if(u.value){const o=y.value-1;u.value=H(C({},u.value),{page:o})}else y.value-=1},pe=o=>{F.value||(u.value?u.value=H(C({},u.value),{page:o}):y.value=o)};e.watch(F,(o,r)=>{u.value&&o===!1&&r===!0&&(y.value=u.value.page)});const fe=e.computed(()=>B.value?n.items:ie.value.slice(ue.value-1,de.value)),me=e.computed(()=>$.value*(y.value-1)+1),Ct=e.computed(()=>$.value*y.value),J=e.computed(()=>n.showIndex?fe.value.map((o,r)=>C({index:me.value+r},o)):fe.value),ge=e.computed(()=>G.value?M.value==="allSelected"?J.value.map(o=>C({checkbox:!0},o)):M.value==="noneSelected"?J.value.map(o=>C({checkbox:!1},o)):J.value.map(o=>{const r=w.value.findIndex(t=>{const c=C({},o);return delete c.index,JSON.stringify(t)===JSON.stringify(c)})!==-1;return C({checkbox:r},o)}):J.value),St=o=>{w.value=o?ie.value:[]},Bt=o=>{const r=o.checkbox;if(delete o.checkbox,delete o.index,r)w.value=w.value.filter(t=>JSON.stringify(t)!==JSON.stringify(o));else{const t=w.value;t.unshift(o),w.value=t}},wt=o=>{const r=C({},o);if(G.value){const{checkbox:t}=o;delete r.checkbox,r.isSelected=t}if(n.showIndex){const{index:t}=o;delete r.index,r.indexInCurrentPage=t}l("clickRow",r)};return k({clientItemsLength:X,currentPageFirstIndex:me,currentPageLastIndex:Ct,maxPaginationNumber:j,currentPaginationNumber:y,isLastPage:q,isFirstPage:W,nextPage:Y,prevPage:Z,updatePage:pe}),(o,r)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:ne,class:"vue3-easy-data-table"},[e.createElementVNode("div",{ref_key:"tableBody",ref:U,class:e.normalizeClass(["data-table__body",{"fixed-header":a.fixedHeader,"fixed-height":a.tableHeight,"show-shadow":re.value}])},[e.createElementVNode("table",{class:e.normalizeClass({fixed:e.unref(N).length})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,c)=>(e.openBlock(),e.createElementBlock("col",{key:c,style:e.normalizeStyle(_t(t))},null,4))),128))]),e.unref(L).length?(e.openBlock(),e.createElementBlock("thead",We,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,c)=>(e.openBlock(),e.createElementBlock("th",{key:c,class:e.normalizeClass({sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",fixed:t.fixed,hasShadow:t.value===e.unref(ae)}),style:e.normalizeStyle(le(t.value)),onClick:i=>t.sortable&&t.sortType?bt(t.value,t.sortType):null},[t.text==="checkbox"?(e.openBlock(),e.createBlock(Be,{key:e.unref(M),status:e.unref(M),onChange:St},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ue,[e.createElementVNode("span",Ge,e.toDisplayString(t.text),1),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,Je))),128))])])):e.createCommentVNode("",!0),e.unref(ut)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.unref(Q).length&&e.unref(se).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":a.alternating,"hover-to-change-color":a.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ge),(t,c)=>(e.openBlock(),e.createElementBlock("tr",{key:c,onClick:i=>wt(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(se),(i,f)=>(e.openBlock(),e.createElementBlock("td",{key:f,style:e.normalizeStyle(le(i,"td")),class:e.normalizeClass({hasShadow:i===e.unref(ae)})},[e.unref(D)[i]?e.renderSlot(o.$slots,i,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):i==="checkbox"?(e.openBlock(),e.createBlock($e,{key:1,checked:t[i],onChange:he=>Bt(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(xt(i,t)),1)],64))],6))),128))],8,Ke))),128))],2)):e.createCommentVNode("",!0)],64))],2),e.unref(F)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!e.unref(Q).length&&e.unref(F)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":a.hideFooter}])},null,2),e.createElementVNode("div",Qe,[e.unref(ft)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Le,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(ge).length&&!e.unref(F)?(e.openBlock(),e.createElementBlock("div",Xe,e.toDisplayString(a.emptyMessage),1)):e.createCommentVNode("",!0)],2),a.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ye,[a.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ze,[ve,e.createVNode(ze,{modelValue:$.value,"onUpdate:modelValue":r[0]||(r[0]=t=>$.value=t),"rows-items":e.unref(mt)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",et,e.toDisplayString(`${e.unref(ue)}-${e.unref(de)}`)+" of "+e.toDisplayString(e.unref(X)),1),e.unref(pt)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(W),isLastPage:e.unref(q),currentPaginationNumber:y.value,maxPaginationNumber:e.unref(j),nextPage:Y,prevPage:Z})),void 0,!0):(e.openBlock(),e.createBlock(qe,{key:2,"is-first-page":e.unref(W),"is-last-page":e.unref(q),onClickNextPage:Y,onClickPrevPage:Z},e.createSlots({_:2},[a.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(De,{"current-pagination-number":y.value,"max-pagination-number":e.unref(j),onUpdatePage:pe},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],512))}}),[["__scopeId","data-v-20b07e6b"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",ee),ee});

@@ -6,3 +6,3 @@ {

"private": false,
"version": "1.2.19",
"version": "1.2.20",
"types": "./types/main.d.ts",

@@ -18,3 +18,3 @@ "license": "MIT",

"data-table",
"mvue3-component",
"vue3-component",
"vue-component"

@@ -21,0 +21,0 @@ ],

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