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

vue3-easy-data-table

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.2.3 to 1.2.4

89

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

@@ -400,14 +400,15 @@ var __defProp = Object.defineProperty;

const _hoisted_4 = { class: "header-text" };
const _hoisted_5 = { class: "loading-entity" };
const _hoisted_6 = {
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "loading-entity" };
const _hoisted_7 = {
key: 1,
class: "data-table__message"
};
const _hoisted_7 = {
const _hoisted_8 = {
key: 0,
class: "data-table__footer"
};
const _hoisted_8 = { class: "footer__rows-per-page" };
const _hoisted_9 = /* @__PURE__ */ createTextVNode(" rows per page: ");
const _hoisted_10 = { class: "footer__items-index" };
const _hoisted_9 = { class: "footer__rows-per-page" };
const _hoisted_10 = /* @__PURE__ */ createTextVNode(" rows per page: ");
const _hoisted_11 = { class: "footer__items-index" };
const _sfc_main = /* @__PURE__ */ defineComponent({

@@ -562,3 +563,4 @@ props: {

"update:itemsSelected",
"update:serverOptions"
"update:serverOptions",
"clickRow"
],

@@ -568,22 +570,22 @@ setup(__props, { expose, emit: emits }) {

useCssVars((_ctx) => ({
"c65bd006": unref(tableBorderColor),
"b254d126": unref(minHeightPx),
"22a645e9": unref(tableHeightPx),
"24bf46d8": unref(loadingWrapperSizePx),
"7f6da2f5": unref(rowHeightPx),
"f0657fa8": unref(fontSizePx),
"712c83ae": unref(rowFontColor),
"329582af": unref(rowBackgroundColor),
"60f70f71": unref(rowBorderColor),
"4a75d3b3": unref(headerFontColor),
"2c21faf4": __props.headerBackgroundColor,
"fa9cd624": unref(sortTypeIconSizePx),
"60ff4571": unref(sortTypeAscIconMarginTopPx),
"67ea0079": unref(sortTypeDescIconMarginTopPx),
"1b03925f": unref(rowHoverBackgroundColor),
"eae7d144": unref(rowHoverFontColor),
"5da087e8": unref(evenRowFontColor),
"e5c0192e": unref(evenRowBackgroundColor),
"b09c2bb4": unref(footerBackgroundColor),
"20a4df36": unref(footerFontColor)
"6e3117a2": unref(tableBorderColor),
"42f6b6b0": unref(minHeightPx),
"2ac6f064": unref(tableHeightPx),
"1b05fc8e": unref(loadingWrapperSizePx),
"91c69fa0": unref(rowHeightPx),
"0dba1f91": unref(fontSizePx),
"2f5f1dd3": unref(rowFontColor),
"28332d14": unref(rowBackgroundColor),
"5cebb456": unref(rowBorderColor),
"65d46924": unref(headerFontColor),
"7a4c0b22": __props.headerBackgroundColor,
"784f3f53": unref(sortTypeIconSizePx),
"5a52bad6": unref(sortTypeAscIconMarginTopPx),
"cdf59098": unref(sortTypeDescIconMarginTopPx),
"388cc1cc": unref(rowHoverBackgroundColor),
"35e5e74e": unref(rowHoverFontColor),
"2eff878d": unref(evenRowFontColor),
"65303964": unref(evenRowBackgroundColor),
"3e69e9a1": unref(footerBackgroundColor),
"724d8820": unref(footerFontColor)
}));

@@ -901,2 +903,16 @@ const {

};
const clickRow = (item) => {
const clickRowArgument = __spreadValues({}, item);
if (isMutipleSelectable.value) {
const { checkbox } = item;
delete clickRowArgument.checkbox;
clickRowArgument.isSelected = checkbox;
}
if (props.showIndex) {
const { index } = item;
delete clickRowArgument.index;
clickRowArgument.indexInCurrentPage = index;
}
emits("clickRow", clickRowArgument);
};
expose({

@@ -962,3 +978,4 @@ clientItemsLength: totalItemsLength,

return openBlock(), createElementBlock("tr", {
key: JSON.stringify(item)
key: JSON.stringify(item),
onClick: ($event) => clickRow(item)
}, [

@@ -976,3 +993,3 @@ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(headerColumns), (column, i) => {

}), 128))
]);
], 8, _hoisted_5);
}), 128))

@@ -989,11 +1006,11 @@ ], 2)) : createCommentVNode("", true)

}, null, 2),
createElementVNode("div", _hoisted_5, [
createElementVNode("div", _hoisted_6, [
unref(ifHasLoadingSlot) ? renderSlot(_ctx.$slots, "loading", { key: 0 }, void 0, true) : (openBlock(), createBlock(Loading, { key: 1 }))
])
], 2)) : createCommentVNode("", true),
!unref(itemsForRender).length && !unref(loading) ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(__props.emptyMessage), 1)) : createCommentVNode("", true)
!unref(itemsForRender).length && !unref(loading) ? (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(__props.emptyMessage), 1)) : createCommentVNode("", true)
], 2),
__props.showFooter ? (openBlock(), createElementBlock("div", _hoisted_7, [
createElementVNode("div", _hoisted_8, [
_hoisted_9,
__props.showFooter ? (openBlock(), createElementBlock("div", _hoisted_8, [
createElementVNode("div", _hoisted_9, [
_hoisted_10,
createVNode(RowsSelector, {

@@ -1005,3 +1022,3 @@ modelValue: rowsPerPageReactive.value,

]),
createElementVNode("div", _hoisted_10, toDisplayString(`${unref(firstIndexOfItemsInCurrentPage)}-${unref(lastIndexOfItemsInCurrentPage)}`) + " of " + toDisplayString(unref(totalItemsLength)), 1),
createElementVNode("div", _hoisted_11, toDisplayString(`${unref(firstIndexOfItemsInCurrentPage)}-${unref(lastIndexOfItemsInCurrentPage)}`) + " of " + toDisplayString(unref(totalItemsLength)), 1),
unref(ifHasPaginationSlot) ? renderSlot(_ctx.$slots, "pagination", normalizeProps(mergeProps({ key: 0 }, {

@@ -1037,3 +1054,3 @@ isFirstPage: unref(isFirstPage),

});
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5129d26c"]]);
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ad03fd10"]]);
export { DataTable as default };

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

(function(e,g){typeof exports=="object"&&typeof module!="undefined"?module.exports=g(require("vue")):typeof define=="function"&&define.amd?define(["vue"],g):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=g(e.Vue))})(this,function(e){"use strict";var lt=Object.defineProperty,st=Object.defineProperties;var ct=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var ce=(e,g,f)=>g in e?lt(e,g,{enumerable:!0,configurable:!0,writable:!0,value:f}):e[g]=f,S=(e,g)=>{for(var f in g||(g={}))it.call(g,f)&&ce(e,f,g[f]);if(se)for(var f of se(g))dt.call(g,f)&&ce(e,f,g[f]);return e},z=(e,g)=>st(e,ct(g));var g="",f=(r,h)=>{const a=r.__vccOpts||r;for(const[t,p]of h)a[t]=p;return a};const ie=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),de=["onClick"],pe=["checked"],ue=ie(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var fe=f(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:h}){const a=r;e.useCssVars(P=>({"7f84b28f":e.unref(b)}));const t=e.computed(()=>a.status==="allSelected"),p=()=>{h("change",!t.value)},b=e.inject("themeColor");return(P,F)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(p,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(t),class:e.normalizeClass(r.status)},null,10,pe),ue],8,de))}}),[["__scopeId","data-v-566775ba"]]),ut="";const me=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),ge=["checked"],_e=me(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var he=f(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:h}){e.useCssVars(t=>({"20cfc5a0":e.unref(a)}));const a=e.inject("themeColor");return(t,p)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:p[0]||(p[0]=e.withModifiers(b=>h("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,ge),_e]))}}),[["__scopeId","data-v-39f156fd"]]),mt="";const ye=r=>(e.pushScopeId("data-v-0ed08e20"),r=r(),e.popScopeId(),r),be={class:"easy-data-table__rows-selector"},ke={class:"rows-input"},Se=ye(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),xe=["onClick"];var Ce=f(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:h}){const a=r;e.useCssVars(m=>({"83c11052":e.unref(u),"6b60f418":e.unref(l),"346ac97c":e.unref(i)}));const t=e.ref(!1),p=e.ref(!1),b=e.inject("dataTable");e.watch(t,m=>{if(m&&b){const x=window.innerHeight,y=b.value.getBoundingClientRect().height,$=b.value.getBoundingClientRect().top;x-(y+$)<=100?p.value=!0:p.value=!1}});const P=e.computed({get:()=>a.modelValue,set:m=>{h("update:modelValue",m)}}),F=m=>{P.value=m,t.value=!1},O=(m,x)=>{let y=m.parentNode;for(;y!=null;){if(y.classList&&y.classList.contains(x))return!0;y=y.parentNode}return!1},T=m=>{O(m.target,"easy-data-table__rows-selector")||(t.value=!1)};e.onMounted(()=>{document.addEventListener("click",T)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",T)});const i=e.inject("themeColor"),l=e.inject("footerBackgroundColor"),u=e.inject("footerFontColor");return(m,x)=>(e.openBlock(),e.createElementBlock("div",be,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:x[0]||(x[0]=y=>t.value=!t.value)},[e.createElementVNode("div",ke,e.toDisplayString(e.unref(P)),1),Se]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:t.value,inside:p.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,y=>(e.openBlock(),e.createElementBlock("li",{key:y,class:e.normalizeClass({selected:y===e.unref(P)}),onClick:$=>F(y)},e.toDisplayString(y),11,xe))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),_t="";const H=r=>(e.pushScopeId("data-v-969989cc"),r=r(),e.popScopeId(),r),Be={class:"lds-ring"},Pe=[H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1))];var Ne=f(e.defineComponent({setup(r){e.useCssVars(t=>({"284c10f4":e.unref(a),"90c4d0a4":e.unref(h)}));const h=e.inject("themeColor"),a=e.inject("loadingEntitySizePx");return(t,p)=>(e.openBlock(),e.createElementBlock("div",Be,Pe))}}),[["__scopeId","data-v-969989cc"]]),xt="";const we={class:"buttons-pagination"},$e=["onClick"];var Ee=f(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:h}){const a=r;e.useCssVars(i=>({aa5730a0:e.unref(F),"24829312":e.unref(O),"98a0e762":e.unref(T)}));const t=7,p=i=>{i.type==="button"&&!i.active&&h("updatePage",i.page)},b=e.computed(()=>{const i=[];if(a.maxPaginationNumber<=t)for(let l=1;l<=a.maxPaginationNumber;l+=1)i.push({type:"button",page:l,active:l===a.currentPaginationNumber});else if([1,2,a.maxPaginationNumber,a.maxPaginationNumber-1].includes(a.currentPaginationNumber))for(let l=1;l<=t;l+=1)if(l<=3)i.push({type:"button",page:l,active:l===a.currentPaginationNumber});else if(l===4)i.push({type:"omission"});else{const u=a.maxPaginationNumber-(t-l);i.push({type:"button",page:u,active:u===a.currentPaginationNumber})}else if([3,4].includes(a.currentPaginationNumber))for(let l=1;l<=t;l+=1)l<=5?i.push({type:"button",page:l,active:l===a.currentPaginationNumber}):l===6?i.push({type:"omission"}):i.push({type:"button",page:a.maxPaginationNumber,active:a.maxPaginationNumber===a.currentPaginationNumber});else if([a.maxPaginationNumber-2,a.maxPaginationNumber-3].includes(a.currentPaginationNumber))for(let l=1;l<=t;l+=1)if(l===1)i.push({type:"button",page:1,active:a.currentPaginationNumber===1});else if(l===2)i.push({type:"omission"});else{const u=a.maxPaginationNumber-(t-l);i.push({type:"button",page:u,active:u===a.currentPaginationNumber})}else for(let l=1;l<=t;l+=1)if(l===1)i.push({type:"button",page:1,active:a.currentPaginationNumber===1});else if(l===2||l===6)i.push({type:"omission"});else if(l===7)i.push({type:"button",page:a.maxPaginationNumber,active:a.maxPaginationNumber===a.currentPaginationNumber});else{const u=4-l,m=a.currentPaginationNumber-u;i.push({type:"button",page:m,active:m===a.currentPaginationNumber})}return i}),P=e.inject("rowHeight"),F=e.computed(()=>`${P*.6}px`),O=e.inject("rowBorderColor"),T=e.inject("themeColor");return(i,l)=>(e.openBlock(),e.createElementBlock("div",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(u,m)=>(e.openBlock(),e.createElementBlock("div",{key:m,class:e.normalizeClass(["item",{button:u.type==="button",active:u.type==="button"&&u.active,omission:u.type==="omission"}]),onClick:x=>p(u)},e.toDisplayString(u.type==="button"?u.page:"..."),11,$e))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Bt="";const G=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),Ie=[G(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Ve=[G(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Fe=f(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:h}){const a=e.useSlots();return(t,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:p[0]||(p[0]=b=>h("clickPrevPage"))},Ie,2),e.unref(a).buttonsPagination?e.renderSlot(t.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":r.isLastPage}]),onClick:p[1]||(p[1]=b=>h("clickNextPage"))},Ve,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),$t="";const Te={key:0},ze=["onClick"],Oe={key:1,class:"header-text__wrapper"},He={class:"header-text"},Le={class:"loading-entity"},De={key:1,class:"data-table__message"},Me={key:0,class:"data-table__footer"},Ae={class:"footer__rows-per-page"},Re=e.createTextVNode(" rows per page: "),je={class:"footer__items-index"};var qe=f(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},showFooter:{type:Boolean,default:!0},filterOptions:{type:Array,default:null}},emits:["update:itemsSelected","update:serverOptions"],setup(r,{expose:h,emit:a}){const t=r;e.useCssVars(o=>({c65bd006:e.unref(b),b254d126:e.unref(Ue),"22a645e9":e.unref(We),"24bf46d8":e.unref(Ye),"7f6da2f5":e.unref(Je),f0657fa8:e.unref(y),"712c83ae":e.unref(F),"329582af":e.unref(l),"60f70f71":e.unref(p),"4a75d3b3":e.unref(P),"2c21faf4":r.headerBackgroundColor,fa9cd624:e.unref(Ge),"60ff4571":e.unref(Ke),"67ea0079":e.unref(Qe),"1b03925f":e.unref(O),eae7d144:e.unref(T),"5da087e8":e.unref(m),e5c0192e:e.unref(u),b09c2bb4:e.unref(i),"20a4df36":e.unref(x)}));const{rowBorderColor:p,tableBorderColor:b,headerFontColor:P,rowFontColor:F,rowHoverBackgroundColor:O,rowHoverFontColor:T,footerBackgroundColor:i,rowBackgroundColor:l,evenRowBackgroundColor:u,evenRowFontColor:m,footerFontColor:x}=e.toRefs(t),y=e.computed(()=>`${t.tableFontSize}px`),$=e.computed(()=>t.tableFontSize*(t.dense?2:3)),Je=e.computed(()=>`${$.value}px`),We=e.computed(()=>t.tableHeight?`${t.tableHeight}px`:null),Ue=e.computed(()=>`${$.value*5}px`),K=e.computed(()=>Math.round(t.tableFontSize/2.5)),Ge=e.computed(()=>`${K.value}px`),Q=e.computed(()=>Math.round(K.value)),Ke=e.computed(()=>`-${Q.value}px`),Qe=e.computed(()=>`${Q.value}px`),Xe=e.computed(()=>`${t.tableFontSize*5}px`),Ye=e.computed(()=>t.tableHeight?`${t.tableHeight-$.value}px`:`${t.tableFontSize*5*2}px`);e.provide("themeColor",t.themeColor),e.provide("loadingEntitySizePx",Xe.value),e.provide("rowHeight",$.value),e.provide("rowBorderColor",p.value),e.provide("footerBackgroundColor",i.value),e.provide("footerFontColor",x.value);const L=e.useSlots(),Ze=e.computed(()=>L.body),ve=e.computed(()=>L.pagination),et=e.computed(()=>L.loading),X=e.ref();e.provide("dataTable",X);const d=e.computed({get:()=>{if(t.serverOptions){const{page:o,rowsPerPage:c,sortBy:n,sortType:s}=t.serverOptions;return{page:o,rowsPerPage:c,sortBy:n!=null?n:null,sortType:s!=null?s:null}}return null},set:o=>{a("update:serverOptions",o)}}),Y=e.computed(()=>t.itemsSelected!==null),w=e.computed(()=>d.value!==null),tt=()=>t.sortBy!==""?{sortBy:t.sortBy,sortDesc:t.sortType==="desc"}:null,E=e.ref(tt()),q=e.computed(()=>{const o=t.headers.map(s=>{const k=s;return s.sortable&&(k.sortType="none"),d.value&&s.value===d.value.sortBy&&d.value.sortType&&(k.sortType=d.value.sortType),!w.value&&E.value&&s.value===E.value.sortBy&&(k.sortType=E.value.sortDesc?"desc":"asc"),k}),c=t.showIndex?[{text:"#",value:"index"},...o]:o;return Y.value?[{text:"checkbox",value:"checkbox"},...c]:c}),Z=e.computed(()=>q.value.map(o=>o.value)),C=e.computed({get:()=>{var o;return(o=t.itemsSelected)!=null?o:[]},set:o=>{a("update:itemsSelected",o)}}),v=e.computed(()=>{if(!w.value&&t.searchValue!==""){const o=new RegExp(t.searchValue,"i");return t.items.filter(c=>o.test(t.searchField!==""?c[t.searchField]:Object.values(c).join(" ")))}return t.items}),I=e.computed(()=>{let o=[...v.value];return t.filterOptions?(t.filterOptions.forEach(c=>{o=o.filter(n=>{const{field:s,comparison:k,criteria:B}=c;switch(k){case"=":return n[s]===B;case"!=":return n[s]!==B;case">":return n[s]>B;case"<":return n[s]<B;case"<=":return n[s]<=B;case">=":return n[s]>=B;case"between":return n[s]>=Math.min(...B)&&n[s]<=Math.max(...B);default:return n[s]===B}})}),o):v.value}),D=e.computed(()=>C.value.length===0||C.value.every(c=>I.value.findIndex(n=>JSON.stringify(c)===JSON.stringify(n))===-1)?"noneSelected":C.value.length===I.value.length&&C.value.every(n=>I.value.findIndex(s=>JSON.stringify(n)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),_=e.ref(w.value?t.serverOptions.page:1),N=e.ref(w.value?t.serverOptions.rowsPerPage:t.rowsPerPage);e.watch(N,o=>{d.value&&(d.value=z(S({},d.value),{page:1,rowsPerPage:o})),_.value=1});const ot=(o,c)=>{let n=null;c==="none"?n="asc":c==="asc"?n="desc":n=null,d.value?d.value=z(S({},d.value),{sortBy:n!==null?o:null,sortType:n}):n===null?E.value=null:E.value={sortBy:o,sortDesc:n==="desc"}},ee=e.computed(()=>{if(w.value)return t.items;if(E.value===null)return I.value;const{sortBy:o,sortDesc:c}=E.value;return[...I.value].sort((s,k)=>s[o]<k[o]?c?1:-1:s[o]>k[o]?c?-1:1:0)}),J=e.computed(()=>w.value?t.serverItemsLength:I.value.length),te=e.computed(()=>w.value?_.value*N.value:Math.min(I.value.length,_.value*N.value)),oe=e.computed(()=>(_.value-1)*N.value+1),M=e.computed(()=>Math.ceil(J.value/N.value)),A=e.computed(()=>_.value===M.value),R=e.computed(()=>_.value===1),{loading:V}=e.toRefs(t),W=()=>{if(!A.value&&!V.value)if(d.value){const o=_.value+1;d.value=z(S({},d.value),{page:o})}else _.value+=1},U=()=>{if(!R.value&&!V.value)if(d.value){const o=_.value-1;d.value=z(S({},d.value),{page:o})}else _.value-=1},ne=o=>{V.value||(d.value?d.value=z(S({},d.value),{page:o}):_.value=o)};e.watch(V,(o,c)=>{d.value&&o===!1&&c===!0&&(_.value=d.value.page)});const re=e.computed(()=>w.value?t.items:ee.value.slice(oe.value-1,te.value)),ae=e.computed(()=>N.value*(_.value-1)+1),nt=e.computed(()=>N.value*_.value),j=e.computed(()=>t.showIndex?re.value.map((o,c)=>S({index:ae.value+c},o)):re.value),le=e.computed(()=>Y.value?D.value==="allSelected"?j.value.map(o=>S({checkbox:!0},o)):D.value==="noneSelected"?j.value.map(o=>S({checkbox:!1},o)):j.value.map(o=>{const c=C.value.findIndex(n=>{const s=S({},o);return delete s.index,JSON.stringify(n)===JSON.stringify(s)})!==-1;return S({checkbox:c},o)}):j.value),rt=o=>{C.value=o?ee.value:[]},at=o=>{const c=o.checkbox;if(delete o.checkbox,delete o.index,c)C.value=C.value.filter(n=>JSON.stringify(n)!==JSON.stringify(o));else{const n=C.value;n.unshift(o),C.value=n}};return h({clientItemsLength:J,currentPageFirstIndex:ae,currentPageLastIndex:nt,maxPaginationNumber:M,currentPaginationNumber:_,isLastPage:A,isFirstPage:R,nextPage:W,prevPage:U,updatePage:ne}),(o,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:X,class:"vue3-easy-data-table"},[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"fixed-height":r.tableHeight}])},[e.createElementVNode("table",null,[e.unref(q).length?(e.openBlock(),e.createElementBlock("thead",Te,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(q),(n,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass({sortable:n.sortable,none:n.sortable&&n.sortType==="none",desc:n.sortable&&n.sortType==="desc",asc:n.sortable&&n.sortType==="asc"}),onClick:k=>n.sortable&&n.sortType?ot(n.value,n.sortType):null},[n.text==="checkbox"?(e.openBlock(),e.createBlock(fe,{key:e.unref(D),status:e.unref(D),onChange:rt},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Oe,[e.createElementVNode("span",He,e.toDisplayString(n.text),1),n.sortable?(e.openBlock(),e.createElementBlock("i",{key:n.sortType?n.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:n.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],10,ze))),128))])])):e.createCommentVNode("",!0),e.unref(Ze)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[r.items.length&&e.unref(Z).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating,"hover-to-change-color":r.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(le),n=>(e.openBlock(),e.createElementBlock("tr",{key:JSON.stringify(n)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Z),(s,k)=>(e.openBlock(),e.createElementBlock("td",{key:k},[e.unref(L)[s]?e.renderSlot(o.$slots,s,e.normalizeProps(e.mergeProps({key:0},n)),void 0,!0):s==="checkbox"?(e.openBlock(),e.createBlock(he,{key:1,checked:n[s],onChange:B=>at(n)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(Array.isArray(n[s])?n[s].join(","):n[s]),1)],64))]))),128))]))),128))],2)):e.createCommentVNode("",!0)],64))]),e.unref(V)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!r.items.length&&e.unref(V)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":!r.showFooter}])},null,2),e.createElementVNode("div",Le,[e.unref(et)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Ne,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(le).length&&!e.unref(V)?(e.openBlock(),e.createElementBlock("div",De,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0)],2),r.showFooter?(e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("div",Ae,[Re,e.createVNode(Ce,{modelValue:N.value,"onUpdate:modelValue":c[0]||(c[0]=n=>N.value=n),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",je,e.toDisplayString(`${e.unref(oe)}-${e.unref(te)}`)+" of "+e.toDisplayString(e.unref(J)),1),e.unref(ve)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:0},{isFirstPage:e.unref(R),isLastPage:e.unref(A),currentPaginationNumber:_.value,maxPaginationNumber:e.unref(M),nextPage:W,prevPage:U})),void 0,!0):(e.openBlock(),e.createBlock(Fe,{key:1,"is-first-page":e.unref(R),"is-last-page":e.unref(A),onClickNextPage:W,onClickPrevPage:U},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Ee,{"current-pagination-number":_.value,"max-pagination-number":e.unref(M),onUpdatePage:ne},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))])):e.createCommentVNode("",!0)],512))}}),[["__scopeId","data-v-5129d26c"]]);return qe});
(function(e,m){typeof exports=="object"&&typeof module!="undefined"?module.exports=m(require("vue")):typeof define=="function"&&define.amd?define(["vue"],m):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=m(e.Vue))})(this,function(e){"use strict";var ct=Object.defineProperty,it=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var ce=(e,m,f)=>m in e?ct(e,m,{enumerable:!0,configurable:!0,writable:!0,value:f}):e[m]=f,x=(e,m)=>{for(var f in m||(m={}))pt.call(m,f)&&ce(e,f,m[f]);if(se)for(var f of se(m))ut.call(m,f)&&ce(e,f,m[f]);return e},z=(e,m)=>it(e,dt(m));var m="",f=(r,_)=>{const a=r.__vccOpts||r;for(const[n,p]of _)a[n]=p;return a};const ie=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),de=["onClick"],pe=["checked"],ue=ie(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var fe=f(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:_}){const a=r;e.useCssVars(P=>({"7f84b28f":e.unref(k)}));const n=e.computed(()=>a.status==="allSelected"),p=()=>{_("change",!n.value)},k=e.inject("themeColor");return(P,F)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(p,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(n),class:e.normalizeClass(r.status)},null,10,pe),ue],8,de))}}),[["__scopeId","data-v-566775ba"]]),gt="";const ge=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),me=["checked"],he=ge(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var _e=f(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:_}){e.useCssVars(n=>({"20cfc5a0":e.unref(a)}));const a=e.inject("themeColor");return(n,p)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:p[0]||(p[0]=e.withModifiers(k=>_("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,me),he]))}}),[["__scopeId","data-v-39f156fd"]]),ht="";const ye=r=>(e.pushScopeId("data-v-0ed08e20"),r=r(),e.popScopeId(),r),ke={class:"easy-data-table__rows-selector"},be={class:"rows-input"},xe=ye(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Ce=["onClick"];var Se=f(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:_}){const a=r;e.useCssVars(g=>({"83c11052":e.unref(u),"6b60f418":e.unref(l),"346ac97c":e.unref(i)}));const n=e.ref(!1),p=e.ref(!1),k=e.inject("dataTable");e.watch(n,g=>{if(g&&k){const C=window.innerHeight,y=k.value.getBoundingClientRect().height,$=k.value.getBoundingClientRect().top;C-(y+$)<=100?p.value=!0:p.value=!1}});const P=e.computed({get:()=>a.modelValue,set:g=>{_("update:modelValue",g)}}),F=g=>{P.value=g,n.value=!1},O=(g,C)=>{let y=g.parentNode;for(;y!=null;){if(y.classList&&y.classList.contains(C))return!0;y=y.parentNode}return!1},T=g=>{O(g.target,"easy-data-table__rows-selector")||(n.value=!1)};e.onMounted(()=>{document.addEventListener("click",T)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",T)});const i=e.inject("themeColor"),l=e.inject("footerBackgroundColor"),u=e.inject("footerFontColor");return(g,C)=>(e.openBlock(),e.createElementBlock("div",ke,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:C[0]||(C[0]=y=>n.value=!n.value)},[e.createElementVNode("div",be,e.toDisplayString(e.unref(P)),1),xe]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:n.value,inside:p.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,y=>(e.openBlock(),e.createElementBlock("li",{key:y,class:e.normalizeClass({selected:y===e.unref(P)}),onClick:$=>F(y)},e.toDisplayString(y),11,Ce))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),yt="";const H=r=>(e.pushScopeId("data-v-969989cc"),r=r(),e.popScopeId(),r),Be={class:"lds-ring"},Pe=[H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1))];var Ne=f(e.defineComponent({setup(r){e.useCssVars(n=>({"284c10f4":e.unref(a),"90c4d0a4":e.unref(_)}));const _=e.inject("themeColor"),a=e.inject("loadingEntitySizePx");return(n,p)=>(e.openBlock(),e.createElementBlock("div",Be,Pe))}}),[["__scopeId","data-v-969989cc"]]),Bt="";const we={class:"buttons-pagination"},$e=["onClick"];var Ie=f(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:_}){const a=r;e.useCssVars(i=>({aa5730a0:e.unref(F),"24829312":e.unref(O),"98a0e762":e.unref(T)}));const n=7,p=i=>{i.type==="button"&&!i.active&&_("updatePage",i.page)},k=e.computed(()=>{const i=[];if(a.maxPaginationNumber<=n)for(let l=1;l<=a.maxPaginationNumber;l+=1)i.push({type:"button",page:l,active:l===a.currentPaginationNumber});else if([1,2,a.maxPaginationNumber,a.maxPaginationNumber-1].includes(a.currentPaginationNumber))for(let l=1;l<=n;l+=1)if(l<=3)i.push({type:"button",page:l,active:l===a.currentPaginationNumber});else if(l===4)i.push({type:"omission"});else{const u=a.maxPaginationNumber-(n-l);i.push({type:"button",page:u,active:u===a.currentPaginationNumber})}else if([3,4].includes(a.currentPaginationNumber))for(let l=1;l<=n;l+=1)l<=5?i.push({type:"button",page:l,active:l===a.currentPaginationNumber}):l===6?i.push({type:"omission"}):i.push({type:"button",page:a.maxPaginationNumber,active:a.maxPaginationNumber===a.currentPaginationNumber});else if([a.maxPaginationNumber-2,a.maxPaginationNumber-3].includes(a.currentPaginationNumber))for(let l=1;l<=n;l+=1)if(l===1)i.push({type:"button",page:1,active:a.currentPaginationNumber===1});else if(l===2)i.push({type:"omission"});else{const u=a.maxPaginationNumber-(n-l);i.push({type:"button",page:u,active:u===a.currentPaginationNumber})}else for(let l=1;l<=n;l+=1)if(l===1)i.push({type:"button",page:1,active:a.currentPaginationNumber===1});else if(l===2||l===6)i.push({type:"omission"});else if(l===7)i.push({type:"button",page:a.maxPaginationNumber,active:a.maxPaginationNumber===a.currentPaginationNumber});else{const u=4-l,g=a.currentPaginationNumber-u;i.push({type:"button",page:g,active:g===a.currentPaginationNumber})}return i}),P=e.inject("rowHeight"),F=e.computed(()=>`${P*.6}px`),O=e.inject("rowBorderColor"),T=e.inject("themeColor");return(i,l)=>(e.openBlock(),e.createElementBlock("div",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(u,g)=>(e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass(["item",{button:u.type==="button",active:u.type==="button"&&u.active,omission:u.type==="omission"}]),onClick:C=>p(u)},e.toDisplayString(u.type==="button"?u.page:"..."),11,$e))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Nt="";const K=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),Ee=[K(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Ve=[K(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Fe=f(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:_}){const a=e.useSlots();return(n,p)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:p[0]||(p[0]=k=>_("clickPrevPage"))},Ee,2),e.unref(a).buttonsPagination?e.renderSlot(n.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":r.isLastPage}]),onClick:p[1]||(p[1]=k=>_("clickNextPage"))},Ve,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),Et="";const Te={key:0},ze=["onClick"],Oe={key:1,class:"header-text__wrapper"},He={class:"header-text"},Le=["onClick"],Re={class:"loading-entity"},Ae={key:1,class:"data-table__message"},De={key:0,class:"data-table__footer"},Me={class:"footer__rows-per-page"},je=e.createTextVNode(" rows per page: "),qe={class:"footer__items-index"};var Je=f(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},showFooter:{type:Boolean,default:!0},filterOptions:{type:Array,default:null}},emits:["update:itemsSelected","update:serverOptions","clickRow"],setup(r,{expose:_,emit:a}){const n=r;e.useCssVars(o=>({"6e3117a2":e.unref(k),"42f6b6b0":e.unref(Ge),"2ac6f064":e.unref(Ue),"1b05fc8e":e.unref(Ze),"91c69fa0":e.unref(We),"0dba1f91":e.unref(y),"2f5f1dd3":e.unref(F),"28332d14":e.unref(l),"5cebb456":e.unref(p),"65d46924":e.unref(P),"7a4c0b22":r.headerBackgroundColor,"784f3f53":e.unref(Ke),"5a52bad6":e.unref(Qe),cdf59098:e.unref(Xe),"388cc1cc":e.unref(O),"35e5e74e":e.unref(T),"2eff878d":e.unref(g),"65303964":e.unref(u),"3e69e9a1":e.unref(i),"724d8820":e.unref(C)}));const{rowBorderColor:p,tableBorderColor:k,headerFontColor:P,rowFontColor:F,rowHoverBackgroundColor:O,rowHoverFontColor:T,footerBackgroundColor:i,rowBackgroundColor:l,evenRowBackgroundColor:u,evenRowFontColor:g,footerFontColor:C}=e.toRefs(n),y=e.computed(()=>`${n.tableFontSize}px`),$=e.computed(()=>n.tableFontSize*(n.dense?2:3)),We=e.computed(()=>`${$.value}px`),Ue=e.computed(()=>n.tableHeight?`${n.tableHeight}px`:null),Ge=e.computed(()=>`${$.value*5}px`),Q=e.computed(()=>Math.round(n.tableFontSize/2.5)),Ke=e.computed(()=>`${Q.value}px`),X=e.computed(()=>Math.round(Q.value)),Qe=e.computed(()=>`-${X.value}px`),Xe=e.computed(()=>`${X.value}px`),Ye=e.computed(()=>`${n.tableFontSize*5}px`),Ze=e.computed(()=>n.tableHeight?`${n.tableHeight-$.value}px`:`${n.tableFontSize*5*2}px`);e.provide("themeColor",n.themeColor),e.provide("loadingEntitySizePx",Ye.value),e.provide("rowHeight",$.value),e.provide("rowBorderColor",p.value),e.provide("footerBackgroundColor",i.value),e.provide("footerFontColor",C.value);const L=e.useSlots(),ve=e.computed(()=>L.body),et=e.computed(()=>L.pagination),tt=e.computed(()=>L.loading),Y=e.ref();e.provide("dataTable",Y);const d=e.computed({get:()=>{if(n.serverOptions){const{page:o,rowsPerPage:c,sortBy:t,sortType:s}=n.serverOptions;return{page:o,rowsPerPage:c,sortBy:t!=null?t:null,sortType:s!=null?s:null}}return null},set:o=>{a("update:serverOptions",o)}}),q=e.computed(()=>n.itemsSelected!==null),w=e.computed(()=>d.value!==null),ot=()=>n.sortBy!==""?{sortBy:n.sortBy,sortDesc:n.sortType==="desc"}:null,I=e.ref(ot()),J=e.computed(()=>{const o=n.headers.map(s=>{const b=s;return s.sortable&&(b.sortType="none"),d.value&&s.value===d.value.sortBy&&d.value.sortType&&(b.sortType=d.value.sortType),!w.value&&I.value&&s.value===I.value.sortBy&&(b.sortType=I.value.sortDesc?"desc":"asc"),b}),c=n.showIndex?[{text:"#",value:"index"},...o]:o;return q.value?[{text:"checkbox",value:"checkbox"},...c]:c}),Z=e.computed(()=>J.value.map(o=>o.value)),S=e.computed({get:()=>{var o;return(o=n.itemsSelected)!=null?o:[]},set:o=>{a("update:itemsSelected",o)}}),v=e.computed(()=>{if(!w.value&&n.searchValue!==""){const o=new RegExp(n.searchValue,"i");return n.items.filter(c=>o.test(n.searchField!==""?c[n.searchField]:Object.values(c).join(" ")))}return n.items}),E=e.computed(()=>{let o=[...v.value];return n.filterOptions?(n.filterOptions.forEach(c=>{o=o.filter(t=>{const{field:s,comparison:b,criteria:B}=c;switch(b){case"=":return t[s]===B;case"!=":return t[s]!==B;case">":return t[s]>B;case"<":return t[s]<B;case"<=":return t[s]<=B;case">=":return t[s]>=B;case"between":return t[s]>=Math.min(...B)&&t[s]<=Math.max(...B);default:return t[s]===B}})}),o):v.value}),R=e.computed(()=>S.value.length===0||S.value.every(c=>E.value.findIndex(t=>JSON.stringify(c)===JSON.stringify(t))===-1)?"noneSelected":S.value.length===E.value.length&&S.value.every(t=>E.value.findIndex(s=>JSON.stringify(t)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),h=e.ref(w.value?n.serverOptions.page:1),N=e.ref(w.value?n.serverOptions.rowsPerPage:n.rowsPerPage);e.watch(N,o=>{d.value&&(d.value=z(x({},d.value),{page:1,rowsPerPage:o})),h.value=1});const nt=(o,c)=>{let t=null;c==="none"?t="asc":c==="asc"?t="desc":t=null,d.value?d.value=z(x({},d.value),{sortBy:t!==null?o:null,sortType:t}):t===null?I.value=null:I.value={sortBy:o,sortDesc:t==="desc"}},ee=e.computed(()=>{if(w.value)return n.items;if(I.value===null)return E.value;const{sortBy:o,sortDesc:c}=I.value;return[...E.value].sort((s,b)=>s[o]<b[o]?c?1:-1:s[o]>b[o]?c?-1:1:0)}),W=e.computed(()=>w.value?n.serverItemsLength:E.value.length),te=e.computed(()=>w.value?h.value*N.value:Math.min(E.value.length,h.value*N.value)),oe=e.computed(()=>(h.value-1)*N.value+1),A=e.computed(()=>Math.ceil(W.value/N.value)),D=e.computed(()=>h.value===A.value),M=e.computed(()=>h.value===1),{loading:V}=e.toRefs(n),U=()=>{if(!D.value&&!V.value)if(d.value){const o=h.value+1;d.value=z(x({},d.value),{page:o})}else h.value+=1},G=()=>{if(!M.value&&!V.value)if(d.value){const o=h.value-1;d.value=z(x({},d.value),{page:o})}else h.value-=1},ne=o=>{V.value||(d.value?d.value=z(x({},d.value),{page:o}):h.value=o)};e.watch(V,(o,c)=>{d.value&&o===!1&&c===!0&&(h.value=d.value.page)});const re=e.computed(()=>w.value?n.items:ee.value.slice(oe.value-1,te.value)),ae=e.computed(()=>N.value*(h.value-1)+1),rt=e.computed(()=>N.value*h.value),j=e.computed(()=>n.showIndex?re.value.map((o,c)=>x({index:ae.value+c},o)):re.value),le=e.computed(()=>q.value?R.value==="allSelected"?j.value.map(o=>x({checkbox:!0},o)):R.value==="noneSelected"?j.value.map(o=>x({checkbox:!1},o)):j.value.map(o=>{const c=S.value.findIndex(t=>{const s=x({},o);return delete s.index,JSON.stringify(t)===JSON.stringify(s)})!==-1;return x({checkbox:c},o)}):j.value),at=o=>{S.value=o?ee.value:[]},lt=o=>{const c=o.checkbox;if(delete o.checkbox,delete o.index,c)S.value=S.value.filter(t=>JSON.stringify(t)!==JSON.stringify(o));else{const t=S.value;t.unshift(o),S.value=t}},st=o=>{const c=x({},o);if(q.value){const{checkbox:t}=o;delete c.checkbox,c.isSelected=t}if(n.showIndex){const{index:t}=o;delete c.index,c.indexInCurrentPage=t}a("clickRow",c)};return _({clientItemsLength:W,currentPageFirstIndex:ae,currentPageLastIndex:rt,maxPaginationNumber:A,currentPaginationNumber:h,isLastPage:D,isFirstPage:M,nextPage:U,prevPage:G,updatePage:ne}),(o,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:Y,class:"vue3-easy-data-table"},[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"fixed-height":r.tableHeight}])},[e.createElementVNode("table",null,[e.unref(J).length?(e.openBlock(),e.createElementBlock("thead",Te,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(J),(t,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass({sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc"}),onClick:b=>t.sortable&&t.sortType?nt(t.value,t.sortType):null},[t.text==="checkbox"?(e.openBlock(),e.createBlock(fe,{key:e.unref(R),status:e.unref(R),onChange:at},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Oe,[e.createElementVNode("span",He,e.toDisplayString(t.text),1),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],10,ze))),128))])])):e.createCommentVNode("",!0),e.unref(ve)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[r.items.length&&e.unref(Z).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating,"hover-to-change-color":r.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(le),t=>(e.openBlock(),e.createElementBlock("tr",{key:JSON.stringify(t),onClick:s=>st(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Z),(s,b)=>(e.openBlock(),e.createElementBlock("td",{key:b},[e.unref(L)[s]?e.renderSlot(o.$slots,s,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):s==="checkbox"?(e.openBlock(),e.createBlock(_e,{key:1,checked:t[s],onChange:B=>lt(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(Array.isArray(t[s])?t[s].join(","):t[s]),1)],64))]))),128))],8,Le))),128))],2)):e.createCommentVNode("",!0)],64))]),e.unref(V)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!r.items.length&&e.unref(V)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":!r.showFooter}])},null,2),e.createElementVNode("div",Re,[e.unref(tt)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Ne,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(le).length&&!e.unref(V)?(e.openBlock(),e.createElementBlock("div",Ae,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0)],2),r.showFooter?(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("div",Me,[je,e.createVNode(Se,{modelValue:N.value,"onUpdate:modelValue":c[0]||(c[0]=t=>N.value=t),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",qe,e.toDisplayString(`${e.unref(oe)}-${e.unref(te)}`)+" of "+e.toDisplayString(e.unref(W)),1),e.unref(et)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:0},{isFirstPage:e.unref(M),isLastPage:e.unref(D),currentPaginationNumber:h.value,maxPaginationNumber:e.unref(A),nextPage:U,prevPage:G})),void 0,!0):(e.openBlock(),e.createBlock(Fe,{key:1,"is-first-page":e.unref(M),"is-last-page":e.unref(D),onClickNextPage:U,onClickPrevPage:G},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Ie,{"current-pagination-number":h.value,"max-pagination-number":e.unref(A),onUpdatePage:ne},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))])):e.createCommentVNode("",!0)],512))}}),[["__scopeId","data-v-ad03fd10"]]);return Je});

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

"private": false,
"version": "1.2.3",
"version": "1.2.4",
"types": "./types/main.d.ts",

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

@@ -24,2 +24,3 @@ <p align="center">

10. [Footer customization](https://hc200ok.github.io/vue3-easy-data-table-doc/features/footer-customization.html)
11. [Filtering](https://hc200ok.github.io/vue3-easy-data-table-doc/features/filtering.html) (new feature since version `1.2.3`)

@@ -79,2 +80,5 @@ ## Getting started

## Todo
1. make table header customizable 🎛️.
## ⭐ Stargazers

@@ -86,2 +90,2 @@ [![Stargazers repo roster for @HC200ok/vue3-easy-data-table](https://reporoster.com/stars/dark/notext/HC200ok/vue3-easy-data-table)](https://github.com/HC200ok/vue3-easy-data-table/stargazers)

And making pull requests is also very welcomed!
And making pull requests is also very welcomed!

@@ -33,1 +33,6 @@ export type SortType = 'asc' | 'desc'

}
export type clickRowArgument = Item & {
isSelected?: boolean,
indexInCurrentPage?: number,
}

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