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