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.7 to 1.4.8

31

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

@@ -426,16 +426,17 @@ var __defProp = Object.defineProperty;

function useExpandableRow(items, emits) {
const expandingItemIndexList = ref([]);
const updateExpandingItemIndexList = (expandingItemIndex, expandingItem, event) => {
const expandingItems = ref([]);
const getExpandingItemIndex = (expandingItem) => expandingItems.value.findIndex((item) => JSON.stringify(item) === JSON.stringify(expandingItem));
const updateExpandingItems = (expandingItem, event) => {
event.stopPropagation();
const index = expandingItemIndexList.value.indexOf(expandingItemIndex);
const index = getExpandingItemIndex(expandingItem);
if (index !== -1) {
expandingItemIndexList.value.splice(index, 1);
expandingItems.value.splice(index, 1);
} else {
emits("expandRow", items.value.findIndex((item) => item === expandingItem));
expandingItemIndexList.value.push(expandingItemIndex);
expandingItems.value.push(expandingItem);
}
};
return {
expandingItemIndexList,
updateExpandingItemIndexList
updateExpandingItems,
getExpandingItemIndex
};

@@ -1016,3 +1017,3 @@ }

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

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

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

@@ -1155,4 +1156,4 @@ const {

const {
expandingItemIndexList,
updateExpandingItemIndexList
updateExpandingItems,
getExpandingItemIndex
} = useExpandableRow(items, emits);

@@ -1294,7 +1295,7 @@ const {

}, typeof _ctx.bodyItemClassName === "string" ? _ctx.bodyItemClassName : _ctx.bodyItemClassName(column, i)]),
onClick: ($event) => column === "expand" ? unref(updateExpandingItemIndexList)(index, item, $event) : null
onClick: ($event) => column === "expand" ? unref(updateExpandingItems)(item, $event) : null
}, [
unref(slots)[`item-${column}`] ? renderSlot(_ctx.$slots, `item-${column}`, normalizeProps(mergeProps({ key: 0 }, item)), void 0, true) : column === "expand" ? (openBlock(), createElementBlock("i", {
key: 1,
class: normalizeClass(["expand-icon", { "expanding": unref(expandingItemIndexList).includes(index) }])
class: normalizeClass(["expand-icon", { "expanding": unref(getExpandingItemIndex)(item) !== -1 }])
}, null, 2)) : column === "checkbox" ? (openBlock(), createBlock(SingleSelectCheckBox, {

@@ -1310,3 +1311,3 @@ key: 2,

], 10, _hoisted_4),
unref(ifHasExpandSlot) && unref(expandingItemIndexList).includes(index) ? (openBlock(), createElementBlock("tr", {
unref(ifHasExpandSlot) && unref(getExpandingItemIndex)(item) !== -1 ? (openBlock(), createElementBlock("tr", {
key: 0,

@@ -1378,3 +1379,3 @@ class: normalizeClass({ "even-row": (index + 1) % 2 === 0 })

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

@@ -1381,0 +1382,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 Tt=Object.defineProperty,Rt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var At=Object.prototype.hasOwnProperty,Ht=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,v=(e,C)=>{for(var b in C||(C={}))At.call(C,b)&&be(e,b,C[b]);if(ke)for(var b of ke(C))Ht.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(l=>({"51ab8a49":e.unref(s)}));const i=e.computed(()=>t.status==="allSelected"),c=()=>{o("change",!i.value)},s=e.inject("themeColor");return(l,r)=>(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(s=>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)),Le=["onClick"];var Te=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),s=e.inject("dataTable");e.watch(i,g=>{if(g&&s){const y=window.innerHeight,f=s.value.getBoundingClientRect().height,x=s.value.getBoundingClientRect().top;y-(f+x)<=100?c.value=!0:c.value=!1}});const l=e.computed({get:()=>t.modelValue,set:g=>{o("update:modelValue",g)}}),r=g=>{l.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},d=g=>{a(g.target,"easy-data-table__rows-selector")||(i.value=!1)};e.onMounted(()=>{document.addEventListener("click",d)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",d)});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(l)),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(l)}),onClick:x=>r(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"},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 Ae=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 He={class:"loader-line"};var Oe=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",He))}}),[["__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(r=>({"40dd4f07":e.unref(l)}));const i=7,c=r=>{r.type==="button"&&!r.active&&o("updatePage",r.page)},s=e.computed(()=>{const r=[];if(t.maxPaginationNumber<=i)for(let a=1;a<=t.maxPaginationNumber;a+=1)r.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)r.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if(a===4)r.push({type:"omission"});else{const d=t.maxPaginationNumber-(i-a);r.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<=i;a+=1)a<=5?r.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber}):a===6?r.push({type:"omission"}):r.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)r.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2)r.push({type:"omission"});else{const d=t.maxPaginationNumber-(i-a);r.push({type:"button",page:d,active:d===t.currentPaginationNumber,activePrev:d+1===t.currentPaginationNumber})}else for(let a=1;a<=i;a+=1)if(a===1)r.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2||a===6)r.push({type:"omission"});else if(a===7)r.push({type:"button",page:t.maxPaginationNumber,active:t.maxPaginationNumber===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else{const d=4-a,k=t.currentPaginationNumber-d;r.push({type:"button",page:k,active:k===t.currentPaginationNumber,activePrev:k+1===t.currentPaginationNumber})}return r}),l=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",De,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(d,k)=>(e.openBlock(),e.createElementBlock("div",{key:k,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=>c(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: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]=s=>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]=s=>o("clickNextPage"))},qe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);function Ue(n,o,t){return{clickRow:c=>{const s=v({},c);if(n.value){const{checkbox:l}=c;delete s.checkbox,s.isSelected=l}if(o.value){const{index:l}=c;delete s.index,s.indexInCurrentPage=l}t("clickRow",s)}}}function Ge(n,o){const t=e.ref([]);return{expandingItemIndexList:t,updateExpandingItemIndexList:(c,s,l)=>{l.stopPropagation();const r=t.value.indexOf(c);r!==-1?t.value.splice(r,1):(o("expandRow",n.value.findIndex(a=>a===s)),t.value.push(c))}}}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(s=>{var l;return(l=s.width)!=null?l:100});return o.value.map((s,l)=>{var r,a;return{value:s.value,fixed:(r=s.fixed)!=null?r:!0,width:(a=s.width)!=null?a:100,distance:l===0?0:c.reduce((d,k,g)=>{let y=d;return g<l&&(y+=k),y})}})});return{fixedHeaders:o,lastFixedColumn:t,fixedColumnsInfos:i}}function Qe(n,o,t,i,c,s,l,r,a,d,k,g,y,f,x,N){const p=e.computed(()=>s.value.findIndex(S=>S.fixed)!==-1),P=e.computed(()=>p.value?s.value.filter(S=>S.fixed):[]),h=e.computed(()=>s.value.filter(S=>!S.fixed)),_=e.ref((()=>f.value!==""?{sortBy:f.value,sortDesc:x.value==="desc"}:null)()),V=e.computed(()=>{var q;const T=[...P.value,...h.value].map(E=>{const z=E;return E.sortable&&(z.sortType="none"),g.value&&E.value===g.value.sortBy&&g.value.sortType&&(z.sortType=g.value.sortType),!d.value&&_.value&&E.value===_.value.sortBy&&(z.sortType=_.value.sortDesc?"desc":"asc"),z});let I=[];l.value?I=[i.value||p.value?{text:"",value:"expand",fixed:!0,width:o.value}:{text:"",value:"expand"},...T]:I=T;let L=[];y.value?L=[c.value||p.value?{text:"#",value:"index",fixed:!0,width:r.value}:{text:"#",value:"index"},...I]:L=I;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:_,headerColumns:B,headersForRender:V,updateSortField:(S,T)=>{let I=null;T==="none"?I="asc":T==="asc"?I="desc":I=k.value?"asc":null,d.value?N(S,I):I===null?_.value=null:_.value={sortBy:S,sortDesc:I==="desc"}}}}function Xe(n,o,t,i,c,s,l,r,a){const d=e.computed(()=>(n.value-1)*c.value+1),k=e.computed(()=>t.value?Math.min(a.value,n.value*c.value):Math.min(r.value.length,n.value*c.value)),g=e.computed(()=>t.value?i.value:r.value.slice(d.value-1,k.value)),y=e.computed(()=>l.value?g.value.map((N,p)=>v({index:d.value+p},N)):g.value),f=e.computed(()=>s.value.length===0||s.value.every(p=>r.value.findIndex(P=>JSON.stringify(p)===JSON.stringify(P))===-1)?"noneSelected":s.value.length===r.value.length&&s.value.every(P=>r.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=s.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:d,currentPageLastIndex:k,multipleSelectStatus:f,pageItems:x}}function Ye(n,o,t,i,c,s){const l=e.ref(c.value?c.value.page:1),r=e.computed(()=>Math.ceil(t.value/i.value)),a=e.computed(()=>l.value===r.value),d=e.computed(()=>l.value===1);return{currentPaginationNumber:l,maxPaginationNumber:r,isLastPage:a,isFirstPage:d,nextPage:()=>{if(!a.value&&!o.value)if(n.value){const x=l.value+1;s(x)}else l.value+=1},prevPage:()=>{if(!d.value&&!o.value)if(n.value){const x=l.value-1;s(x)}else l.value-=1},updatePage:x=>{o.value||(n.value?s(x):l.value=x)},updateCurrentPaginationNumber:x=>{l.value=x}}}function Ze(n,o,t,i){const c=e.computed(()=>!n.value&&o.value.findIndex(l=>l===i.value)===-1?[i.value,...o.value]:o.value),s=e.ref(t.value?t.value.rowsPerPage:i.value);return{rowsItemsComputed:c,rowsPerPageRef:s}}function et(n,o){const t=e.computed({get:()=>{if(n.value){const{page:l,rowsPerPage:r,sortBy:a,sortType:d}=n.value;return{page:l,rowsPerPage:r,sortBy:a!=null?a:null,sortType:d!=null?d:null}}return null},set:l=>{o("update:serverOptions",l)}});return{serverOptionsComputed:t,updateServerOptionsPage:l=>{t.value&&(t.value=M(v({},t.value),{page:l}))},updateServerOptionsSort:(l,r)=>{t.value&&(t.value=M(v({},t.value),{sortBy:r!==null?l:null,sortType:r}))},updateServerOptionsRowsPerPage:l=>{t.value&&(t.value=M(v({},t.value),{page:1,rowsPerPage:l}))}}}function H(n,o){if(n.includes(".")){let t="";return n.split(".").forEach((c,s)=>{t=s===0?o[c]:t[c]}),t}return o[n]}function tt(n,o){const t=H(n,o);return Array.isArray(t)?t.join(","):t}function nt(n,o,t,i,c,s,l,r,a){const d=e.computed(()=>{if(!t.value&&l.value!==""){const p=new RegExp(l.value,"i");return i.value.filter(P=>p.test(s.value!==""?P[s.value]:Object.values(P).join(" ")))}return i.value}),k=e.computed(()=>{let p=[...d.value];return o.value?(o.value.forEach(P=>{p=p.filter(h=>{const{field:_,comparison:V,criteria:B}=P;if(typeof V=="function")return V(h[_],B);switch(V){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):d.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((_,V)=>H(p,_)<H(p,V)?P?1:-1:H(p,_)>H(p,V)?P?-1:1:0)}),y=e.computed(()=>t.value?r.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-03d72812"),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=>({"3edcb22c":e.unref(q)}));const{checkboxColumnWidth:c,expandColumnWidth:s,filterOptions:l,fixedCheckbox:r,fixedExpand:a,fixedHeader:d,fixedIndex:k,headers:g,indexColumnWidth:y,items:f,itemsSelected:x,loading:N,mustSort:p,rowsItems:P,rowsPerPage:h,searchField:_,searchValue:V,serverItemsLength:B,serverOptions:O,showIndex:S,sortBy:T,sortType:I,tableHeight:L,themeColor:D}=e.toRefs(i),q=e.computed(()=>L.value?`${L.value}px`:null);e.provide("themeColor",D.value);const E=e.useSlots(),z=e.computed(()=>!!E.pagination),kt=e.computed(()=>!!E.loading),re=e.computed(()=>!!E.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(()=>O.value!==null),{serverOptionsComputed:X,updateServerOptionsPage:bt,updateServerOptionsSort:xt,updateServerOptionsRowsPerPage:Pt}=et(O,t),{clientSortOptions:Ct,headerColumns:ce,headersForRender:j,updateSortField:Nt}=Qe(c,s,r,a,k,g,re,y,Q,R,p,X,S,T,I,xt),{rowsItemsComputed:St,rowsPerPageRef:A}=Ze(R,P,O,h),{totalItems:Bt,selectItemsComputed:wt,totalItemsLength:J,toggleSelectAll:It,toggleSelectItem:Et}=nt(Ct,l,R,f,x,_,V,B,t),{currentPaginationNumber:U,maxPaginationNumber:Y,isLastPage:Z,isFirstPage:ee,nextPage:te,prevPage:ne,updatePage:G,updateCurrentPaginationNumber:$t}=Ye(R,N,J,A,O,bt),{currentPageFirstIndex:de,currentPageLastIndex:ue,multipleSelectStatus:pe,pageItems:fe}=Xe(U,Q,R,f,A,wt,S,Bt,J),{expandingItemIndexList:me,updateExpandingItemIndexList:Vt}=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(w=>w.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(A,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(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,w)=>(e.openBlock(),e.createElementBlock("col",{key:w,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,w)=>(e.openBlock(),e.createElementBlock("th",{key:w,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,w)]),style:e.normalizeStyle(he(u.value)),onClick:e.withModifiers($=>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(E)[`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,w)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:w},[e.createElementVNode("tr",{class:e.normalizeClass([{"even-row":(w+1)%2===0},typeof m.bodyRowClassName=="string"?m.bodyRowClassName:m.bodyRowClassName(u,w)]),onClick:$=>e.unref(Ft)(u)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ce),($,_e)=>(e.openBlock(),e.createElementBlock("td",{key:_e,style:e.normalizeStyle(he($,"td")),class:e.normalizeClass([{shadow:$===e.unref(ge),"can-expand":$==="expand"},typeof m.bodyItemClassName=="string"?m.bodyItemClassName:m.bodyItemClassName($,_e)]),onClick:ye=>$==="expand"?e.unref(Vt)(w,u,ye):null},[e.unref(E)[`item-${$}`]?e.renderSlot(m.$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(me).includes(w)}])},null,2)):$==="checkbox"?(e.openBlock(),e.createBlock(Ee,{key:2,checked:u[$],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)($,u)),1)],64))],14,ct))),128))],10,it),e.unref(re)&&e.unref(me).includes(w)?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(w+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(j).length,class:"expand"},[u.expandLoading?(e.openBlock(),e.createBlock(Oe,{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(Ae,{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(A),"onUpdate:modelValue":F[0]||(F[0]=u=>e.isRef(A)?A.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(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-03d72812"]]);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 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});

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

"private": false,
"version": "1.4.7",
"version": "1.4.8",
"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