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