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.18 to 1.4.19

32

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

@@ -425,3 +425,3 @@ var __defProp = Object.defineProperty;

}
function useExpandableRow(items, emits) {
function useExpandableRow(items, prevPageEndIndex, emits) {
const expandingItemIndexList = ref([]);

@@ -434,4 +434,5 @@ const updateExpandingItemIndexList = (expandingItemIndex, expandingItem, event) => {

} else {
emits("expandRow", items.value.findIndex((item) => item === expandingItem));
expandingItemIndexList.value.push(expandingItemIndex);
const currentPageExpandIndex = items.value.findIndex((item) => JSON.stringify(item) === JSON.stringify(expandingItem));
emits("expandRow", prevPageEndIndex.value + currentPageExpandIndex);
expandingItemIndexList.value.push(prevPageEndIndex.value + currentPageExpandIndex);
}

@@ -1054,3 +1055,3 @@ };

var DataTable_vue_vue_type_style_index_1_scoped_true_lang = "";
const _withScopeId = (n) => (pushScopeId("data-v-4d5f5020"), n = n(), popScopeId(), n);
const _withScopeId = (n) => (pushScopeId("data-v-2351cc61"), n = n(), popScopeId(), n);
const _hoisted_1 = ["onClick"];

@@ -1104,4 +1105,4 @@ const _hoisted_2 = {

useCssVars((_ctx) => ({
"43fcf33a": unref(tableMinHeightPx),
"38fe986d": unref(tableHeightPx)
"11cca481": unref(tableMinHeightPx),
"610141e2": unref(tableHeightPx)
}));

@@ -1196,2 +1197,7 @@ const {

} = usePageItems(currentPaginationNumber, isMultipleSelectable, isServerSideMode, items, rowsPerPageRef, selectItemsComputed, showIndex, totalItems, totalItemsLength);
const prevPageEndIndex = computed(() => {
if (currentPaginationNumber.value === 0)
return 0;
return (currentPaginationNumber.value - 1) * rowsPerPageRef.value;
});
const {

@@ -1201,3 +1207,3 @@ expandingItemIndexList,

clearExpandingItemIndexList
} = useExpandableRow(pageItems, emits);
} = useExpandableRow(pageItems, prevPageEndIndex, emits);
const {

@@ -1235,6 +1241,2 @@ fixedHeaders,

});
watch(items, () => {
if (!isServerSideMode.value)
updatePage(1);
}, { deep: true });
watch(rowsPerPageRef, (value) => {

@@ -1361,7 +1363,7 @@ if (!isServerSideMode.value) {

}, typeof _ctx.bodyItemClassName === "string" ? _ctx.bodyItemClassName : _ctx.bodyItemClassName(column, i), `direction-${unref(bodyTextDirection)}`]),
onClick: ($event) => column === "expand" ? unref(updateExpandingItemIndexList)(index, item, $event) : null
onClick: ($event) => column === "expand" ? unref(updateExpandingItemIndexList)(index + unref(prevPageEndIndex), 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(expandingItemIndexList).includes(unref(prevPageEndIndex) + index) }])
}, null, 2)) : column === "checkbox" ? (openBlock(), createBlock(SingleSelectCheckBox, {

@@ -1377,3 +1379,3 @@ key: 2,

], 10, _hoisted_3),
unref(ifHasExpandSlot) && unref(expandingItemIndexList).includes(index) ? (openBlock(), createElementBlock("tr", {
unref(ifHasExpandSlot) && unref(expandingItemIndexList).includes(index + unref(prevPageEndIndex)) ? (openBlock(), createElementBlock("tr", {
key: 0,

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

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

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

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

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

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

"private": false,
"version": "1.4.18",
"version": "1.4.19",
"types": "./types/main.d.ts",
"license": "MIT",
"files": [
"license": "MIT",
"files": [
"dist",

@@ -12,0 +12,0 @@ "types"

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