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.4.8 to 1.4.9

27

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

@@ -427,14 +427,26 @@ var __defProp = Object.defineProperty;

const expandingItems = ref([]);
const getExpandingItemIndex = (expandingItem) => expandingItems.value.findIndex((item) => JSON.stringify(item) === JSON.stringify(expandingItem));
const getOriginalItem = (expandingItem) => {
const originalItem = __spreadValues({}, expandingItem);
delete originalItem.index;
delete originalItem.checkbox;
delete originalItem.expandLoading;
return originalItem;
};
const getExpandingItemIndex = (expandingItem) => {
const originalItem = getOriginalItem(expandingItem);
return expandingItems.value.findIndex((item) => JSON.stringify(item) === JSON.stringify(originalItem));
};
const updateExpandingItems = (expandingItem, event) => {
event.stopPropagation();
const index = getExpandingItemIndex(expandingItem);
const originalItem = getOriginalItem(expandingItem);
const index = getExpandingItemIndex(originalItem);
if (index !== -1) {
expandingItems.value.splice(index, 1);
} else {
emits("expandRow", items.value.findIndex((item) => item === expandingItem));
expandingItems.value.push(expandingItem);
emits("expandRow", items.value.findIndex((item) => item === originalItem));
expandingItems.value.push(originalItem);
}
};
return {
expandingItems,
updateExpandingItems,

@@ -1017,3 +1029,3 @@ getExpandingItemIndex

var DataTable_vue_vue_type_style_index_1_scoped_true_lang = "";
const _withScopeId = (n) => (pushScopeId("data-v-8eff090c"), n = n(), popScopeId(), n);
const _withScopeId = (n) => (pushScopeId("data-v-a3048ef8"), n = n(), popScopeId(), n);
const _hoisted_1 = ["onClick"];

@@ -1070,3 +1082,3 @@ const _hoisted_2 = {

useCssVars((_ctx) => ({
"56e8c7be": unref(tableHeightPx)
"b473df1c": unref(tableHeightPx)
}));

@@ -1156,2 +1168,3 @@ const {

const {
expandingItems,
updateExpandingItems,

@@ -1377,3 +1390,3 @@ getExpandingItemIndex

});
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8eff090c"]]);
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a3048ef8"]]);
if (typeof window !== "undefined" && window.Vue) {

@@ -1380,0 +1393,0 @@ window.Vue.createApp({}).component("Vue3EasyDataTable", DataTable);

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

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

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

"private": false,
"version": "1.4.8",
"version": "1.4.9",
"types": "./types/main.d.ts",

@@ -9,0 +9,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc