vue3-easy-data-table
Advanced tools
Comparing version 1.3.14 to 1.3.15
@@ -397,3 +397,3 @@ var __defProp = Object.defineProperty; | ||
var DataTable_vue_vue_type_style_index_1_lang = ""; | ||
const _withScopeId = (n) => (pushScopeId("data-v-70716fde"), n = n(), popScopeId(), n); | ||
const _withScopeId = (n) => (pushScopeId("data-v-870aca6c"), n = n(), popScopeId(), n); | ||
const _hoisted_1 = ["onClick"]; | ||
@@ -594,3 +594,3 @@ const _hoisted_2 = { | ||
useCssVars((_ctx) => ({ | ||
"703f0a63": unref(tableHeightPx) | ||
"2a5ec828": unref(tableHeightPx) | ||
})); | ||
@@ -912,3 +912,3 @@ const tableHeightPx = computed(() => props.tableHeight ? `${props.tableHeight}px` : null); | ||
if (isServerSideMode.value) { | ||
return currentPaginationNumber.value * rowsPerPageReactive.value; | ||
return Math.min(totalItemsLength.value, currentPaginationNumber.value * rowsPerPageReactive.value); | ||
} | ||
@@ -1172,3 +1172,3 @@ return Math.min(itemsFiltering.value.length, currentPaginationNumber.value * rowsPerPageReactive.value); | ||
])) : createCommentVNode("", true), | ||
createElementVNode("div", _hoisted_13, toDisplayString(`${unref(firstIndexOfItemsInCurrentPage)}-${unref(lastIndexOfItemsInCurrentPage)}`) + " of " + toDisplayString(unref(totalItemsLength)), 1), | ||
createElementVNode("div", _hoisted_13, toDisplayString(`${unref(firstIndexOfItemsInCurrentPage)}\u2013${unref(lastIndexOfItemsInCurrentPage)}`) + " of " + toDisplayString(unref(totalItemsLength)), 1), | ||
unref(ifHasPaginationSlot) ? renderSlot(_ctx.$slots, "pagination", normalizeProps(mergeProps({ key: 1 }, { | ||
@@ -1204,3 +1204,3 @@ isFirstPage: unref(isFirstPage), | ||
}); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-70716fde"]]); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-870aca6c"]]); | ||
if (typeof window !== "undefined" && window.Vue) { | ||
@@ -1207,0 +1207,0 @@ window.Vue.createApp({}).component("Vue3EasyDataTable", DataTable); |
@@ -1,1 +0,1 @@ | ||
(function(e,y){typeof exports=="object"&&typeof module!="undefined"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=y(e.Vue))})(this,function(e){"use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var de=(e,y,m)=>y in e?dt(e,y,{enumerable:!0,configurable:!0,writable:!0,value:m}):e[y]=m,S=(e,y)=>{for(var m in y||(y={}))mt.call(y,m)&&de(e,m,y[m]);if(ce)for(var m of ce(y))ft.call(y,m)&&de(e,m,y[m]);return e},O=(e,y)=>ut(e,pt(y));var y="",m=(o,h)=>{const r=o.__vccOpts||o;for(const[a,f]of h)r[a]=f;return r};const ue=o=>(e.pushScopeId("data-v-566775ba"),o=o(),e.popScopeId(),o),pe=["onClick"],me=["checked"],fe=ue(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ge=m(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(o,{emit:h}){const r=o;e.useCssVars(w=>({"7f84b28f":e.unref(x)}));const a=e.computed(()=>r.status==="allSelected"),f=()=>{h("change",!a.value)},x=e.inject("themeColor");return(w,u)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(f,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(a),class:e.normalizeClass(o.status)},null,10,me),fe],8,pe))}}),[["__scopeId","data-v-566775ba"]]),ht="";const he=o=>(e.pushScopeId("data-v-39f156fd"),o=o(),e.popScopeId(),o),_e=["checked"],ye=he(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ke=m(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(o,{emit:h}){e.useCssVars(a=>({"20cfc5a0":e.unref(r)}));const r=e.inject("themeColor");return(a,f)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:f[0]||(f[0]=e.withModifiers(x=>h("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:o.checked},null,8,_e),ye]))}}),[["__scopeId","data-v-39f156fd"]]),yt="";const xe=o=>(e.pushScopeId("data-v-384d1036"),o=o(),e.popScopeId(),o),be={class:"easy-data-table__rows-selector"},Ce={class:"rows-input"},Ne=xe(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Se=["onClick"];var Be=m(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(o,{emit:h}){const r=o;e.useCssVars(b=>({"40595ee7":e.unref(B)}));const a=e.ref(!1),f=e.ref(!1),x=e.inject("dataTable");e.watch(a,b=>{if(b&&x){const d=window.innerHeight,k=x.value.getBoundingClientRect().height,C=x.value.getBoundingClientRect().top;d-(k+C)<=100?f.value=!0:f.value=!1}});const w=e.computed({get:()=>r.modelValue,set:b=>{h("update:modelValue",b)}}),u=b=>{w.value=b,a.value=!1},i=(b,d)=>{let k=b.parentNode;for(;k!=null;){if(k.classList&&k.classList.contains(d))return!0;k=k.parentNode}return!1},p=b=>{i(b.target,"easy-data-table__rows-selector")||(a.value=!1)};e.onMounted(()=>{document.addEventListener("click",p)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",p)});const B=e.inject("themeColor");return(b,d)=>(e.openBlock(),e.createElementBlock("div",be,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:d[0]||(d[0]=k=>a.value=!a.value)},[e.createElementVNode("div",Ce,e.toDisplayString(e.unref(w)),1),Ne]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:a.value,inside:f.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.rowsItems,k=>(e.openBlock(),e.createElementBlock("li",{key:k,class:e.normalizeClass({selected:k===e.unref(w)}),onClick:C=>u(k)},e.toDisplayString(k),11,Se))),128))],2)]))}}),[["__scopeId","data-v-384d1036"]]),xt="";const H=o=>(e.pushScopeId("data-v-1fa3a520"),o=o(),e.popScopeId(),o),Pe={class:"lds-ring"},we=[H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1))];var Ie=m(e.defineComponent({setup(o){e.useCssVars(r=>({"26774109":e.unref(h)}));const h=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",Pe,we))}}),[["__scopeId","data-v-1fa3a520"]]),Pt="";const $e={class:"loader-line"};var Ee=m(e.defineComponent({setup(o){e.useCssVars(r=>({"0d327f57":e.unref(h)}));const h=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",$e))}}),[["__scopeId","data-v-7d281cac"]]),It="";const Ve={class:"buttons-pagination"},Fe=["onClick"];var Te=m(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(o,{emit:h}){const r=o;e.useCssVars(u=>({"5c478b08":e.unref(w)}));const a=7,f=u=>{u.type==="button"&&!u.active&&h("updatePage",u.page)},x=e.computed(()=>{const u=[];if(r.maxPaginationNumber<=a)for(let i=1;i<=r.maxPaginationNumber;i+=1)u.push({type:"button",page:i,active:i===r.currentPaginationNumber});else if([1,2,r.maxPaginationNumber,r.maxPaginationNumber-1].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)if(i<=3)u.push({type:"button",page:i,active:i===r.currentPaginationNumber});else if(i===4)u.push({type:"omission"});else{const p=r.maxPaginationNumber-(a-i);u.push({type:"button",page:p,active:p===r.currentPaginationNumber})}else if([3,4].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)i<=5?u.push({type:"button",page:i,active:i===r.currentPaginationNumber}):i===6?u.push({type:"omission"}):u.push({type:"button",page:r.maxPaginationNumber,active:r.maxPaginationNumber===r.currentPaginationNumber});else if([r.maxPaginationNumber-2,r.maxPaginationNumber-3].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)if(i===1)u.push({type:"button",page:1,active:r.currentPaginationNumber===1});else if(i===2)u.push({type:"omission"});else{const p=r.maxPaginationNumber-(a-i);u.push({type:"button",page:p,active:p===r.currentPaginationNumber})}else for(let i=1;i<=a;i+=1)if(i===1)u.push({type:"button",page:1,active:r.currentPaginationNumber===1});else if(i===2||i===6)u.push({type:"omission"});else if(i===7)u.push({type:"button",page:r.maxPaginationNumber,active:r.maxPaginationNumber===r.currentPaginationNumber});else{const p=4-i,B=r.currentPaginationNumber-p;u.push({type:"button",page:B,active:B===r.currentPaginationNumber})}return u}),w=e.inject("themeColor");return(u,i)=>(e.openBlock(),e.createElementBlock("div",Ve,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(x),(p,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:e.normalizeClass(["item",{button:p.type==="button",active:p.type==="button"&&p.active,omission:p.type==="omission"}]),onClick:b=>f(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,Fe))),128))]))}}),[["__scopeId","data-v-0e334da4"]]),Et="";const G=o=>(e.pushScopeId("data-v-c9da5286"),o=o(),e.popScopeId(),o),Le=[G(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Oe=[G(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Re=m(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(o,{emit:h}){const r=e.useSlots();return(a,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":o.isFirstPage}]),onClick:f[0]||(f[0]=x=>h("clickPrevPage"))},Le,2),e.unref(r).buttonsPagination?e.renderSlot(a.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":o.isLastPage}]),onClick:f[1]||(f[1]=x=>h("clickNextPage"))},Oe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),Lt="",Ot="";const ze=o=>(e.pushScopeId("data-v-70716fde"),o=o(),e.popScopeId(),o),He=["onClick"],Ae={key:1,class:"header"},De={key:1,class:"header-text"},Me=["onClick"],je=["onClick"],qe=["colspan"],We={key:0,class:"vue3-easy-data-table__loading"},ve=ze(()=>e.createElementVNode("div",{class:"vue3-easy-data-table__loading-mask"},null,-1)),Je={class:"loading-entity"},Ue={key:1,class:"vue3-easy-data-table__message"},Ge={key:0,class:"vue3-easy-data-table__footer"},Ke={key:0,class:"pagination__rows-per-page"},Qe={class:"pagination__items-index"};var K=m(e.defineComponent({props:{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},headers:{type:Array,required:!0},hideFooter:{type:Boolean,default:!1},hideRowsPerPage:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},items:{type:Array,required:!0},itemsSelected:{type:Array,default:null},loading:{type:Boolean,deault:!1},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowsPerPageMessage:{type:String,default:"rows per page:"},searchField:{type:String,default:""},searchValue:{type:String,default:""},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},showIndex:{type:Boolean,default:!1},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},tableHeight:{type:Number,default:null},themeColor:{type:String,default:"#42b883"},tableClassName:{type:String,default:""},headerClassName:{type:String,default:""},headerItemClassName:{type:[Function,String],default:""},bodyRowClassName:{type:[Function,String],default:""},bodyItemClassName:{type:[Function,String],default:""},noHover:{type:Boolean,default:!1},borderCell:{type:Boolean,default:!1},mustSort:{type:Boolean,default:!1}},emits:["update:itemsSelected","update:serverOptions","clickRow","expandRow"],setup(o,{expose:h,emit:r}){const a=o;e.useCssVars(n=>({"703f0a63":e.unref(f)}));const f=e.computed(()=>a.tableHeight?`${a.tableHeight}px`:null);e.provide("themeColor",a.themeColor);const x=e.useSlots(),w=e.computed(()=>x.pagination),u=e.computed(()=>x.loading),i=e.computed(()=>x.expand),p=e.ref(),B=e.ref();e.provide("dataTable",p);const b=e.ref(!1);e.onMounted(()=>{B.value.addEventListener("scroll",()=>{b.value=B.value.scrollLeft>0})});const d=e.computed({get:()=>{if(a.serverOptions){const{page:n,rowsPerPage:l,sortBy:t,sortType:s}=a.serverOptions;return{page:n,rowsPerPage:l,sortBy:t!=null?t:null,sortType:s!=null?s:null}}return null},set:n=>{r("update:serverOptions",n)}}),k=e.computed(()=>a.itemsSelected!==null),C=e.computed(()=>d.value!==null),Xe=e.computed(()=>!C.value&&a.rowsItems.findIndex(n=>n===a.rowsPerPage)===-1?[a.rowsPerPage,...a.rowsItems]:a.rowsItems),Ye=()=>a.sortBy!==""?{sortBy:a.sortBy,sortDesc:a.sortType==="desc"}:null,E=e.ref(Ye()),A=e.computed(()=>a.headers.findIndex(n=>n.fixed)!==-1),Ze=e.computed(()=>A.value?a.headers.filter(n=>n.fixed):[]),et=e.computed(()=>a.headers.filter(n=>!n.fixed)),F=e.computed(()=>{var g;const l=[...Ze.value,...et.value].map(N=>{const L=N;return N.sortable&&(L.sortType="none"),d.value&&N.value===d.value.sortBy&&d.value.sortType&&(L.sortType=d.value.sortType),!C.value&&E.value&&N.value===E.value.sortBy&&(L.sortType=E.value.sortDesc?"desc":"asc"),L});let t=[];i.value?t=[a.fixedExpand||A.value?{text:"",value:"expand",fixed:!0,width:a.expandColumnWidth}:{text:"",value:"expand"},...l]:t=l;let s=[];a.showIndex?s=[a.fixedIndex||A.value?{text:"#",value:"index",fixed:!0,width:a.indexColumnWidth}:{text:"#",value:"index"},...t]:s=t;let c=[];return k.value?c=[a.fixedCheckbox||A.value?{text:"checkbox",value:"checkbox",fixed:!0,width:(g=a.checkboxColumnWidth)!=null?g:36}:{text:"checkbox",value:"checkbox"},...s]:c=s,c}),R=e.ref([]),tt=(n,l,t)=>{t.stopPropagation();const s=R.value.indexOf(n);s!==-1?R.value.splice(s,1):(r("expandRow",a.items.findIndex(c=>c===l)),R.value.push(n))},I=e.computed(()=>F.value.filter(n=>n.fixed)),Q=e.computed(()=>I.value.length?I.value[I.value.length-1].value:""),nt=n=>{var t;const l=(t=n.width)!=null?t:I.value.length?100:null;if(l)return`width: ${l}px; min-width: ${l}px;`},at=e.computed(()=>{if(!I.value.length)return[];const n=I.value.map(l=>{var t;return(t=l.width)!=null?t:100});return I.value.map((l,t)=>{var s,c;return{value:l.value,fixed:(s=l.fixed)!=null?s:!0,width:(c=l.width)!=null?c:100,distance:t===0?0:n.reduce((g,N,L)=>{let ie=g;return L<t&&(ie+=N),ie})}})}),X=(n,l="th")=>{if(!I.value.length)return;const t=at.value.find(s=>s.value===n);if(t)return`left: ${t.distance}px;z-index: ${l==="th"?3:1};position: sticky;`},Y=e.computed(()=>F.value.map(n=>n.value)),z=(n,l)=>{if(n.includes(".")){let t="";return n.split(".").forEach((c,g)=>{t=g===0?l[c]:t[c]}),t}return l[n]},ot=(n,l)=>{const t=z(n,l);return Array.isArray(t)?t.join(","):t},P=e.computed({get:()=>{var n;return(n=a.itemsSelected)!=null?n:[]},set:n=>{r("update:itemsSelected",n)}}),Z=e.computed(()=>{if(!C.value&&a.searchValue!==""){const n=new RegExp(a.searchValue,"i");return a.items.filter(l=>n.test(a.searchField!==""?l[a.searchField]:Object.values(l).join(" ")))}return a.items}),V=e.computed(()=>{let n=[...Z.value];return a.filterOptions?(a.filterOptions.forEach(l=>{n=n.filter(t=>{const{field:s,comparison:c,criteria:g}=l;switch(c){case"=":return t[s]===g;case"!=":return t[s]!==g;case">":return t[s]>g;case"<":return t[s]<g;case"<=":return t[s]<=g;case">=":return t[s]>=g;case"between":return t[s]>=Math.min(...g)&&t[s]<=Math.max(...g);default:return t[s]===g}})}),n):Z.value}),D=e.computed(()=>P.value.length===0||P.value.every(l=>V.value.findIndex(t=>JSON.stringify(l)===JSON.stringify(t))===-1)?"noneSelected":P.value.length===V.value.length&&P.value.every(t=>V.value.findIndex(s=>JSON.stringify(t)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),_=e.ref(C.value?a.serverOptions.page:1),{items:ee}=e.toRefs(a);e.watch(ee,()=>{C.value||(_.value=1)},{deep:!0});const $=e.ref(C.value?a.serverOptions.rowsPerPage:a.rowsPerPage);e.watch($,n=>{d.value&&(d.value=O(S({},d.value),{page:1,rowsPerPage:n})),_.value=1});const lt=(n,l)=>{let t=null;l==="none"?t="asc":l==="asc"?t="desc":t=a.mustSort?"asc":null,d.value?d.value=O(S({},d.value),{sortBy:t!==null?n:null,sortType:t}):t===null?E.value=null:E.value={sortBy:n,sortDesc:t==="desc"}},te=e.computed(()=>{if(C.value)return a.items;if(E.value===null)return V.value;const{sortBy:n,sortDesc:l}=E.value;return[...V.value].sort((s,c)=>z(n,s)<z(n,c)?l?1:-1:z(n,s)>z(n,c)?l?-1:1:0)}),v=e.computed(()=>C.value?a.serverItemsLength:V.value.length),ne=e.computed(()=>C.value?_.value*$.value:Math.min(V.value.length,_.value*$.value)),ae=e.computed(()=>(_.value-1)*$.value+1),M=e.computed(()=>Math.ceil(v.value/$.value)),j=e.computed(()=>_.value===M.value),q=e.computed(()=>_.value===1),{loading:T}=e.toRefs(a),J=()=>{if(!j.value&&!T.value)if(d.value){const n=_.value+1;d.value=O(S({},d.value),{page:n})}else _.value+=1},U=()=>{if(!q.value&&!T.value)if(d.value){const n=_.value-1;d.value=O(S({},d.value),{page:n})}else _.value-=1},oe=n=>{T.value||(d.value?d.value=O(S({},d.value),{page:n}):_.value=n)};e.watch(T,(n,l)=>{d.value&&n===!1&&l===!0&&(_.value=d.value.page)});const le=e.computed(()=>C.value?a.items:te.value.slice(ae.value-1,ne.value)),se=e.computed(()=>$.value*(_.value-1)+1),st=e.computed(()=>$.value*_.value),W=e.computed(()=>a.showIndex?le.value.map((n,l)=>S({index:se.value+l},n)):le.value),re=e.computed(()=>k.value?D.value==="allSelected"?W.value.map(n=>S({checkbox:!0},n)):D.value==="noneSelected"?W.value.map(n=>S({checkbox:!1},n)):W.value.map(n=>{const l=P.value.findIndex(t=>{const s=S({},n);return delete s.index,JSON.stringify(t)===JSON.stringify(s)})!==-1;return S({checkbox:l},n)}):W.value),rt=n=>{P.value=n?te.value:[]},it=n=>{const l=n.checkbox;if(delete n.checkbox,delete n.index,l)P.value=P.value.filter(t=>JSON.stringify(t)!==JSON.stringify(n));else{const t=P.value;t.unshift(n),P.value=t}},ct=n=>{const l=S({},n);if(k.value){const{checkbox:t}=n;delete l.checkbox,l.isSelected=t}if(a.showIndex){const{index:t}=n;delete l.index,l.indexInCurrentPage=t}r("clickRow",l)};return h({clientItemsLength:v,currentPageFirstIndex:se,currentPageLastIndex:st,maxPaginationNumber:M,currentPaginationNumber:_,isLastPage:j,isFirstPage:q,nextPage:J,prevPage:U,updatePage:oe}),(n,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:p,class:e.normalizeClass(["vue3-easy-data-table",[o.tableClassName]])},[e.createElementVNode("div",{ref_key:"tableBody",ref:B,class:e.normalizeClass(["vue3-easy-data-table__main",{"fixed-header":o.fixedHeader,"fixed-height":o.tableHeight,"show-shadow":b.value,"table-fixed":e.unref(I).length,hoverable:!o.noHover,"border-cell":o.borderCell}])},[e.createElementVNode("table",null,[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(t,s)=>(e.openBlock(),e.createElementBlock("col",{key:s,style:e.normalizeStyle(nt(t))},null,4))),128))]),e.unref(F).length&&!o.hideHeader?(e.openBlock(),e.createElementBlock("thead",{key:0,class:e.normalizeClass(["vue3-easy-data-table__header",[o.headerClassName]])},[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(t,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass([{sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",shadow:t.value===e.unref(Q)},typeof o.headerItemClassName=="string"?o.headerItemClassName:o.headerItemClassName(t,s)]),style:e.normalizeStyle(X(t.value)),onClick:e.withModifiers(c=>t.sortable&&t.sortType?lt(t.value,t.sortType):null,["stop"])},[t.text==="checkbox"?(e.openBlock(),e.createBlock(ge,{key:e.unref(D),status:e.unref(D),onChange:rt},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ae,[e.unref(x)[`header-${t.value}`]?e.renderSlot(n.$slots,`header-${t.value}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):(e.openBlock(),e.createElementBlock("span",De,e.toDisplayString(t.text),1)),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,He))),128))])],2)):e.createCommentVNode("",!0),e.unref(ee).length&&e.unref(Y).length?(e.openBlock(),e.createElementBlock("tbody",{key:1,class:e.normalizeClass(["vue3-easy-data-table__body",{"row-alternation":o.alternating}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(re),(t,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s},[e.createElementVNode("tr",{class:e.normalizeClass([{"even-row":(s+1)%2===0},typeof o.bodyRowClassName=="string"?o.bodyRowClassName:o.bodyRowClassName(t,s)]),onClick:c=>ct(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Y),(c,g)=>(e.openBlock(),e.createElementBlock("td",{key:g,style:e.normalizeStyle(X(c,"td")),class:e.normalizeClass([{shadow:c===e.unref(Q),"can-expand":c==="expand"},typeof o.bodyItemClassName=="string"?o.bodyItemClassName:o.bodyItemClassName(c,g)]),onClick:N=>c==="expand"?tt(s,t,N):null},[e.unref(x)[`item-${c}`]?e.renderSlot(n.$slots,`item-${c}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):c==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:R.value.includes(s)}])},null,2)):c==="checkbox"?(e.openBlock(),e.createBlock(ke,{key:2,checked:t[c],onChange:N=>it(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(ot(c,t)),1)],64))],14,je))),128))],10,Me),e.unref(i)&&R.value.includes(s)?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(s+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(F).length,class:"expand"},[t.expandLoading?(e.openBlock(),e.createBlock(Ee,{key:0,class:"expand-loading"})):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"expand",e.normalizeProps(e.guardReactiveProps(t)),void 0,!0)],8,qe)],2)):e.createCommentVNode("",!0)],64))),128))],2)):e.createCommentVNode("",!0)]),e.unref(T)?(e.openBlock(),e.createElementBlock("div",We,[ve,e.createElementVNode("div",Je,[e.unref(u)?e.renderSlot(n.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Ie,{key:1}))])])):e.createCommentVNode("",!0),!e.unref(re).length&&!e.unref(T)?(e.openBlock(),e.createElementBlock("div",Ue,e.toDisplayString(o.emptyMessage),1)):e.createCommentVNode("",!0)],2),o.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ge,[o.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ke,[e.createTextVNode(e.toDisplayString(o.rowsPerPageMessage)+" ",1),e.createVNode(Be,{modelValue:$.value,"onUpdate:modelValue":l[0]||(l[0]=t=>$.value=t),"rows-items":e.unref(Xe)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",Qe,e.toDisplayString(`${e.unref(ae)}-${e.unref(ne)}`)+" of "+e.toDisplayString(e.unref(v)),1),e.unref(w)?e.renderSlot(n.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(q),isLastPage:e.unref(j),currentPaginationNumber:_.value,maxPaginationNumber:e.unref(M),nextPage:J,prevPage:U})),void 0,!0):(e.openBlock(),e.createBlock(Re,{key:2,"is-first-page":e.unref(q),"is-last-page":e.unref(j),onClickNextPage:J,onClickPrevPage:U},e.createSlots({_:2},[o.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Te,{"current-pagination-number":_.value,"max-pagination-number":e.unref(M),onUpdatePage:oe},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],2))}}),[["__scopeId","data-v-70716fde"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",K),K}); | ||
(function(e,y){typeof exports=="object"&&typeof module!="undefined"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=y(e.Vue))})(this,function(e){"use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var de=(e,y,m)=>y in e?dt(e,y,{enumerable:!0,configurable:!0,writable:!0,value:m}):e[y]=m,S=(e,y)=>{for(var m in y||(y={}))mt.call(y,m)&&de(e,m,y[m]);if(ce)for(var m of ce(y))ft.call(y,m)&&de(e,m,y[m]);return e},O=(e,y)=>ut(e,pt(y));var y="",m=(o,h)=>{const r=o.__vccOpts||o;for(const[a,f]of h)r[a]=f;return r};const ue=o=>(e.pushScopeId("data-v-566775ba"),o=o(),e.popScopeId(),o),pe=["onClick"],me=["checked"],fe=ue(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ge=m(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(o,{emit:h}){const r=o;e.useCssVars(w=>({"7f84b28f":e.unref(x)}));const a=e.computed(()=>r.status==="allSelected"),f=()=>{h("change",!a.value)},x=e.inject("themeColor");return(w,u)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(f,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(a),class:e.normalizeClass(o.status)},null,10,me),fe],8,pe))}}),[["__scopeId","data-v-566775ba"]]),ht="";const he=o=>(e.pushScopeId("data-v-39f156fd"),o=o(),e.popScopeId(),o),_e=["checked"],ye=he(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ke=m(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(o,{emit:h}){e.useCssVars(a=>({"20cfc5a0":e.unref(r)}));const r=e.inject("themeColor");return(a,f)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:f[0]||(f[0]=e.withModifiers(x=>h("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:o.checked},null,8,_e),ye]))}}),[["__scopeId","data-v-39f156fd"]]),yt="";const xe=o=>(e.pushScopeId("data-v-384d1036"),o=o(),e.popScopeId(),o),be={class:"easy-data-table__rows-selector"},Ce={class:"rows-input"},Ne=xe(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Se=["onClick"];var Be=m(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(o,{emit:h}){const r=o;e.useCssVars(b=>({"40595ee7":e.unref(B)}));const a=e.ref(!1),f=e.ref(!1),x=e.inject("dataTable");e.watch(a,b=>{if(b&&x){const d=window.innerHeight,k=x.value.getBoundingClientRect().height,C=x.value.getBoundingClientRect().top;d-(k+C)<=100?f.value=!0:f.value=!1}});const w=e.computed({get:()=>r.modelValue,set:b=>{h("update:modelValue",b)}}),u=b=>{w.value=b,a.value=!1},i=(b,d)=>{let k=b.parentNode;for(;k!=null;){if(k.classList&&k.classList.contains(d))return!0;k=k.parentNode}return!1},p=b=>{i(b.target,"easy-data-table__rows-selector")||(a.value=!1)};e.onMounted(()=>{document.addEventListener("click",p)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",p)});const B=e.inject("themeColor");return(b,d)=>(e.openBlock(),e.createElementBlock("div",be,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:d[0]||(d[0]=k=>a.value=!a.value)},[e.createElementVNode("div",Ce,e.toDisplayString(e.unref(w)),1),Ne]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:a.value,inside:f.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.rowsItems,k=>(e.openBlock(),e.createElementBlock("li",{key:k,class:e.normalizeClass({selected:k===e.unref(w)}),onClick:C=>u(k)},e.toDisplayString(k),11,Se))),128))],2)]))}}),[["__scopeId","data-v-384d1036"]]),xt="";const H=o=>(e.pushScopeId("data-v-1fa3a520"),o=o(),e.popScopeId(),o),Pe={class:"lds-ring"},we=[H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1)),H(()=>e.createElementVNode("div",null,null,-1))];var Ie=m(e.defineComponent({setup(o){e.useCssVars(r=>({"26774109":e.unref(h)}));const h=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",Pe,we))}}),[["__scopeId","data-v-1fa3a520"]]),Pt="";const $e={class:"loader-line"};var Ee=m(e.defineComponent({setup(o){e.useCssVars(r=>({"0d327f57":e.unref(h)}));const h=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",$e))}}),[["__scopeId","data-v-7d281cac"]]),It="";const Ve={class:"buttons-pagination"},Fe=["onClick"];var Te=m(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(o,{emit:h}){const r=o;e.useCssVars(u=>({"5c478b08":e.unref(w)}));const a=7,f=u=>{u.type==="button"&&!u.active&&h("updatePage",u.page)},x=e.computed(()=>{const u=[];if(r.maxPaginationNumber<=a)for(let i=1;i<=r.maxPaginationNumber;i+=1)u.push({type:"button",page:i,active:i===r.currentPaginationNumber});else if([1,2,r.maxPaginationNumber,r.maxPaginationNumber-1].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)if(i<=3)u.push({type:"button",page:i,active:i===r.currentPaginationNumber});else if(i===4)u.push({type:"omission"});else{const p=r.maxPaginationNumber-(a-i);u.push({type:"button",page:p,active:p===r.currentPaginationNumber})}else if([3,4].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)i<=5?u.push({type:"button",page:i,active:i===r.currentPaginationNumber}):i===6?u.push({type:"omission"}):u.push({type:"button",page:r.maxPaginationNumber,active:r.maxPaginationNumber===r.currentPaginationNumber});else if([r.maxPaginationNumber-2,r.maxPaginationNumber-3].includes(r.currentPaginationNumber))for(let i=1;i<=a;i+=1)if(i===1)u.push({type:"button",page:1,active:r.currentPaginationNumber===1});else if(i===2)u.push({type:"omission"});else{const p=r.maxPaginationNumber-(a-i);u.push({type:"button",page:p,active:p===r.currentPaginationNumber})}else for(let i=1;i<=a;i+=1)if(i===1)u.push({type:"button",page:1,active:r.currentPaginationNumber===1});else if(i===2||i===6)u.push({type:"omission"});else if(i===7)u.push({type:"button",page:r.maxPaginationNumber,active:r.maxPaginationNumber===r.currentPaginationNumber});else{const p=4-i,B=r.currentPaginationNumber-p;u.push({type:"button",page:B,active:B===r.currentPaginationNumber})}return u}),w=e.inject("themeColor");return(u,i)=>(e.openBlock(),e.createElementBlock("div",Ve,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(x),(p,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:e.normalizeClass(["item",{button:p.type==="button",active:p.type==="button"&&p.active,omission:p.type==="omission"}]),onClick:b=>f(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,Fe))),128))]))}}),[["__scopeId","data-v-0e334da4"]]),Et="";const G=o=>(e.pushScopeId("data-v-c9da5286"),o=o(),e.popScopeId(),o),Le=[G(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],Oe=[G(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Re=m(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(o,{emit:h}){const r=e.useSlots();return(a,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":o.isFirstPage}]),onClick:f[0]||(f[0]=x=>h("clickPrevPage"))},Le,2),e.unref(r).buttonsPagination?e.renderSlot(a.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":o.isLastPage}]),onClick:f[1]||(f[1]=x=>h("clickNextPage"))},Oe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),Lt="",Ot="";const ze=o=>(e.pushScopeId("data-v-870aca6c"),o=o(),e.popScopeId(),o),He=["onClick"],Ae={key:1,class:"header"},De={key:1,class:"header-text"},Me=["onClick"],je=["onClick"],qe=["colspan"],ve={key:0,class:"vue3-easy-data-table__loading"},We=ze(()=>e.createElementVNode("div",{class:"vue3-easy-data-table__loading-mask"},null,-1)),Je={class:"loading-entity"},Ue={key:1,class:"vue3-easy-data-table__message"},Ge={key:0,class:"vue3-easy-data-table__footer"},Ke={key:0,class:"pagination__rows-per-page"},Qe={class:"pagination__items-index"};var K=m(e.defineComponent({props:{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},headers:{type:Array,required:!0},hideFooter:{type:Boolean,default:!1},hideRowsPerPage:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},items:{type:Array,required:!0},itemsSelected:{type:Array,default:null},loading:{type:Boolean,deault:!1},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowsPerPageMessage:{type:String,default:"rows per page:"},searchField:{type:String,default:""},searchValue:{type:String,default:""},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},showIndex:{type:Boolean,default:!1},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},tableHeight:{type:Number,default:null},themeColor:{type:String,default:"#42b883"},tableClassName:{type:String,default:""},headerClassName:{type:String,default:""},headerItemClassName:{type:[Function,String],default:""},bodyRowClassName:{type:[Function,String],default:""},bodyItemClassName:{type:[Function,String],default:""},noHover:{type:Boolean,default:!1},borderCell:{type:Boolean,default:!1},mustSort:{type:Boolean,default:!1}},emits:["update:itemsSelected","update:serverOptions","clickRow","expandRow"],setup(o,{expose:h,emit:r}){const a=o;e.useCssVars(n=>({"2a5ec828":e.unref(f)}));const f=e.computed(()=>a.tableHeight?`${a.tableHeight}px`:null);e.provide("themeColor",a.themeColor);const x=e.useSlots(),w=e.computed(()=>x.pagination),u=e.computed(()=>x.loading),i=e.computed(()=>x.expand),p=e.ref(),B=e.ref();e.provide("dataTable",p);const b=e.ref(!1);e.onMounted(()=>{B.value.addEventListener("scroll",()=>{b.value=B.value.scrollLeft>0})});const d=e.computed({get:()=>{if(a.serverOptions){const{page:n,rowsPerPage:l,sortBy:t,sortType:s}=a.serverOptions;return{page:n,rowsPerPage:l,sortBy:t!=null?t:null,sortType:s!=null?s:null}}return null},set:n=>{r("update:serverOptions",n)}}),k=e.computed(()=>a.itemsSelected!==null),C=e.computed(()=>d.value!==null),Xe=e.computed(()=>!C.value&&a.rowsItems.findIndex(n=>n===a.rowsPerPage)===-1?[a.rowsPerPage,...a.rowsItems]:a.rowsItems),Ye=()=>a.sortBy!==""?{sortBy:a.sortBy,sortDesc:a.sortType==="desc"}:null,E=e.ref(Ye()),A=e.computed(()=>a.headers.findIndex(n=>n.fixed)!==-1),Ze=e.computed(()=>A.value?a.headers.filter(n=>n.fixed):[]),et=e.computed(()=>a.headers.filter(n=>!n.fixed)),F=e.computed(()=>{var g;const l=[...Ze.value,...et.value].map(N=>{const L=N;return N.sortable&&(L.sortType="none"),d.value&&N.value===d.value.sortBy&&d.value.sortType&&(L.sortType=d.value.sortType),!C.value&&E.value&&N.value===E.value.sortBy&&(L.sortType=E.value.sortDesc?"desc":"asc"),L});let t=[];i.value?t=[a.fixedExpand||A.value?{text:"",value:"expand",fixed:!0,width:a.expandColumnWidth}:{text:"",value:"expand"},...l]:t=l;let s=[];a.showIndex?s=[a.fixedIndex||A.value?{text:"#",value:"index",fixed:!0,width:a.indexColumnWidth}:{text:"#",value:"index"},...t]:s=t;let c=[];return k.value?c=[a.fixedCheckbox||A.value?{text:"checkbox",value:"checkbox",fixed:!0,width:(g=a.checkboxColumnWidth)!=null?g:36}:{text:"checkbox",value:"checkbox"},...s]:c=s,c}),R=e.ref([]),tt=(n,l,t)=>{t.stopPropagation();const s=R.value.indexOf(n);s!==-1?R.value.splice(s,1):(r("expandRow",a.items.findIndex(c=>c===l)),R.value.push(n))},I=e.computed(()=>F.value.filter(n=>n.fixed)),Q=e.computed(()=>I.value.length?I.value[I.value.length-1].value:""),nt=n=>{var t;const l=(t=n.width)!=null?t:I.value.length?100:null;if(l)return`width: ${l}px; min-width: ${l}px;`},at=e.computed(()=>{if(!I.value.length)return[];const n=I.value.map(l=>{var t;return(t=l.width)!=null?t:100});return I.value.map((l,t)=>{var s,c;return{value:l.value,fixed:(s=l.fixed)!=null?s:!0,width:(c=l.width)!=null?c:100,distance:t===0?0:n.reduce((g,N,L)=>{let ie=g;return L<t&&(ie+=N),ie})}})}),X=(n,l="th")=>{if(!I.value.length)return;const t=at.value.find(s=>s.value===n);if(t)return`left: ${t.distance}px;z-index: ${l==="th"?3:1};position: sticky;`},Y=e.computed(()=>F.value.map(n=>n.value)),z=(n,l)=>{if(n.includes(".")){let t="";return n.split(".").forEach((c,g)=>{t=g===0?l[c]:t[c]}),t}return l[n]},ot=(n,l)=>{const t=z(n,l);return Array.isArray(t)?t.join(","):t},P=e.computed({get:()=>{var n;return(n=a.itemsSelected)!=null?n:[]},set:n=>{r("update:itemsSelected",n)}}),Z=e.computed(()=>{if(!C.value&&a.searchValue!==""){const n=new RegExp(a.searchValue,"i");return a.items.filter(l=>n.test(a.searchField!==""?l[a.searchField]:Object.values(l).join(" ")))}return a.items}),V=e.computed(()=>{let n=[...Z.value];return a.filterOptions?(a.filterOptions.forEach(l=>{n=n.filter(t=>{const{field:s,comparison:c,criteria:g}=l;switch(c){case"=":return t[s]===g;case"!=":return t[s]!==g;case">":return t[s]>g;case"<":return t[s]<g;case"<=":return t[s]<=g;case">=":return t[s]>=g;case"between":return t[s]>=Math.min(...g)&&t[s]<=Math.max(...g);default:return t[s]===g}})}),n):Z.value}),D=e.computed(()=>P.value.length===0||P.value.every(l=>V.value.findIndex(t=>JSON.stringify(l)===JSON.stringify(t))===-1)?"noneSelected":P.value.length===V.value.length&&P.value.every(t=>V.value.findIndex(s=>JSON.stringify(t)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),_=e.ref(C.value?a.serverOptions.page:1),{items:ee}=e.toRefs(a);e.watch(ee,()=>{C.value||(_.value=1)},{deep:!0});const $=e.ref(C.value?a.serverOptions.rowsPerPage:a.rowsPerPage);e.watch($,n=>{d.value&&(d.value=O(S({},d.value),{page:1,rowsPerPage:n})),_.value=1});const lt=(n,l)=>{let t=null;l==="none"?t="asc":l==="asc"?t="desc":t=a.mustSort?"asc":null,d.value?d.value=O(S({},d.value),{sortBy:t!==null?n:null,sortType:t}):t===null?E.value=null:E.value={sortBy:n,sortDesc:t==="desc"}},te=e.computed(()=>{if(C.value)return a.items;if(E.value===null)return V.value;const{sortBy:n,sortDesc:l}=E.value;return[...V.value].sort((s,c)=>z(n,s)<z(n,c)?l?1:-1:z(n,s)>z(n,c)?l?-1:1:0)}),M=e.computed(()=>C.value?a.serverItemsLength:V.value.length),ne=e.computed(()=>C.value?Math.min(M.value,_.value*$.value):Math.min(V.value.length,_.value*$.value)),ae=e.computed(()=>(_.value-1)*$.value+1),j=e.computed(()=>Math.ceil(M.value/$.value)),q=e.computed(()=>_.value===j.value),v=e.computed(()=>_.value===1),{loading:T}=e.toRefs(a),J=()=>{if(!q.value&&!T.value)if(d.value){const n=_.value+1;d.value=O(S({},d.value),{page:n})}else _.value+=1},U=()=>{if(!v.value&&!T.value)if(d.value){const n=_.value-1;d.value=O(S({},d.value),{page:n})}else _.value-=1},oe=n=>{T.value||(d.value?d.value=O(S({},d.value),{page:n}):_.value=n)};e.watch(T,(n,l)=>{d.value&&n===!1&&l===!0&&(_.value=d.value.page)});const le=e.computed(()=>C.value?a.items:te.value.slice(ae.value-1,ne.value)),se=e.computed(()=>$.value*(_.value-1)+1),st=e.computed(()=>$.value*_.value),W=e.computed(()=>a.showIndex?le.value.map((n,l)=>S({index:se.value+l},n)):le.value),re=e.computed(()=>k.value?D.value==="allSelected"?W.value.map(n=>S({checkbox:!0},n)):D.value==="noneSelected"?W.value.map(n=>S({checkbox:!1},n)):W.value.map(n=>{const l=P.value.findIndex(t=>{const s=S({},n);return delete s.index,JSON.stringify(t)===JSON.stringify(s)})!==-1;return S({checkbox:l},n)}):W.value),rt=n=>{P.value=n?te.value:[]},it=n=>{const l=n.checkbox;if(delete n.checkbox,delete n.index,l)P.value=P.value.filter(t=>JSON.stringify(t)!==JSON.stringify(n));else{const t=P.value;t.unshift(n),P.value=t}},ct=n=>{const l=S({},n);if(k.value){const{checkbox:t}=n;delete l.checkbox,l.isSelected=t}if(a.showIndex){const{index:t}=n;delete l.index,l.indexInCurrentPage=t}r("clickRow",l)};return h({clientItemsLength:M,currentPageFirstIndex:se,currentPageLastIndex:st,maxPaginationNumber:j,currentPaginationNumber:_,isLastPage:q,isFirstPage:v,nextPage:J,prevPage:U,updatePage:oe}),(n,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:p,class:e.normalizeClass(["vue3-easy-data-table",[o.tableClassName]])},[e.createElementVNode("div",{ref_key:"tableBody",ref:B,class:e.normalizeClass(["vue3-easy-data-table__main",{"fixed-header":o.fixedHeader,"fixed-height":o.tableHeight,"show-shadow":b.value,"table-fixed":e.unref(I).length,hoverable:!o.noHover,"border-cell":o.borderCell}])},[e.createElementVNode("table",null,[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(t,s)=>(e.openBlock(),e.createElementBlock("col",{key:s,style:e.normalizeStyle(nt(t))},null,4))),128))]),e.unref(F).length&&!o.hideHeader?(e.openBlock(),e.createElementBlock("thead",{key:0,class:e.normalizeClass(["vue3-easy-data-table__header",[o.headerClassName]])},[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(t,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass([{sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",shadow:t.value===e.unref(Q)},typeof o.headerItemClassName=="string"?o.headerItemClassName:o.headerItemClassName(t,s)]),style:e.normalizeStyle(X(t.value)),onClick:e.withModifiers(c=>t.sortable&&t.sortType?lt(t.value,t.sortType):null,["stop"])},[t.text==="checkbox"?(e.openBlock(),e.createBlock(ge,{key:e.unref(D),status:e.unref(D),onChange:rt},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ae,[e.unref(x)[`header-${t.value}`]?e.renderSlot(n.$slots,`header-${t.value}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):(e.openBlock(),e.createElementBlock("span",De,e.toDisplayString(t.text),1)),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,He))),128))])],2)):e.createCommentVNode("",!0),e.unref(ee).length&&e.unref(Y).length?(e.openBlock(),e.createElementBlock("tbody",{key:1,class:e.normalizeClass(["vue3-easy-data-table__body",{"row-alternation":o.alternating}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(re),(t,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s},[e.createElementVNode("tr",{class:e.normalizeClass([{"even-row":(s+1)%2===0},typeof o.bodyRowClassName=="string"?o.bodyRowClassName:o.bodyRowClassName(t,s)]),onClick:c=>ct(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Y),(c,g)=>(e.openBlock(),e.createElementBlock("td",{key:g,style:e.normalizeStyle(X(c,"td")),class:e.normalizeClass([{shadow:c===e.unref(Q),"can-expand":c==="expand"},typeof o.bodyItemClassName=="string"?o.bodyItemClassName:o.bodyItemClassName(c,g)]),onClick:N=>c==="expand"?tt(s,t,N):null},[e.unref(x)[`item-${c}`]?e.renderSlot(n.$slots,`item-${c}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):c==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:R.value.includes(s)}])},null,2)):c==="checkbox"?(e.openBlock(),e.createBlock(ke,{key:2,checked:t[c],onChange:N=>it(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(ot(c,t)),1)],64))],14,je))),128))],10,Me),e.unref(i)&&R.value.includes(s)?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(s+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(F).length,class:"expand"},[t.expandLoading?(e.openBlock(),e.createBlock(Ee,{key:0,class:"expand-loading"})):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"expand",e.normalizeProps(e.guardReactiveProps(t)),void 0,!0)],8,qe)],2)):e.createCommentVNode("",!0)],64))),128))],2)):e.createCommentVNode("",!0)]),e.unref(T)?(e.openBlock(),e.createElementBlock("div",ve,[We,e.createElementVNode("div",Je,[e.unref(u)?e.renderSlot(n.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Ie,{key:1}))])])):e.createCommentVNode("",!0),!e.unref(re).length&&!e.unref(T)?(e.openBlock(),e.createElementBlock("div",Ue,e.toDisplayString(o.emptyMessage),1)):e.createCommentVNode("",!0)],2),o.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ge,[o.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ke,[e.createTextVNode(e.toDisplayString(o.rowsPerPageMessage)+" ",1),e.createVNode(Be,{modelValue:$.value,"onUpdate:modelValue":l[0]||(l[0]=t=>$.value=t),"rows-items":e.unref(Xe)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",Qe,e.toDisplayString(`${e.unref(ae)}\u2013${e.unref(ne)}`)+" of "+e.toDisplayString(e.unref(M)),1),e.unref(w)?e.renderSlot(n.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(v),isLastPage:e.unref(q),currentPaginationNumber:_.value,maxPaginationNumber:e.unref(j),nextPage:J,prevPage:U})),void 0,!0):(e.openBlock(),e.createBlock(Re,{key:2,"is-first-page":e.unref(v),"is-last-page":e.unref(q),onClickNextPage:J,onClickPrevPage:U},e.createSlots({_:2},[o.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(Te,{"current-pagination-number":_.value,"max-pagination-number":e.unref(j),onUpdatePage:oe},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],2))}}),[["__scopeId","data-v-870aca6c"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",K),K}); |
@@ -6,3 +6,3 @@ { | ||
"private": false, | ||
"version": "1.3.14", | ||
"version": "1.3.15", | ||
"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
92710