vue3-easy-data-table
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -490,11 +490,15 @@ var __defProp = Object.defineProperty; | ||
const unFixedHeaders = computed(() => headers.value.filter((header) => !header.fixed)); | ||
const clientSortOptions = ref((() => { | ||
if (sortBy.value !== "") { | ||
const generateClientSortOptions = (sortByValue, sortTypeValue) => { | ||
if (sortByValue !== "") { | ||
return { | ||
sortBy: sortBy.value, | ||
sortDesc: sortType.value === "desc" | ||
sortBy: sortByValue, | ||
sortDesc: sortTypeValue === "desc" | ||
}; | ||
} | ||
return null; | ||
})()); | ||
}; | ||
const clientSortOptions = ref(generateClientSortOptions(sortBy.value, sortType.value)); | ||
watch([sortBy, sortType], () => { | ||
clientSortOptions.value = generateClientSortOptions(sortBy.value, sortType.value); | ||
}); | ||
const headersForRender = computed(() => { | ||
@@ -501,0 +505,0 @@ var _a; |
@@ -1,1 +0,1 @@ | ||
(function(e,P){typeof exports=="object"&&typeof module!="undefined"?module.exports=P(require("vue")):typeof define=="function"&&define.amd?define(["vue"],P):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=P(e.Vue))})(this,function(e){"use strict";var Mt=Object.defineProperty,jt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var Se=Object.getOwnPropertySymbols;var qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var Be=(e,P,k)=>P in e?Mt(e,P,{enumerable:!0,configurable:!0,writable:!0,value:k}):e[P]=k,E=(e,P)=>{for(var k in P||(P={}))qt.call(P,k)&&Be(e,k,P[k]);if(Se)for(var k of Se(P))Jt.call(P,k)&&Be(e,k,P[k]);return e},Y=(e,P)=>jt(e,Wt(P));var P="",k=(n,l)=>{const t=n.__vccOpts||n;for(const[r,c]of l)t[r]=c;return t};const we=n=>(e.pushScopeId("data-v-e0a0b7f0"),n=n(),e.popScopeId(),n),Ie=["onClick"],$e=["checked"],Ee=we(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Ve=k(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(n,{emit:l}){const t=n;e.useCssVars(d=>({"51ab8a49":e.unref(s)}));const r=e.computed(()=>t.status==="allSelected"),c=()=>{l("change",!r.value)},s=e.inject("themeColor");return(d,o)=>(e.openBlock(),e.createElementBlock("div",{class:"easy-checkbox",onClick:e.withModifiers(c,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(r),class:e.normalizeClass(n.status)},null,10,$e),Ee],8,Ie))}}),[["__scopeId","data-v-e0a0b7f0"]]),Gt="";const Fe=n=>(e.pushScopeId("data-v-7e69a276"),n=n(),e.popScopeId(),n),Le=["checked"],ve=Fe(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Re=k(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(n,{emit:l}){e.useCssVars(r=>({fdaf7e9e:e.unref(t)}));const t=e.inject("themeColor");return(r,c)=>(e.openBlock(),e.createElementBlock("div",{class:"easy-checkbox",onClick:c[0]||(c[0]=e.withModifiers(s=>l("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:n.checked},null,8,Le),ve]))}}),[["__scopeId","data-v-7e69a276"]]),Qt="";const Te=n=>(e.pushScopeId("data-v-09dad912"),n=n(),e.popScopeId(),n),Oe={class:"easy-data-table__rows-selector"},ze={class:"rows-input"},De=Te(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),He=["onClick"];var Ae=k(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(n,{emit:l}){const t=n;e.useCssVars(m=>({"7fe9410c":e.unref(h)}));const r=e.ref(!1),c=e.ref(!1),s=e.inject("dataTable");e.watch(r,m=>{if(m&&s){const b=window.innerHeight,g=s.value.getBoundingClientRect().height,V=s.value.getBoundingClientRect().top;b-(g+V)<=100?c.value=!0:c.value=!1}});const d=e.computed({get:()=>t.modelValue,set:m=>{l("update:modelValue",m)}}),o=m=>{d.value=m,r.value=!1},a=(m,b)=>{let g=m.parentNode;for(;g!=null;){if(g.classList&&g.classList.contains(b))return!0;g=g.parentNode}return!1},i=m=>{a(m.target,"easy-data-table__rows-selector")||(r.value=!1)};e.onMounted(()=>{document.addEventListener("click",i)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",i)});const h=e.inject("themeColor");return(m,b)=>(e.openBlock(),e.createElementBlock("div",Oe,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:b[0]||(b[0]=g=>r.value=!r.value)},[e.createElementVNode("div",ze,e.toDisplayString(e.unref(d)),1),De]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:r.value,inside:c.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.rowsItems,g=>(e.openBlock(),e.createElementBlock("li",{key:g,class:e.normalizeClass({selected:g===e.unref(d)}),onClick:V=>o(g)},e.toDisplayString(g),11,He))),128))],2)]))}}),[["__scopeId","data-v-09dad912"]]),Yt="";const Z=n=>(e.pushScopeId("data-v-1fa3a520"),n=n(),e.popScopeId(),n),Me={class:"lds-ring"},je=[Z(()=>e.createElementVNode("div",null,null,-1)),Z(()=>e.createElementVNode("div",null,null,-1)),Z(()=>e.createElementVNode("div",null,null,-1)),Z(()=>e.createElementVNode("div",null,null,-1))];var We=k(e.defineComponent({setup(n){e.useCssVars(t=>({"26774109":e.unref(l)}));const l=e.inject("themeColor");return(t,r)=>(e.openBlock(),e.createElementBlock("div",Me,je))}}),[["__scopeId","data-v-1fa3a520"]]),on="";const qe={class:"loader-line"};var Je=k(e.defineComponent({setup(n){e.useCssVars(t=>({"0d327f57":e.unref(l)}));const l=e.inject("themeColor");return(t,r)=>(e.openBlock(),e.createElementBlock("div",qe))}}),[["__scopeId","data-v-7d281cac"]]),ln="";const Ue={class:"buttons-pagination"},Ge=["onClick"];var Ke=k(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(n,{emit:l}){const t=n;e.useCssVars(o=>({"40dd4f07":e.unref(d)}));const r=7,c=o=>{o.type==="button"&&!o.active&&l("updatePage",o.page)},s=e.computed(()=>{const o=[];if(t.maxPaginationNumber<=r)for(let a=1;a<=t.maxPaginationNumber;a+=1)o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if([1,2,t.maxPaginationNumber,t.maxPaginationNumber-1].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)if(a<=3)o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if(a===4)o.push({type:"omission"});else{const i=t.maxPaginationNumber-(r-a);o.push({type:"button",page:i,active:i===t.currentPaginationNumber,activePrev:i+1===t.currentPaginationNumber})}else if([3,4].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)a<=5?o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber}):a===6?o.push({type:"omission"}):o.push({type:"button",page:t.maxPaginationNumber,active:t.maxPaginationNumber===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if([t.maxPaginationNumber-2,t.maxPaginationNumber-3].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)if(a===1)o.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2)o.push({type:"omission"});else{const i=t.maxPaginationNumber-(r-a);o.push({type:"button",page:i,active:i===t.currentPaginationNumber,activePrev:i+1===t.currentPaginationNumber})}else for(let a=1;a<=r;a+=1)if(a===1)o.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2||a===6)o.push({type:"omission"});else if(a===7)o.push({type:"button",page:t.maxPaginationNumber,active:t.maxPaginationNumber===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else{const i=4-a,h=t.currentPaginationNumber-i;o.push({type:"button",page:h,active:h===t.currentPaginationNumber,activePrev:h+1===t.currentPaginationNumber})}return o}),d=e.inject("themeColor");return(o,a)=>(e.openBlock(),e.createElementBlock("div",Ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(i,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:i.type==="button",active:i.type==="button"&&i.active,"active-prev":i.type==="button"&&i.activePrev,omission:i.type==="omission"}]),onClick:m=>c(i)},e.toDisplayString(i.type==="button"?i.page:"..."),11,Ge))),128))]))}}),[["__scopeId","data-v-4c681fa2"]]),cn="";const ie=n=>(e.pushScopeId("data-v-c9da5286"),n=n(),e.popScopeId(),n),Qe=[ie(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Xe=[ie(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Ye=k(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(n,{emit:l}){const t=e.useSlots();return(r,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":n.isFirstPage}]),onClick:c[0]||(c[0]=s=>l("clickPrevPage"))},Qe,2),e.unref(t).buttonsPagination?e.renderSlot(r.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":n.isLastPage}]),onClick:c[1]||(c[1]=s=>l("clickNextPage"))},Xe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);function Ze(n,l,t){return{clickRow:c=>{const s=E({},c);if(n.value){const{checkbox:d}=c;delete s.checkbox,s.isSelected=d}if(l.value){const{index:d}=c;delete s.index,s.indexInCurrentPage=d}t("clickRow",s)}}}function et(n,l,t){const r=e.ref([]);return{expandingItemIndexList:r,updateExpandingItemIndexList:(d,o,a)=>{a.stopPropagation();const i=r.value.indexOf(d);if(i!==-1)r.value.splice(i,1);else{const h=n.value.findIndex(m=>JSON.stringify(m)===JSON.stringify(o));t("expandRow",l.value+h),r.value.push(l.value+h)}},clearExpandingItemIndexList:()=>{r.value=[]}}}function tt(n){const l=e.computed(()=>n.value.filter(c=>c.fixed)),t=e.computed(()=>l.value.length?l.value[l.value.length-1].value:""),r=e.computed(()=>{if(!l.value.length)return[];const c=l.value.map(s=>{var d;return(d=s.width)!=null?d:100});return l.value.map((s,d)=>{var o,a;return{value:s.value,fixed:(o=s.fixed)!=null?o:!0,width:(a=s.width)!=null?a:100,distance:d===0?0:c.reduce((i,h,m)=>{let b=i;return m<d&&(b+=h),b})}})});return{fixedHeaders:l,lastFixedColumn:t,fixedColumnsInfos:r}}function nt(n,l,t,r,c,s,d,o,a,i,h,m,b,g,V,_,f){const y=e.computed(()=>s.value.findIndex(w=>w.fixed)!==-1),x=e.computed(()=>y.value?s.value.filter(w=>w.fixed):[]),v=e.computed(()=>s.value.filter(w=>!w.fixed)),N=e.ref((()=>g.value!==""?{sortBy:g.value,sortDesc:V.value==="desc"}:null)()),S=e.computed(()=>{var A;const F=[...x.value,...v.value].map(R=>{const M=R;return R.sortable&&(M.sortType="none"),m.value&&R.value===m.value.sortBy&&m.value.sortType&&(M.sortType=m.value.sortType),!i.value&&N.value&&R.value===N.value.sortBy&&(M.sortType=N.value.sortDesc?"desc":"asc"),M});let C=[];d.value?C=[r.value||y.value?{text:"",value:"expand",fixed:!0,width:l.value}:{text:"",value:"expand"},...F]:C=F;let H=[];b.value?H=[c.value||y.value?{text:"#",value:"index",fixed:!0,width:o.value}:{text:"#",value:"index"},...C]:H=C;let W=[];return a.value?W=[t.value||y.value?{text:"checkbox",value:"checkbox",fixed:!0,width:(A=n.value)!=null?A:36}:{text:"checkbox",value:"checkbox"},...H]:W=H,W}),B=e.computed(()=>S.value.map(w=>w.value));return{clientSortOptions:N,headerColumns:B,headersForRender:S,updateSortField:(w,F)=>{let C=null;F==="none"?C="asc":F==="asc"?C="desc":C=h.value?"asc":null,i.value?_(w,C):C===null?N.value=null:N.value={sortBy:w,sortDesc:C==="desc"},f("updateSort",{sortType:C,sortBy:w})}}}function at(n,l,t,r,c,s,d,o,a){const i=e.computed(()=>(n.value-1)*c.value+1),h=e.computed(()=>t.value?Math.min(a.value,n.value*c.value):Math.min(o.value.length,n.value*c.value)),m=e.computed(()=>t.value?r.value:o.value.slice(i.value-1,h.value)),b=e.computed(()=>d.value?m.value.map((_,f)=>E({index:i.value+f},_)):m.value),g=e.computed(()=>s.value.length===0||s.value.every(f=>o.value.findIndex(y=>JSON.stringify(f)===JSON.stringify(y))===-1)?"noneSelected":s.value.length===o.value.length&&s.value.every(y=>o.value.findIndex(x=>JSON.stringify(y)===JSON.stringify(x))!==-1)?"allSelected":"partSelected"),V=e.computed(()=>l.value?g.value==="allSelected"?b.value.map(_=>E({checkbox:!0},_)):g.value==="noneSelected"?b.value.map(_=>E({checkbox:!1},_)):b.value.map(_=>{const f=s.value.findIndex(y=>{const x=E({},_);return delete x.index,JSON.stringify(y)===JSON.stringify(x)})!==-1;return E({checkbox:f},_)}):b.value);return{currentPageFirstIndex:i,currentPageLastIndex:h,multipleSelectStatus:g,pageItems:V}}function ot(n,l,t,r,c,s,d){const o=e.ref(s.value?s.value.page:n.value),a=e.computed(()=>Math.ceil(r.value/c.value)),i=e.computed(()=>a.value===0||o.value===a.value),h=e.computed(()=>o.value===1);return{currentPaginationNumber:o,maxPaginationNumber:a,isLastPage:i,isFirstPage:h,nextPage:()=>{if(r.value!==0&&!i.value&&!t.value)if(l.value){const _=o.value+1;d(_)}else o.value+=1},prevPage:()=>{if(r.value!==0&&!h.value&&!t.value)if(l.value){const _=o.value-1;d(_)}else o.value-=1},updatePage:_=>{t.value||(l.value?d(_):o.value=_)},updateCurrentPaginationNumber:_=>{o.value=_}}}function rt(n,l,t,r){const c=e.computed(()=>!n.value&&l.value.findIndex(o=>o===r.value)===-1?[r.value,...l.value]:l.value),s=e.ref(t.value?t.value.rowsPerPage:r.value);return{rowsItemsComputed:c,rowsPerPageRef:s,updateRowsPerPage:o=>{s.value=o}}}function lt(n,l){const t=e.computed({get:()=>{if(n.value){const{page:d,rowsPerPage:o,sortBy:a,sortType:i}=n.value;return{page:d,rowsPerPage:o,sortBy:a!=null?a:null,sortType:i!=null?i:null}}return null},set:d=>{l("update:serverOptions",d)}});return{serverOptionsComputed:t,updateServerOptionsPage:d=>{t.value&&(t.value=Y(E({},t.value),{page:d}))},updateServerOptionsSort:(d,o)=>{t.value&&(t.value=Y(E({},t.value),{sortBy:o!==null?d:null,sortType:o}))},updateServerOptionsRowsPerPage:d=>{t.value&&(t.value=Y(E({},t.value),{page:1,rowsPerPage:d}))}}}function z(n,l){if(n.includes(".")){let t="";const r=n.split("."),{length:c}=r;let s=0;for(;s<c&&(t=s===0?l[r[s]]:t[r[s]],s+=1,t!==void 0););return t}return l[n]}function st(n,l){const t=z(n,l);return Array.isArray(t)?t.join(","):t}function it(n,l,t,r,c,s,d,o,a){const i=e.computed(()=>{if(!t.value&&d.value!==""){const f=new RegExp(d.value,"i");return r.value.filter(y=>f.test(s.value!==""?y[s.value]:Object.values(y).join(" ")))}return r.value}),h=e.computed(()=>{let f=[...i.value];return l.value?(l.value.forEach(y=>{f=f.filter(x=>{const{field:v,comparison:N,criteria:S}=y;if(typeof N=="function")return N(z(v,x),S);const B=z(v,x);switch(N){case"=":return B===S;case"!=":return B!==S;case">":return B>S;case"<":return B<S;case"<=":return B<=S;case">=":return B>=S;case"between":return B>=Math.min(...S)&&B<=Math.max(...S);default:return B===S}})}),f):i.value}),m=e.computed(()=>{if(t.value)return r.value;if(n.value===null)return h.value;const{sortBy:f,sortDesc:y}=n.value;return[...h.value].sort((v,N)=>z(f,v)<z(f,N)?y?1:-1:z(f,v)>z(f,N)?y?-1:1:0)}),b=e.computed(()=>t.value?o.value:m.value.length),g=e.computed({get:()=>{var f;return(f=c.value)!=null?f:[]},set:f=>{a("update:itemsSelected",f)}});return{totalItems:m,selectItemsComputed:g,totalItemsLength:b,toggleSelectAll:f=>{g.value=f?m.value:[]},toggleSelectItem:f=>{const y=f.checkbox;if(delete f.checkbox,delete f.index,y)g.value=g.value.filter(x=>JSON.stringify(x)!==JSON.stringify(f));else{const x=g.value;x.unshift(f),g.value=x}}}}var ct={alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},checkboxColumnWidth:{type:Number,default:null},currentPage:{type:Number,default:1},emptyMessage:{type:String,default:"No Available Data"},expandColumnWidth:{type:Number,default:36},filterOptions:{type:Array,default:null},fixedExpand:{type:Boolean,default:!1},fixedHeader:{type:Boolean,default:!0},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},headerTextDirection:{type:String,default:"left"},bodyTextDirection:{type:String,default:"left"},hideFooter:{type:Boolean,default:!1},hideRowsPerPage:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},itemsSelected:{type:Array,default:null},loading:{type:Boolean,deault:!1},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowsPerPageMessage:{type:String,default:"rows per page:"},searchField:{type:String,default:""},searchValue:{type:String,default:""},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},showIndex:{type:Boolean,default:!1},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},tableMinHeight:{type:Number,default:180},tableHeight:{type:Number,default:null},themeColor:{type:String,default:"#42b883"},tableClassName:{type:String,default:""},headerClassName:{type:String,default:""},headerItemClassName:{type:[Function,String],default:""},bodyRowClassName:{type:[Function,String],default:""},bodyItemClassName:{type:[Function,String],default:""},noHover:{type:Boolean,default:!1},borderCell:{type:Boolean,default:!1},mustSort:{type:Boolean,default:!1}},fn="",mn="";const dt=n=>(e.pushScopeId("data-v-2351cc61"),n=n(),e.popScopeId(),n),ut=["onClick"],pt={key:1,class:"header-text"},ft=["onClick"],mt=["onClick"],gt=["colspan"],ht={key:0,class:"vue3-easy-data-table__loading"},_t=dt(()=>e.createElementVNode("div",{class:"vue3-easy-data-table__loading-mask"},null,-1)),yt={class:"loading-entity"},bt={key:1,class:"vue3-easy-data-table__message"},xt={key:0,class:"vue3-easy-data-table__footer"},kt={key:0,class:"pagination__rows-per-page"},Pt={class:"pagination__items-index"},Ct=e.defineComponent({props:Y(E({},ct),{items:{type:Array,required:!0},headers:{type:Array,required:!0}}),emits:["clickRow","expandRow","updateSort","update:itemsSelected","update:serverOptions"],setup(n,{expose:l,emit:t}){const r=n;e.useCssVars(p=>({"11cca481":e.unref(St),"610141e2":e.unref(Nt)}));const{bodyTextDirection:c,checkboxColumnWidth:s,currentPage:d,expandColumnWidth:o,filterOptions:a,fixedCheckbox:i,fixedExpand:h,fixedHeader:m,fixedIndex:b,headers:g,headerTextDirection:V,indexColumnWidth:_,items:f,itemsSelected:y,loading:x,mustSort:v,rowsItems:N,rowsPerPage:S,searchField:B,searchValue:ne,serverItemsLength:w,serverOptions:F,showIndex:C,sortBy:H,sortType:W,tableHeight:A,tableMinHeight:R,themeColor:M}=e.toRefs(r),Nt=e.computed(()=>A.value?`${A.value}px`:null),St=e.computed(()=>`${R.value}px`);e.provide("themeColor",M.value);const q=e.useSlots(),Bt=e.computed(()=>!!q.pagination),wt=e.computed(()=>!!q.loading),de=e.computed(()=>!!q.expand),ue=e.ref(),ae=e.ref();e.provide("dataTable",ue);const pe=e.ref(!1);e.onMounted(()=>{ae.value.addEventListener("scroll",()=>{pe.value=ae.value.scrollLeft>0})});const oe=e.computed(()=>y.value!==null),j=e.computed(()=>F.value!==null),{serverOptionsComputed:re,updateServerOptionsPage:It,updateServerOptionsSort:$t,updateServerOptionsRowsPerPage:Et}=lt(F,t),{clientSortOptions:fe,headerColumns:me,headersForRender:D,updateSortField:Vt}=nt(s,o,i,h,b,g,de,_,oe,j,v,re,C,H,W,$t,t),{rowsItemsComputed:ge,rowsPerPageRef:O,updateRowsPerPage:Ft}=rt(j,N,F,S),{totalItems:Lt,selectItemsComputed:vt,totalItemsLength:ee,toggleSelectAll:Rt,toggleSelectItem:Tt}=it(fe,a,j,f,y,B,ne,w,t),{currentPaginationNumber:T,maxPaginationNumber:J,isLastPage:U,isFirstPage:G,nextPage:K,prevPage:Q,updatePage:le,updateCurrentPaginationNumber:Ot}=ot(d,j,x,ee,O,F,It),{currentPageFirstIndex:he,currentPageLastIndex:_e,multipleSelectStatus:ye,pageItems:X}=at(T,oe,j,f,O,vt,C,Lt,ee),te=e.computed(()=>T.value===0?0:(T.value-1)*O.value),{expandingItemIndexList:be,updateExpandingItemIndexList:zt,clearExpandingItemIndexList:xe}=et(X,te,t),{fixedHeaders:se,lastFixedColumn:ke,fixedColumnsInfos:Dt}=tt(D),{clickRow:Ht}=Ze(oe,C,t),At=p=>{var u;const L=(u=p.width)!=null?u:se.value.length?100:null;if(L)return`width: ${L}px; min-width: ${L}px;`},Pe=(p,L="th")=>{if(!se.value.length)return;const u=Dt.value.find(I=>I.value===p);if(u)return`left: ${u.distance}px;z-index: ${L==="th"?3:1};position: sticky;`};return e.watch(x,(p,L)=>{re.value&&p===!1&&L===!0&&(Ot(re.value.page),xe())}),e.watch(O,p=>{j.value?Et(p):le(1)}),e.watch([T,fe,B,ne,a],()=>{xe()},{deep:!0}),l({currentPageFirstIndex:he,currentPageLastIndex:_e,clientItemsLength:ee,maxPaginationNumber:J,currentPaginationNumber:T,isLastPage:U,isFirstPage:G,nextPage:K,prevPage:Q,updatePage:le,rowsPerPageOptions:ge,rowsPerPageActiveOption:O,updateRowsPerPageActiveOption:Ft}),(p,L)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:ue,class:e.normalizeClass(["vue3-easy-data-table",[p.tableClassName]])},[e.createElementVNode("div",{ref_key:"tableBody",ref:ae,class:e.normalizeClass(["vue3-easy-data-table__main",{"fixed-header":e.unref(m),"fixed-height":e.unref(A),"show-shadow":pe.value,"table-fixed":e.unref(se).length,hoverable:!p.noHover,"border-cell":p.borderCell}])},[e.createElementVNode("table",null,[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(D),(u,I)=>(e.openBlock(),e.createElementBlock("col",{key:I,style:e.normalizeStyle(At(u))},null,4))),128))]),e.unref(D).length&&!p.hideHeader?(e.openBlock(),e.createElementBlock("thead",{key:0,class:e.normalizeClass(["vue3-easy-data-table__header",[p.headerClassName]])},[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(D),(u,I)=>(e.openBlock(),e.createElementBlock("th",{key:I,class:e.normalizeClass([{sortable:u.sortable,none:u.sortable&&u.sortType==="none",desc:u.sortable&&u.sortType==="desc",asc:u.sortable&&u.sortType==="asc",shadow:u.value===e.unref(ke)},typeof p.headerItemClassName=="string"?p.headerItemClassName:p.headerItemClassName(u,I)]),style:e.normalizeStyle(Pe(u.value)),onClick:e.withModifiers($=>u.sortable&&u.sortType?e.unref(Vt)(u.value,u.sortType):null,["stop"])},[u.text==="checkbox"?(e.openBlock(),e.createBlock(Ve,{key:e.unref(ye),status:e.unref(ye),onChange:e.unref(Rt)},null,8,["status","onChange"])):(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(["header",`direction-${e.unref(V)}`])},[e.unref(q)[`header-${u.value}`]?e.renderSlot(p.$slots,`header-${u.value}`,e.normalizeProps(e.mergeProps({key:0},u)),void 0,!0):(e.openBlock(),e.createElementBlock("span",pt,e.toDisplayString(u.text),1)),u.sortable?(e.openBlock(),e.createElementBlock("i",{key:u.sortType?u.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:u.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)],2))],14,ut))),128))])],2)):e.createCommentVNode("",!0),e.unref(me).length?(e.openBlock(),e.createElementBlock("tbody",{key:1,class:e.normalizeClass(["vue3-easy-data-table__body",{"row-alternation":p.alternating}])},[e.renderSlot(p.$slots,"body-prepend",e.normalizeProps(e.guardReactiveProps({items:e.unref(X),pagination:{isFirstPage:e.unref(G),isLastPage:e.unref(U),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(J),nextPage:e.unref(K),prevPage:e.unref(Q)},headers:e.unref(D)})),void 0,!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(X),(u,I)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:I},[e.createElementVNode("tr",{class:e.normalizeClass([{"even-row":(I+1)%2===0},typeof p.bodyRowClassName=="string"?p.bodyRowClassName:p.bodyRowClassName(u,I)]),onClick:$=>e.unref(Ht)(u)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(me),($,Ce)=>(e.openBlock(),e.createElementBlock("td",{key:Ce,style:e.normalizeStyle(Pe($,"td")),class:e.normalizeClass([{shadow:$===e.unref(ke),"can-expand":$==="expand"},typeof p.bodyItemClassName=="string"?p.bodyItemClassName:p.bodyItemClassName($,Ce),`direction-${e.unref(c)}`]),onClick:Ne=>$==="expand"?e.unref(zt)(I+e.unref(te),u,Ne):null},[e.unref(q)[`item-${$}`]?e.renderSlot(p.$slots,`item-${$}`,e.normalizeProps(e.mergeProps({key:0},u)),void 0,!0):$==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:e.unref(be).includes(e.unref(te)+I)}])},null,2)):$==="checkbox"?(e.openBlock(),e.createBlock(Re,{key:2,checked:u[$],onChange:Ne=>e.unref(Tt)(u)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(e.unref(st)($,u)),1)],64))],14,mt))),128))],10,ft),e.unref(de)&&e.unref(be).includes(I+e.unref(te))?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(I+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(D).length,class:"expand"},[u.expandLoading?(e.openBlock(),e.createBlock(Je,{key:0,class:"expand-loading"})):e.createCommentVNode("",!0),e.renderSlot(p.$slots,"expand",e.normalizeProps(e.guardReactiveProps(u)),void 0,!0)],8,gt)],2)):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(p.$slots,"body-append",e.normalizeProps(e.guardReactiveProps({items:e.unref(X),pagination:{isFirstPage:e.unref(G),isLastPage:e.unref(U),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(J),nextPage:e.unref(K),prevPage:e.unref(Q)},headers:e.unref(D)})),void 0,!0)],2)):e.createCommentVNode("",!0)]),e.unref(x)?(e.openBlock(),e.createElementBlock("div",ht,[_t,e.createElementVNode("div",yt,[e.unref(wt)?e.renderSlot(p.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(We,{key:1}))])])):e.createCommentVNode("",!0),!e.unref(X).length&&!e.unref(x)?(e.openBlock(),e.createElementBlock("div",bt,e.toDisplayString(p.emptyMessage),1)):e.createCommentVNode("",!0)],2),p.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",xt,[p.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",kt,[e.createTextVNode(e.toDisplayString(p.rowsPerPageMessage)+" ",1),e.createVNode(Ae,{modelValue:e.unref(O),"onUpdate:modelValue":L[0]||(L[0]=u=>e.isRef(O)?O.value=u:null),"rows-items":e.unref(ge)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",Pt,e.toDisplayString(`${e.unref(he)}\u2013${e.unref(_e)}`)+" of "+e.toDisplayString(e.unref(ee)),1),e.unref(Bt)?e.renderSlot(p.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(G),isLastPage:e.unref(U),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(J),nextPage:e.unref(K),prevPage:e.unref(Q)})),void 0,!0):(e.openBlock(),e.createBlock(Ye,{key:2,"is-first-page":e.unref(G),"is-last-page":e.unref(U),onClickNextPage:e.unref(K),onClickPrevPage:e.unref(Q)},e.createSlots({_:2},[p.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Ke,{"current-pagination-number":e.unref(T),"max-pagination-number":e.unref(J),onUpdatePage:e.unref(le)},null,8,["current-pagination-number","max-pagination-number","onUpdatePage"])])}:void 0]),1032,["is-first-page","is-last-page","onClickNextPage","onClickPrevPage"]))]))],2))}});var ce=k(Ct,[["__scopeId","data-v-2351cc61"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",ce),ce}); | ||
(function(e,N){typeof exports=="object"&&typeof module!="undefined"?module.exports=N(require("vue")):typeof define=="function"&&define.amd?define(["vue"],N):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=N(e.Vue))})(this,function(e){"use strict";var Mt=Object.defineProperty,jt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var we=Object.getOwnPropertySymbols;var qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var Be=(e,N,C)=>N in e?Mt(e,N,{enumerable:!0,configurable:!0,writable:!0,value:C}):e[N]=C,F=(e,N)=>{for(var C in N||(N={}))qt.call(N,C)&&Be(e,C,N[C]);if(we)for(var C of we(N))Jt.call(N,C)&&Be(e,C,N[C]);return e},X=(e,N)=>jt(e,Wt(N));var N="",C=(n,l)=>{const t=n.__vccOpts||n;for(const[r,c]of l)t[r]=c;return t};const Ie=n=>(e.pushScopeId("data-v-e0a0b7f0"),n=n(),e.popScopeId(),n),$e=["onClick"],Ee=["checked"],Ve=Ie(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Fe=C(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(n,{emit:l}){const t=n;e.useCssVars(d=>({"51ab8a49":e.unref(s)}));const r=e.computed(()=>t.status==="allSelected"),c=()=>{l("change",!r.value)},s=e.inject("themeColor");return(d,o)=>(e.openBlock(),e.createElementBlock("div",{class:"easy-checkbox",onClick:e.withModifiers(c,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(r),class:e.normalizeClass(n.status)},null,10,Ee),Ve],8,$e))}}),[["__scopeId","data-v-e0a0b7f0"]]),Gt="";const Le=n=>(e.pushScopeId("data-v-7e69a276"),n=n(),e.popScopeId(),n),ve=["checked"],Re=Le(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Te=C(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(n,{emit:l}){e.useCssVars(r=>({fdaf7e9e:e.unref(t)}));const t=e.inject("themeColor");return(r,c)=>(e.openBlock(),e.createElementBlock("div",{class:"easy-checkbox",onClick:c[0]||(c[0]=e.withModifiers(s=>l("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:n.checked},null,8,ve),Re]))}}),[["__scopeId","data-v-7e69a276"]]),Qt="";const Oe=n=>(e.pushScopeId("data-v-09dad912"),n=n(),e.popScopeId(),n),ze={class:"easy-data-table__rows-selector"},De={class:"rows-input"},He=Oe(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Ae=["onClick"];var Me=C(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(n,{emit:l}){const t=n;e.useCssVars(m=>({"7fe9410c":e.unref(h)}));const r=e.ref(!1),c=e.ref(!1),s=e.inject("dataTable");e.watch(r,m=>{if(m&&s){const b=window.innerHeight,g=s.value.getBoundingClientRect().height,$=s.value.getBoundingClientRect().top;b-(g+$)<=100?c.value=!0:c.value=!1}});const d=e.computed({get:()=>t.modelValue,set:m=>{l("update:modelValue",m)}}),o=m=>{d.value=m,r.value=!1},a=(m,b)=>{let g=m.parentNode;for(;g!=null;){if(g.classList&&g.classList.contains(b))return!0;g=g.parentNode}return!1},i=m=>{a(m.target,"easy-data-table__rows-selector")||(r.value=!1)};e.onMounted(()=>{document.addEventListener("click",i)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",i)});const h=e.inject("themeColor");return(m,b)=>(e.openBlock(),e.createElementBlock("div",ze,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:b[0]||(b[0]=g=>r.value=!r.value)},[e.createElementVNode("div",De,e.toDisplayString(e.unref(d)),1),He]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:r.value,inside:c.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.rowsItems,g=>(e.openBlock(),e.createElementBlock("li",{key:g,class:e.normalizeClass({selected:g===e.unref(d)}),onClick:$=>o(g)},e.toDisplayString(g),11,Ae))),128))],2)]))}}),[["__scopeId","data-v-09dad912"]]),Yt="";const Y=n=>(e.pushScopeId("data-v-1fa3a520"),n=n(),e.popScopeId(),n),je={class:"lds-ring"},We=[Y(()=>e.createElementVNode("div",null,null,-1)),Y(()=>e.createElementVNode("div",null,null,-1)),Y(()=>e.createElementVNode("div",null,null,-1)),Y(()=>e.createElementVNode("div",null,null,-1))];var qe=C(e.defineComponent({setup(n){e.useCssVars(t=>({"26774109":e.unref(l)}));const l=e.inject("themeColor");return(t,r)=>(e.openBlock(),e.createElementBlock("div",je,We))}}),[["__scopeId","data-v-1fa3a520"]]),on="";const Je={class:"loader-line"};var Ue=C(e.defineComponent({setup(n){e.useCssVars(t=>({"0d327f57":e.unref(l)}));const l=e.inject("themeColor");return(t,r)=>(e.openBlock(),e.createElementBlock("div",Je))}}),[["__scopeId","data-v-7d281cac"]]),ln="";const Ge={class:"buttons-pagination"},Ke=["onClick"];var Qe=C(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(n,{emit:l}){const t=n;e.useCssVars(o=>({"40dd4f07":e.unref(d)}));const r=7,c=o=>{o.type==="button"&&!o.active&&l("updatePage",o.page)},s=e.computed(()=>{const o=[];if(t.maxPaginationNumber<=r)for(let a=1;a<=t.maxPaginationNumber;a+=1)o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if([1,2,t.maxPaginationNumber,t.maxPaginationNumber-1].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)if(a<=3)o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if(a===4)o.push({type:"omission"});else{const i=t.maxPaginationNumber-(r-a);o.push({type:"button",page:i,active:i===t.currentPaginationNumber,activePrev:i+1===t.currentPaginationNumber})}else if([3,4].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)a<=5?o.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber}):a===6?o.push({type:"omission"}):o.push({type:"button",page:t.maxPaginationNumber,active:t.maxPaginationNumber===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if([t.maxPaginationNumber-2,t.maxPaginationNumber-3].includes(t.currentPaginationNumber))for(let a=1;a<=r;a+=1)if(a===1)o.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2)o.push({type:"omission"});else{const i=t.maxPaginationNumber-(r-a);o.push({type:"button",page:i,active:i===t.currentPaginationNumber,activePrev:i+1===t.currentPaginationNumber})}else for(let a=1;a<=r;a+=1)if(a===1)o.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2||a===6)o.push({type:"omission"});else if(a===7)o.push({type:"button",page:t.maxPaginationNumber,active:t.maxPaginationNumber===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else{const i=4-a,h=t.currentPaginationNumber-i;o.push({type:"button",page:h,active:h===t.currentPaginationNumber,activePrev:h+1===t.currentPaginationNumber})}return o}),d=e.inject("themeColor");return(o,a)=>(e.openBlock(),e.createElementBlock("div",Ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(i,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:i.type==="button",active:i.type==="button"&&i.active,"active-prev":i.type==="button"&&i.activePrev,omission:i.type==="omission"}]),onClick:m=>c(i)},e.toDisplayString(i.type==="button"?i.page:"..."),11,Ke))),128))]))}}),[["__scopeId","data-v-4c681fa2"]]),cn="";const ie=n=>(e.pushScopeId("data-v-c9da5286"),n=n(),e.popScopeId(),n),Xe=[ie(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Ye=[ie(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Ze=C(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(n,{emit:l}){const t=e.useSlots();return(r,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":n.isFirstPage}]),onClick:c[0]||(c[0]=s=>l("clickPrevPage"))},Xe,2),e.unref(t).buttonsPagination?e.renderSlot(r.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":n.isLastPage}]),onClick:c[1]||(c[1]=s=>l("clickNextPage"))},Ye,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);function et(n,l,t){return{clickRow:c=>{const s=F({},c);if(n.value){const{checkbox:d}=c;delete s.checkbox,s.isSelected=d}if(l.value){const{index:d}=c;delete s.index,s.indexInCurrentPage=d}t("clickRow",s)}}}function tt(n,l,t){const r=e.ref([]);return{expandingItemIndexList:r,updateExpandingItemIndexList:(d,o,a)=>{a.stopPropagation();const i=r.value.indexOf(d);if(i!==-1)r.value.splice(i,1);else{const h=n.value.findIndex(m=>JSON.stringify(m)===JSON.stringify(o));t("expandRow",l.value+h),r.value.push(l.value+h)}},clearExpandingItemIndexList:()=>{r.value=[]}}}function nt(n){const l=e.computed(()=>n.value.filter(c=>c.fixed)),t=e.computed(()=>l.value.length?l.value[l.value.length-1].value:""),r=e.computed(()=>{if(!l.value.length)return[];const c=l.value.map(s=>{var d;return(d=s.width)!=null?d:100});return l.value.map((s,d)=>{var o,a;return{value:s.value,fixed:(o=s.fixed)!=null?o:!0,width:(a=s.width)!=null?a:100,distance:d===0?0:c.reduce((i,h,m)=>{let b=i;return m<d&&(b+=h),b})}})});return{fixedHeaders:l,lastFixedColumn:t,fixedColumnsInfos:r}}function at(n,l,t,r,c,s,d,o,a,i,h,m,b,g,$,_,f){const y=e.computed(()=>s.value.findIndex(P=>P.fixed)!==-1),x=e.computed(()=>y.value?s.value.filter(P=>P.fixed):[]),v=e.computed(()=>s.value.filter(P=>!P.fixed)),E=(P,V)=>P!==""?{sortBy:P,sortDesc:V==="desc"}:null,k=e.ref(E(g.value,$.value));e.watch([g,$],()=>{k.value=E(g.value,$.value)});const S=e.computed(()=>{var ee;const V=[...x.value,...v.value].map(R=>{const M=R;return R.sortable&&(M.sortType="none"),m.value&&R.value===m.value.sortBy&&m.value.sortType&&(M.sortType=m.value.sortType),!i.value&&k.value&&R.value===k.value.sortBy&&(M.sortType=k.value.sortDesc?"desc":"asc"),M});let w=[];d.value?w=[r.value||y.value?{text:"",value:"expand",fixed:!0,width:l.value}:{text:"",value:"expand"},...V]:w=V;let A=[];b.value?A=[c.value||y.value?{text:"#",value:"index",fixed:!0,width:o.value}:{text:"#",value:"index"},...w]:A=w;let D=[];return a.value?D=[t.value||y.value?{text:"checkbox",value:"checkbox",fixed:!0,width:(ee=n.value)!=null?ee:36}:{text:"checkbox",value:"checkbox"},...A]:D=A,D}),Z=e.computed(()=>S.value.map(P=>P.value));return{clientSortOptions:k,headerColumns:Z,headersForRender:S,updateSortField:(P,V)=>{let w=null;V==="none"?w="asc":V==="asc"?w="desc":w=h.value?"asc":null,i.value?_(P,w):w===null?k.value=null:k.value={sortBy:P,sortDesc:w==="desc"},f("updateSort",{sortType:w,sortBy:P})}}}function ot(n,l,t,r,c,s,d,o,a){const i=e.computed(()=>(n.value-1)*c.value+1),h=e.computed(()=>t.value?Math.min(a.value,n.value*c.value):Math.min(o.value.length,n.value*c.value)),m=e.computed(()=>t.value?r.value:o.value.slice(i.value-1,h.value)),b=e.computed(()=>d.value?m.value.map((_,f)=>F({index:i.value+f},_)):m.value),g=e.computed(()=>s.value.length===0||s.value.every(f=>o.value.findIndex(y=>JSON.stringify(f)===JSON.stringify(y))===-1)?"noneSelected":s.value.length===o.value.length&&s.value.every(y=>o.value.findIndex(x=>JSON.stringify(y)===JSON.stringify(x))!==-1)?"allSelected":"partSelected"),$=e.computed(()=>l.value?g.value==="allSelected"?b.value.map(_=>F({checkbox:!0},_)):g.value==="noneSelected"?b.value.map(_=>F({checkbox:!1},_)):b.value.map(_=>{const f=s.value.findIndex(y=>{const x=F({},_);return delete x.index,JSON.stringify(y)===JSON.stringify(x)})!==-1;return F({checkbox:f},_)}):b.value);return{currentPageFirstIndex:i,currentPageLastIndex:h,multipleSelectStatus:g,pageItems:$}}function rt(n,l,t,r,c,s,d){const o=e.ref(s.value?s.value.page:n.value),a=e.computed(()=>Math.ceil(r.value/c.value)),i=e.computed(()=>a.value===0||o.value===a.value),h=e.computed(()=>o.value===1);return{currentPaginationNumber:o,maxPaginationNumber:a,isLastPage:i,isFirstPage:h,nextPage:()=>{if(r.value!==0&&!i.value&&!t.value)if(l.value){const _=o.value+1;d(_)}else o.value+=1},prevPage:()=>{if(r.value!==0&&!h.value&&!t.value)if(l.value){const _=o.value-1;d(_)}else o.value-=1},updatePage:_=>{t.value||(l.value?d(_):o.value=_)},updateCurrentPaginationNumber:_=>{o.value=_}}}function lt(n,l,t,r){const c=e.computed(()=>!n.value&&l.value.findIndex(o=>o===r.value)===-1?[r.value,...l.value]:l.value),s=e.ref(t.value?t.value.rowsPerPage:r.value);return{rowsItemsComputed:c,rowsPerPageRef:s,updateRowsPerPage:o=>{s.value=o}}}function st(n,l){const t=e.computed({get:()=>{if(n.value){const{page:d,rowsPerPage:o,sortBy:a,sortType:i}=n.value;return{page:d,rowsPerPage:o,sortBy:a!=null?a:null,sortType:i!=null?i:null}}return null},set:d=>{l("update:serverOptions",d)}});return{serverOptionsComputed:t,updateServerOptionsPage:d=>{t.value&&(t.value=X(F({},t.value),{page:d}))},updateServerOptionsSort:(d,o)=>{t.value&&(t.value=X(F({},t.value),{sortBy:o!==null?d:null,sortType:o}))},updateServerOptionsRowsPerPage:d=>{t.value&&(t.value=X(F({},t.value),{page:1,rowsPerPage:d}))}}}function z(n,l){if(n.includes(".")){let t="";const r=n.split("."),{length:c}=r;let s=0;for(;s<c&&(t=s===0?l[r[s]]:t[r[s]],s+=1,t!==void 0););return t}return l[n]}function it(n,l){const t=z(n,l);return Array.isArray(t)?t.join(","):t}function ct(n,l,t,r,c,s,d,o,a){const i=e.computed(()=>{if(!t.value&&d.value!==""){const f=new RegExp(d.value,"i");return r.value.filter(y=>f.test(s.value!==""?y[s.value]:Object.values(y).join(" ")))}return r.value}),h=e.computed(()=>{let f=[...i.value];return l.value?(l.value.forEach(y=>{f=f.filter(x=>{const{field:v,comparison:E,criteria:k}=y;if(typeof E=="function")return E(z(v,x),k);const S=z(v,x);switch(E){case"=":return S===k;case"!=":return S!==k;case">":return S>k;case"<":return S<k;case"<=":return S<=k;case">=":return S>=k;case"between":return S>=Math.min(...k)&&S<=Math.max(...k);default:return S===k}})}),f):i.value}),m=e.computed(()=>{if(t.value)return r.value;if(n.value===null)return h.value;const{sortBy:f,sortDesc:y}=n.value;return[...h.value].sort((v,E)=>z(f,v)<z(f,E)?y?1:-1:z(f,v)>z(f,E)?y?-1:1:0)}),b=e.computed(()=>t.value?o.value:m.value.length),g=e.computed({get:()=>{var f;return(f=c.value)!=null?f:[]},set:f=>{a("update:itemsSelected",f)}});return{totalItems:m,selectItemsComputed:g,totalItemsLength:b,toggleSelectAll:f=>{g.value=f?m.value:[]},toggleSelectItem:f=>{const y=f.checkbox;if(delete f.checkbox,delete f.index,y)g.value=g.value.filter(x=>JSON.stringify(x)!==JSON.stringify(f));else{const x=g.value;x.unshift(f),g.value=x}}}}var dt={alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},checkboxColumnWidth:{type:Number,default:null},currentPage:{type:Number,default:1},emptyMessage:{type:String,default:"No Available Data"},expandColumnWidth:{type:Number,default:36},filterOptions:{type:Array,default:null},fixedExpand:{type:Boolean,default:!1},fixedHeader:{type:Boolean,default:!0},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},headerTextDirection:{type:String,default:"left"},bodyTextDirection:{type:String,default:"left"},hideFooter:{type:Boolean,default:!1},hideRowsPerPage:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},itemsSelected:{type:Array,default:null},loading:{type:Boolean,deault:!1},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowsPerPageMessage:{type:String,default:"rows per page:"},searchField:{type:String,default:""},searchValue:{type:String,default:""},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},showIndex:{type:Boolean,default:!1},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},tableMinHeight:{type:Number,default:180},tableHeight:{type:Number,default:null},themeColor:{type:String,default:"#42b883"},tableClassName:{type:String,default:""},headerClassName:{type:String,default:""},headerItemClassName:{type:[Function,String],default:""},bodyRowClassName:{type:[Function,String],default:""},bodyItemClassName:{type:[Function,String],default:""},noHover:{type:Boolean,default:!1},borderCell:{type:Boolean,default:!1},mustSort:{type:Boolean,default:!1}},fn="",mn="";const ut=n=>(e.pushScopeId("data-v-2351cc61"),n=n(),e.popScopeId(),n),pt=["onClick"],ft={key:1,class:"header-text"},mt=["onClick"],gt=["onClick"],ht=["colspan"],_t={key:0,class:"vue3-easy-data-table__loading"},yt=ut(()=>e.createElementVNode("div",{class:"vue3-easy-data-table__loading-mask"},null,-1)),bt={class:"loading-entity"},xt={key:1,class:"vue3-easy-data-table__message"},kt={key:0,class:"vue3-easy-data-table__footer"},Pt={key:0,class:"pagination__rows-per-page"},Ct={class:"pagination__items-index"},Nt=e.defineComponent({props:X(F({},dt),{items:{type:Array,required:!0},headers:{type:Array,required:!0}}),emits:["clickRow","expandRow","updateSort","update:itemsSelected","update:serverOptions"],setup(n,{expose:l,emit:t}){const r=n;e.useCssVars(p=>({"11cca481":e.unref(St),"610141e2":e.unref(M)}));const{bodyTextDirection:c,checkboxColumnWidth:s,currentPage:d,expandColumnWidth:o,filterOptions:a,fixedCheckbox:i,fixedExpand:h,fixedHeader:m,fixedIndex:b,headers:g,headerTextDirection:$,indexColumnWidth:_,items:f,itemsSelected:y,loading:x,mustSort:v,rowsItems:E,rowsPerPage:k,searchField:S,searchValue:Z,serverItemsLength:de,serverOptions:P,showIndex:V,sortBy:w,sortType:A,tableHeight:D,tableMinHeight:ee,themeColor:R}=e.toRefs(r),M=e.computed(()=>D.value?`${D.value}px`:null),St=e.computed(()=>`${ee.value}px`);e.provide("themeColor",R.value);const W=e.useSlots(),wt=e.computed(()=>!!W.pagination),Bt=e.computed(()=>!!W.loading),ue=e.computed(()=>!!W.expand),pe=e.ref(),ae=e.ref();e.provide("dataTable",pe);const fe=e.ref(!1);e.onMounted(()=>{ae.value.addEventListener("scroll",()=>{fe.value=ae.value.scrollLeft>0})});const oe=e.computed(()=>y.value!==null),j=e.computed(()=>P.value!==null),{serverOptionsComputed:re,updateServerOptionsPage:It,updateServerOptionsSort:$t,updateServerOptionsRowsPerPage:Et}=st(P,t),{clientSortOptions:me,headerColumns:ge,headersForRender:H,updateSortField:Vt}=at(s,o,i,h,b,g,ue,_,oe,j,v,re,V,w,A,$t,t),{rowsItemsComputed:he,rowsPerPageRef:O,updateRowsPerPage:Ft}=lt(j,E,P,k),{totalItems:Lt,selectItemsComputed:vt,totalItemsLength:te,toggleSelectAll:Rt,toggleSelectItem:Tt}=ct(me,a,j,f,y,S,Z,de,t),{currentPaginationNumber:T,maxPaginationNumber:q,isLastPage:J,isFirstPage:U,nextPage:G,prevPage:K,updatePage:le,updateCurrentPaginationNumber:Ot}=rt(d,j,x,te,O,P,It),{currentPageFirstIndex:_e,currentPageLastIndex:ye,multipleSelectStatus:be,pageItems:Q}=ot(T,oe,j,f,O,vt,V,Lt,te),ne=e.computed(()=>T.value===0?0:(T.value-1)*O.value),{expandingItemIndexList:xe,updateExpandingItemIndexList:zt,clearExpandingItemIndexList:ke}=tt(Q,ne,t),{fixedHeaders:se,lastFixedColumn:Pe,fixedColumnsInfos:Dt}=nt(H),{clickRow:Ht}=et(oe,V,t),At=p=>{var u;const L=(u=p.width)!=null?u:se.value.length?100:null;if(L)return`width: ${L}px; min-width: ${L}px;`},Ce=(p,L="th")=>{if(!se.value.length)return;const u=Dt.value.find(B=>B.value===p);if(u)return`left: ${u.distance}px;z-index: ${L==="th"?3:1};position: sticky;`};return e.watch(x,(p,L)=>{re.value&&p===!1&&L===!0&&(Ot(re.value.page),ke())}),e.watch(O,p=>{j.value?Et(p):le(1)}),e.watch([T,me,S,Z,a],()=>{ke()},{deep:!0}),l({currentPageFirstIndex:_e,currentPageLastIndex:ye,clientItemsLength:te,maxPaginationNumber:q,currentPaginationNumber:T,isLastPage:J,isFirstPage:U,nextPage:G,prevPage:K,updatePage:le,rowsPerPageOptions:he,rowsPerPageActiveOption:O,updateRowsPerPageActiveOption:Ft}),(p,L)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:pe,class:e.normalizeClass(["vue3-easy-data-table",[p.tableClassName]])},[e.createElementVNode("div",{ref_key:"tableBody",ref:ae,class:e.normalizeClass(["vue3-easy-data-table__main",{"fixed-header":e.unref(m),"fixed-height":e.unref(D),"show-shadow":fe.value,"table-fixed":e.unref(se).length,hoverable:!p.noHover,"border-cell":p.borderCell}])},[e.createElementVNode("table",null,[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(H),(u,B)=>(e.openBlock(),e.createElementBlock("col",{key:B,style:e.normalizeStyle(At(u))},null,4))),128))]),e.unref(H).length&&!p.hideHeader?(e.openBlock(),e.createElementBlock("thead",{key:0,class:e.normalizeClass(["vue3-easy-data-table__header",[p.headerClassName]])},[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(H),(u,B)=>(e.openBlock(),e.createElementBlock("th",{key:B,class:e.normalizeClass([{sortable:u.sortable,none:u.sortable&&u.sortType==="none",desc:u.sortable&&u.sortType==="desc",asc:u.sortable&&u.sortType==="asc",shadow:u.value===e.unref(Pe)},typeof p.headerItemClassName=="string"?p.headerItemClassName:p.headerItemClassName(u,B)]),style:e.normalizeStyle(Ce(u.value)),onClick:e.withModifiers(I=>u.sortable&&u.sortType?e.unref(Vt)(u.value,u.sortType):null,["stop"])},[u.text==="checkbox"?(e.openBlock(),e.createBlock(Fe,{key:e.unref(be),status:e.unref(be),onChange:e.unref(Rt)},null,8,["status","onChange"])):(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(["header",`direction-${e.unref($)}`])},[e.unref(W)[`header-${u.value}`]?e.renderSlot(p.$slots,`header-${u.value}`,e.normalizeProps(e.mergeProps({key:0},u)),void 0,!0):(e.openBlock(),e.createElementBlock("span",ft,e.toDisplayString(u.text),1)),u.sortable?(e.openBlock(),e.createElementBlock("i",{key:u.sortType?u.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:u.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)],2))],14,pt))),128))])],2)):e.createCommentVNode("",!0),e.unref(ge).length?(e.openBlock(),e.createElementBlock("tbody",{key:1,class:e.normalizeClass(["vue3-easy-data-table__body",{"row-alternation":p.alternating}])},[e.renderSlot(p.$slots,"body-prepend",e.normalizeProps(e.guardReactiveProps({items:e.unref(Q),pagination:{isFirstPage:e.unref(U),isLastPage:e.unref(J),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(q),nextPage:e.unref(G),prevPage:e.unref(K)},headers:e.unref(H)})),void 0,!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Q),(u,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:B},[e.createElementVNode("tr",{class:e.normalizeClass([{"even-row":(B+1)%2===0},typeof p.bodyRowClassName=="string"?p.bodyRowClassName:p.bodyRowClassName(u,B)]),onClick:I=>e.unref(Ht)(u)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ge),(I,Ne)=>(e.openBlock(),e.createElementBlock("td",{key:Ne,style:e.normalizeStyle(Ce(I,"td")),class:e.normalizeClass([{shadow:I===e.unref(Pe),"can-expand":I==="expand"},typeof p.bodyItemClassName=="string"?p.bodyItemClassName:p.bodyItemClassName(I,Ne),`direction-${e.unref(c)}`]),onClick:Se=>I==="expand"?e.unref(zt)(B+e.unref(ne),u,Se):null},[e.unref(W)[`item-${I}`]?e.renderSlot(p.$slots,`item-${I}`,e.normalizeProps(e.mergeProps({key:0},u)),void 0,!0):I==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:e.unref(xe).includes(e.unref(ne)+B)}])},null,2)):I==="checkbox"?(e.openBlock(),e.createBlock(Te,{key:2,checked:u[I],onChange:Se=>e.unref(Tt)(u)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(e.unref(it)(I,u)),1)],64))],14,gt))),128))],10,mt),e.unref(ue)&&e.unref(xe).includes(B+e.unref(ne))?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(B+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(H).length,class:"expand"},[u.expandLoading?(e.openBlock(),e.createBlock(Ue,{key:0,class:"expand-loading"})):e.createCommentVNode("",!0),e.renderSlot(p.$slots,"expand",e.normalizeProps(e.guardReactiveProps(u)),void 0,!0)],8,ht)],2)):e.createCommentVNode("",!0)],64))),128)),e.renderSlot(p.$slots,"body-append",e.normalizeProps(e.guardReactiveProps({items:e.unref(Q),pagination:{isFirstPage:e.unref(U),isLastPage:e.unref(J),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(q),nextPage:e.unref(G),prevPage:e.unref(K)},headers:e.unref(H)})),void 0,!0)],2)):e.createCommentVNode("",!0)]),e.unref(x)?(e.openBlock(),e.createElementBlock("div",_t,[yt,e.createElementVNode("div",bt,[e.unref(Bt)?e.renderSlot(p.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(qe,{key:1}))])])):e.createCommentVNode("",!0),!e.unref(Q).length&&!e.unref(x)?(e.openBlock(),e.createElementBlock("div",xt,e.toDisplayString(p.emptyMessage),1)):e.createCommentVNode("",!0)],2),p.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",kt,[p.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Pt,[e.createTextVNode(e.toDisplayString(p.rowsPerPageMessage)+" ",1),e.createVNode(Me,{modelValue:e.unref(O),"onUpdate:modelValue":L[0]||(L[0]=u=>e.isRef(O)?O.value=u:null),"rows-items":e.unref(he)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",Ct,e.toDisplayString(`${e.unref(_e)}\u2013${e.unref(ye)}`)+" of "+e.toDisplayString(e.unref(te)),1),e.unref(wt)?e.renderSlot(p.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(U),isLastPage:e.unref(J),currentPaginationNumber:e.unref(T),maxPaginationNumber:e.unref(q),nextPage:e.unref(G),prevPage:e.unref(K)})),void 0,!0):(e.openBlock(),e.createBlock(Ze,{key:2,"is-first-page":e.unref(U),"is-last-page":e.unref(J),onClickNextPage:e.unref(G),onClickPrevPage:e.unref(K)},e.createSlots({_:2},[p.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Qe,{"current-pagination-number":e.unref(T),"max-pagination-number":e.unref(q),onUpdatePage:e.unref(le)},null,8,["current-pagination-number","max-pagination-number","onUpdatePage"])])}:void 0]),1032,["is-first-page","is-last-page","onClickNextPage","onClickPrevPage"]))]))],2))}});var ce=C(Nt,[["__scopeId","data-v-2351cc61"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",ce),ce}); |
@@ -6,3 +6,3 @@ { | ||
"private": false, | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"types": "./types/main.d.ts", | ||
@@ -9,0 +9,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106422
1673