vue3-easy-data-table
Advanced tools
Comparing version 1.4.6 to 1.4.7
@@ -34,3 +34,2 @@ var __defProp = Object.defineProperty; | ||
const _sfc_main$7 = /* @__PURE__ */ defineComponent({ | ||
__name: "MultipleSelectCheckBox", | ||
props: { | ||
@@ -71,3 +70,2 @@ status: { type: String, required: true } | ||
const _sfc_main$6 = /* @__PURE__ */ defineComponent({ | ||
__name: "SingleSelectCheckBox", | ||
props: { | ||
@@ -104,3 +102,2 @@ checked: { type: Boolean, required: true } | ||
const _sfc_main$5 = /* @__PURE__ */ defineComponent({ | ||
__name: "RowsSelector", | ||
props: { | ||
@@ -201,3 +198,2 @@ modelValue: { type: Number, required: true }, | ||
const _sfc_main$4 = /* @__PURE__ */ defineComponent({ | ||
__name: "Loading", | ||
setup(__props) { | ||
@@ -217,3 +213,2 @@ useCssVars((_ctx) => ({ | ||
const _sfc_main$3 = /* @__PURE__ */ defineComponent({ | ||
__name: "LoadingLine", | ||
setup(__props) { | ||
@@ -234,3 +229,2 @@ useCssVars((_ctx) => ({ | ||
const _sfc_main$2 = /* @__PURE__ */ defineComponent({ | ||
__name: "ButtonsPagination", | ||
props: { | ||
@@ -395,3 +389,2 @@ maxPaginationNumber: { type: Number, required: true }, | ||
const _sfc_main$1 = /* @__PURE__ */ defineComponent({ | ||
__name: "PaginationArrows", | ||
props: { | ||
@@ -451,9 +444,5 @@ isFirstPage: { type: Boolean, required: false }, | ||
}; | ||
const clearExpandingItemIndexList = () => { | ||
expandingItemIndexList.value = []; | ||
}; | ||
return { | ||
expandingItemIndexList, | ||
updateExpandingItemIndexList, | ||
clearExpandingItemIndexList | ||
updateExpandingItemIndexList | ||
}; | ||
@@ -1034,3 +1023,3 @@ } | ||
var DataTable_vue_vue_type_style_index_1_scoped_true_lang = ""; | ||
const _withScopeId = (n) => (pushScopeId("data-v-6a78109a"), n = n(), popScopeId(), n); | ||
const _withScopeId = (n) => (pushScopeId("data-v-03d72812"), n = n(), popScopeId(), n); | ||
const _hoisted_1 = ["onClick"]; | ||
@@ -1068,3 +1057,2 @@ const _hoisted_2 = { | ||
const _sfc_main = /* @__PURE__ */ defineComponent({ | ||
__name: "DataTable", | ||
props: __spreadProps(__spreadValues({}, propsWithDefault), { | ||
@@ -1089,3 +1077,3 @@ items: { | ||
useCssVars((_ctx) => ({ | ||
"52352974": unref(tableHeightPx) | ||
"3edcb22c": unref(tableHeightPx) | ||
})); | ||
@@ -1176,4 +1164,3 @@ const { | ||
expandingItemIndexList, | ||
updateExpandingItemIndexList, | ||
clearExpandingItemIndexList | ||
updateExpandingItemIndexList | ||
} = useExpandableRow(items, emits); | ||
@@ -1222,5 +1209,2 @@ const { | ||
}); | ||
watch(pageItems, () => { | ||
clearExpandingItemIndexList(); | ||
}, { deep: true }); | ||
expose({ | ||
@@ -1401,3 +1385,3 @@ currentPageFirstIndex, | ||
}); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6a78109a"]]); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-03d72812"]]); | ||
if (typeof window !== "undefined" && window.Vue) { | ||
@@ -1404,0 +1388,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 Rt=Object.defineProperty,zt=Object.defineProperties;var At=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var be=(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={}))Dt.call(C,b)&&be(e,b,C[b]);if(ke)for(var b of ke(C))Ht.call(C,b)&&be(e,b,C[b]);return e},j=(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 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({__name:"MultipleSelectCheckBox",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,Ce),Ne],8,Pe))}}),[["__scopeId","data-v-e0a0b7f0"]]),Mt="";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({__name:"SingleSelectCheckBox",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,we),Ie]))}}),[["__scopeId","data-v-7e69a276"]]),Wt="";const $e=n=>(e.pushScopeId("data-v-384d1036"),n=n(),e.popScopeId(),n),Ve={class:"easy-data-table__rows-selector"},ve={class:"rows-input"},Le=$e(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),Fe=["onClick"];var Te=b(e.defineComponent({__name:"RowsSelector",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",ve,e.toDisplayString(e.unref(l)),1),Le]),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,Fe))),128))],2)]))}}),[["__scopeId","data-v-384d1036"]]),Jt="";const W=n=>(e.pushScopeId("data-v-1fa3a520"),n=n(),e.popScopeId(),n),Re={class:"lds-ring"},ze=[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 Ae=b(e.defineComponent({__name:"Loading",setup(n){e.useCssVars(t=>({"26774109":e.unref(o)}));const o=e.inject("themeColor");return(t,i)=>(e.openBlock(),e.createElementBlock("div",Re,ze))}}),[["__scopeId","data-v-1fa3a520"]]),Yt="";const De={class:"loader-line"};var He=b(e.defineComponent({__name:"LoadingLine",setup(n){e.useCssVars(t=>({"0d327f57":e.unref(o)}));const o=e.inject("themeColor");return(t,i)=>(e.openBlock(),e.createElementBlock("div",De))}}),[["__scopeId","data-v-7d281cac"]]),en="";const Oe={class:"buttons-pagination"},Me=["onClick"];var je=b(e.defineComponent({__name:"ButtonsPagination",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",Oe,[(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 le=n=>(e.pushScopeId("data-v-c9da5286"),n=n(),e.popScopeId(),n),We=[le(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],qe=[le(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Je=b(e.defineComponent({__name:"PaginationArrows",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"))},We,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"))},qe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);function Ue(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 Ge(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 Ke(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 Qe(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):[]),_=e.computed(()=>r.value.filter(S=>!S.fixed)),h=e.ref((()=>f.value!==""?{sortBy:f.value,sortDesc:x.value==="desc"}:null)()),V=e.computed(()=>{var q;const T=[...P.value,..._.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&&h.value&&E.value===h.value.sortBy&&(z.sortType=h.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 O=[];return a.value?O=[t.value||p.value?{text:"checkbox",value:"checkbox",fixed:!0,width:(q=n.value)!=null?q:36}:{text:"checkbox",value:"checkbox"},...F]:O=F,O}),B=e.computed(()=>V.value.map(S=>S.value));return{clientSortOptions:h,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?h.value=null:h.value={sortBy:S,sortDesc:I==="desc"}}}}function Xe(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(_=>JSON.stringify(P)===JSON.stringify(_))!==-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 _=v({},N);return delete _.index,JSON.stringify(P)===JSON.stringify(_)})!==-1;return v({checkbox:p},N)}):y.value);return{currentPageFirstIndex:d,currentPageLastIndex:k,multipleSelectStatus:f,pageItems:x}}function Ye(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 Ze(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 et(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=j(v({},t.value),{page:l}))},updateServerOptionsSort:(l,s)=>{t.value&&(t.value=j(v({},t.value),{sortBy:s!==null?l:null,sortType:s}))},updateServerOptionsRowsPerPage:l=>{t.value&&(t.value=j(v({},t.value),{page:1,rowsPerPage:l}))}}}function D(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 tt(n,o){const t=D(n,o);return Array.isArray(t)?t.join(","):t}function nt(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(_=>{const{field:h,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((h,V)=>D(p,h)<D(p,V)?P?1:-1:D(p,h)>D(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(_=>JSON.stringify(_)!==JSON.stringify(p));else{const _=f.value;_.unshift(p),f.value=_}}}}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}},rn="",sn="";const ot=n=>(e.pushScopeId("data-v-6a78109a"),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"},_t={key:0,class:"pagination__rows-per-page"},ht={class:"pagination__items-index"},yt=e.defineComponent({__name:"DataTable",props:j(v({},at),{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=>({"52352974":e.unref(q)}));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:_,searchField:h,searchValue:V,serverItemsLength:B,serverOptions:H,showIndex:S,sortBy:T,sortType:I,tableHeight:F,themeColor:O}=e.toRefs(i),q=e.computed(()=>F.value?`${F.value}px`:null);e.provide("themeColor",O.value);const E=e.useSlots(),z=e.computed(()=>!!E.pagination),kt=e.computed(()=>!!E.loading),se=e.computed(()=>!!E.expand),ie=e.ref(),K=e.ref();e.provide("dataTable",ie);const ce=e.ref(!1);e.onMounted(()=>{K.value.addEventListener("scroll",()=>{ce.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:de,headersForRender:M,updateSortField:Nt}=Qe(c,r,s,a,k,g,se,y,Q,R,p,X,S,T,I,xt),{rowsItemsComputed:St,rowsPerPageRef:A}=Ze(R,P,H,_),{totalItems:Bt,selectItemsComputed:wt,totalItemsLength:J,toggleSelectAll:It,toggleSelectItem:Et}=nt(Ct,l,R,f,x,h,V,B,t),{currentPaginationNumber:U,maxPaginationNumber:Y,isLastPage:Z,isFirstPage:ee,nextPage:te,prevPage:ne,updatePage:G,updateCurrentPaginationNumber:$t}=Ye(R,N,J,A,H,bt),{currentPageFirstIndex:ue,currentPageLastIndex:pe,multipleSelectStatus:fe,pageItems:ae}=Xe(U,Q,R,f,A,wt,S,Bt,J),{expandingItemIndexList:me,updateExpandingItemIndexList:Vt,clearExpandingItemIndexList:vt}=Ge(f,t),{fixedHeaders:oe,lastFixedColumn:ge,fixedColumnsInfos:Lt}=Ke(M),{clickRow:Ft}=Ue(Q,S,t),Tt=m=>{var u;const L=(u=m.width)!=null?u:oe.value.length?100:null;if(L)return`width: ${L}px; min-width: ${L}px;`},_e=(m,L="th")=>{if(!oe.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?Pt(m):G(1)}),e.watch(ae,()=>{vt()},{deep:!0}),o({currentPageFirstIndex:ue,currentPageLastIndex:pe,clientItemsLength:J,maxPaginationNumber:Y,currentPaginationNumber:U,isLastPage:Z,isFirstPage:ee,nextPage:te,prevPage:ne,updatePage:G}),(m,L)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:ie,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":ce.value,"table-fixed":e.unref(oe).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(M),(u,w)=>(e.openBlock(),e.createElementBlock("col",{key:w,style:e.normalizeStyle(Tt(u))},null,4))),128))]),e.unref(M).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(M),(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(ge)},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(Se,{key:e.unref(fe),status:e.unref(fe),onChange:e.unref(It)},null,8,["status","onChange"])):(e.openBlock(),e.createElementBlock("span",rt,[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",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(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(ae),(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),($,he)=>(e.openBlock(),e.createElementBlock("td",{key:he,style:e.normalizeStyle(_e($,"td")),class:e.normalizeClass([{shadow:$===e.unref(ge),"can-expand":$==="expand"},typeof m.bodyItemClassName=="string"?m.bodyItemClassName:m.bodyItemClassName($,he)]),onClick:ye=>$==="expand"?e.unref(Vt)(w,u,ye):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(me).includes(w)}])},null,2)):$==="checkbox"?(e.openBlock(),e.createBlock(Ee,{key:2,checked:u[$],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)($,u)),1)],64))],14,ct))),128))],10,it),e.unref(se)&&e.unref(me).includes(w)?(e.openBlock(),e.createElementBlock("tr",{key:0,class:e.normalizeClass({"even-row":(w+1)%2===0})},[e.createElementVNode("td",{colspan:e.unref(M).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(Ae,{key:1}))])])):e.createCommentVNode("",!0),!e.unref(ae).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",_t,[e.createTextVNode(e.toDisplayString(m.rowsPerPageMessage)+" ",1),e.createVNode(Te,{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",ht,e.toDisplayString(`${e.unref(ue)}\u2013${e.unref(pe)}`)+" of "+e.toDisplayString(e.unref(J)),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(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(je,{"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 re=b(yt,[["__scopeId","data-v-6a78109a"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",re),re}); | ||
(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 zt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var At=Object.prototype.hasOwnProperty,Ht=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,v=(e,C)=>{for(var b in C||(C={}))At.call(C,b)&&be(e,b,C[b]);if(ke)for(var b of ke(C))Ht.call(C,b)&&be(e,b,C[b]);return e},M=(e,C)=>Rt(e,zt(C));var C="",b=(n,o)=>{const t=n.__vccOpts||n;for(const[i,c]of o)t[i]=c;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:o}){const t=n;e.useCssVars(l=>({"51ab8a49":e.unref(s)}));const i=e.computed(()=>t.status==="allSelected"),c=()=>{o("change",!i.value)},s=e.inject("themeColor");return(l,r)=>(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,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: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(s=>o("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:o}){const t=n;e.useCssVars(g=>({"40595ee7":e.unref(k)}));const i=e.ref(!1),c=e.ref(!1),s=e.inject("dataTable");e.watch(i,g=>{if(g&&s){const y=window.innerHeight,f=s.value.getBoundingClientRect().height,x=s.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)}}),r=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",ve,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=>r(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"},ze=[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 Ae=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",Re,ze))}}),[["__scopeId","data-v-1fa3a520"]]),Xt="";const He={class:"loader-line"};var Oe=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",He))}}),[["__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:o}){const t=n;e.useCssVars(r=>({"40dd4f07":e.unref(l)}));const i=7,c=r=>{r.type==="button"&&!r.active&&o("updatePage",r.page)},s=e.computed(()=>{const r=[];if(t.maxPaginationNumber<=i)for(let a=1;a<=t.maxPaginationNumber;a+=1)r.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)r.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber});else if(a===4)r.push({type:"omission"});else{const d=t.maxPaginationNumber-(i-a);r.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?r.push({type:"button",page:a,active:a===t.currentPaginationNumber,activePrev:a+1===t.currentPaginationNumber}):a===6?r.push({type:"omission"}):r.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)r.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2)r.push({type:"omission"});else{const d=t.maxPaginationNumber-(i-a);r.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)r.push({type:"button",page:1,active:t.currentPaginationNumber===1,activePrev:a+1===t.currentPaginationNumber});else if(a===2||a===6)r.push({type:"omission"});else if(a===7)r.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;r.push({type:"button",page:k,active:k===t.currentPaginationNumber,activePrev:k+1===t.currentPaginationNumber})}return r}),l=e.inject("themeColor");return(r,a)=>(e.openBlock(),e.createElementBlock("div",De,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(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,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: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]=s=>o("clickPrevPage"))},We,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]=s=>o("clickNextPage"))},qe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);function Ue(n,o,t){return{clickRow:c=>{const s=v({},c);if(n.value){const{checkbox:l}=c;delete s.checkbox,s.isSelected=l}if(o.value){const{index:l}=c;delete s.index,s.indexInCurrentPage=l}t("clickRow",s)}}}function Ge(n,o){const t=e.ref([]);return{expandingItemIndexList:t,updateExpandingItemIndexList:(c,s,l)=>{l.stopPropagation();const r=t.value.indexOf(c);r!==-1?t.value.splice(r,1):(o("expandRow",n.value.findIndex(a=>a===s)),t.value.push(c))}}}function Ke(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(s=>{var l;return(l=s.width)!=null?l:100});return o.value.map((s,l)=>{var r,a;return{value:s.value,fixed:(r=s.fixed)!=null?r:!0,width:(a=s.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 Qe(n,o,t,i,c,s,l,r,a,d,k,g,y,f,x,N){const p=e.computed(()=>s.value.findIndex(S=>S.fixed)!==-1),P=e.computed(()=>p.value?s.value.filter(S=>S.fixed):[]),h=e.computed(()=>s.value.filter(S=>!S.fixed)),_=e.ref((()=>f.value!==""?{sortBy:f.value,sortDesc:x.value==="desc"}:null)()),V=e.computed(()=>{var q;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 L=[];y.value?L=[c.value||p.value?{text:"#",value:"index",fixed:!0,width:r.value}:{text:"#",value:"index"},...I]:L=I;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:_,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 Xe(n,o,t,i,c,s,l,r,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(r.value.length,n.value*c.value)),g=e.computed(()=>t.value?i.value:r.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(()=>s.value.length===0||s.value.every(p=>r.value.findIndex(P=>JSON.stringify(p)===JSON.stringify(P))===-1)?"noneSelected":s.value.length===r.value.length&&s.value.every(P=>r.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=s.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 Ye(n,o,t,i,c,s){const l=e.ref(c.value?c.value.page:1),r=e.computed(()=>Math.ceil(t.value/i.value)),a=e.computed(()=>l.value===r.value),d=e.computed(()=>l.value===1);return{currentPaginationNumber:l,maxPaginationNumber:r,isLastPage:a,isFirstPage:d,nextPage:()=>{if(!a.value&&!o.value)if(n.value){const x=l.value+1;s(x)}else l.value+=1},prevPage:()=>{if(!d.value&&!o.value)if(n.value){const x=l.value-1;s(x)}else l.value-=1},updatePage:x=>{o.value||(n.value?s(x):l.value=x)},updateCurrentPaginationNumber:x=>{l.value=x}}}function Ze(n,o,t,i){const c=e.computed(()=>!n.value&&o.value.findIndex(l=>l===i.value)===-1?[i.value,...o.value]:o.value),s=e.ref(t.value?t.value.rowsPerPage:i.value);return{rowsItemsComputed:c,rowsPerPageRef:s}}function et(n,o){const t=e.computed({get:()=>{if(n.value){const{page:l,rowsPerPage:r,sortBy:a,sortType:d}=n.value;return{page:l,rowsPerPage:r,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=M(v({},t.value),{page:l}))},updateServerOptionsSort:(l,r)=>{t.value&&(t.value=M(v({},t.value),{sortBy:r!==null?l:null,sortType:r}))},updateServerOptionsRowsPerPage:l=>{t.value&&(t.value=M(v({},t.value),{page:1,rowsPerPage:l}))}}}function H(n,o){if(n.includes(".")){let t="";return n.split(".").forEach((c,s)=>{t=s===0?o[c]:t[c]}),t}return o[n]}function tt(n,o){const t=H(n,o);return Array.isArray(t)?t.join(","):t}function nt(n,o,t,i,c,s,l,r,a){const d=e.computed(()=>{if(!t.value&&l.value!==""){const p=new RegExp(l.value,"i");return i.value.filter(P=>p.test(s.value!==""?P[s.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?r.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 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-03d72812"),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(v({},at),{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=>({"3edcb22c":e.unref(q)}));const{checkboxColumnWidth:c,expandColumnWidth:s,filterOptions:l,fixedCheckbox:r,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:L,themeColor:D}=e.toRefs(i),q=e.computed(()=>L.value?`${L.value}px`:null);e.provide("themeColor",D.value);const E=e.useSlots(),z=e.computed(()=>!!E.pagination),kt=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:bt,updateServerOptionsSort:xt,updateServerOptionsRowsPerPage:Pt}=et(O,t),{clientSortOptions:Ct,headerColumns:ce,headersForRender:j,updateSortField:Nt}=Qe(c,s,r,a,k,g,re,y,Q,R,p,X,S,T,I,xt),{rowsItemsComputed:St,rowsPerPageRef:A}=Ze(R,P,O,h),{totalItems:Bt,selectItemsComputed:wt,totalItemsLength:J,toggleSelectAll:It,toggleSelectItem:Et}=nt(Ct,l,R,f,x,_,V,B,t),{currentPaginationNumber:U,maxPaginationNumber:Y,isLastPage:Z,isFirstPage:ee,nextPage:te,prevPage:ne,updatePage:G,updateCurrentPaginationNumber:$t}=Ye(R,N,J,A,O,bt),{currentPageFirstIndex:de,currentPageLastIndex:ue,multipleSelectStatus:pe,pageItems:fe}=Xe(U,Q,R,f,A,wt,S,Bt,J),{expandingItemIndexList:me,updateExpandingItemIndexList:Vt}=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(w=>w.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(A,m=>{R.value?Pt(m):G(1)}),o({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,w)=>(e.openBlock(),e.createElementBlock("col",{key:w,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,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(ge)},typeof m.headerItemClassName=="string"?m.headerItemClassName:m.headerItemClassName(u,w)]),style:e.normalizeStyle(he(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(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(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",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,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(ce),($,_e)=>(e.openBlock(),e.createElementBlock("td",{key:_e,style:e.normalizeStyle(he($,"td")),class:e.normalizeClass([{shadow:$===e.unref(ge),"can-expand":$==="expand"},typeof m.bodyItemClassName=="string"?m.bodyItemClassName:m.bodyItemClassName($,_e)]),onClick:ye=>$==="expand"?e.unref(Vt)(w,u,ye):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(me).includes(w)}])},null,2)):$==="checkbox"?(e.openBlock(),e.createBlock(Ee,{key:2,checked:u[$],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)($,u)),1)],64))],14,ct))),128))],10,it),e.unref(re)&&e.unref(me).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(Oe,{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(Ae,{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(A),"onUpdate:modelValue":F[0]||(F[0]=u=>e.isRef(A)?A.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(z)?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-03d72812"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",le),le}); |
@@ -6,3 +6,3 @@ { | ||
"private": false, | ||
"version": "1.4.6", | ||
"version": "1.4.7", | ||
"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
100345
1575