vue3-easy-data-table
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -620,23 +620,23 @@ var __defProp = Object.defineProperty; | ||
useCssVars((_ctx) => ({ | ||
"0c67db22": unref(tableBorderColor), | ||
"49fc9db0": unref(minHeightPx), | ||
"13c71094": unref(rowBackgroundColor), | ||
"079a4638": unref(tableHeightPx), | ||
"48a60539": unref(loadingWrapperSizePx), | ||
"98cc86a0": unref(rowHeightPx), | ||
"3f298311": unref(fontSizePx), | ||
"7af8bd5a": unref(rowFontColor), | ||
"076f652a": unref(shadowRightPx), | ||
"8e055054": unref(rowBorderColor), | ||
"198ed024": unref(headerFontColor), | ||
"31d166ef": __props.headerBackgroundColor, | ||
"63e322d3": unref(sortTypeIconSizePx), | ||
"58e9c354": unref(sortTypeAscIconMarginTopPx), | ||
"46d94434": unref(sortTypeDescIconMarginTopPx), | ||
"7287eb9a": unref(rowHoverBackgroundColor), | ||
"0daeb8d9": unref(rowHoverFontColor), | ||
"659369e6": unref(evenRowFontColor), | ||
"3d5e06ce": unref(evenRowBackgroundColor), | ||
"a53d53be": unref(footerBackgroundColor), | ||
"cf1f56c0": unref(footerFontColor) | ||
"7c380ee0": unref(tableBorderColor), | ||
"d66f320c": unref(minHeightPx), | ||
"5ab18a82": unref(rowBackgroundColor), | ||
"5f236636": unref(tableHeightPx), | ||
"7ed9bba7": unref(loadingWrapperSizePx), | ||
"6d607282": unref(rowHeightPx), | ||
"55abcaff": unref(fontSizePx), | ||
"4193a5c1": unref(rowFontColor), | ||
"5f38d6bd": unref(shadowRightPx), | ||
"97c40e78": unref(rowBorderColor), | ||
"5c2c14c0": unref(headerFontColor), | ||
"7bd7037e": __props.headerBackgroundColor, | ||
"aa64c67e": unref(sortTypeIconSizePx), | ||
"7ee86b78": unref(sortTypeAscIconMarginTopPx), | ||
"0c23d3f4": unref(sortTypeDescIconMarginTopPx), | ||
"033b1328": unref(rowHoverBackgroundColor), | ||
"07b6492b": unref(rowHoverFontColor), | ||
"fa9b2f0a": unref(evenRowFontColor), | ||
"95044c88": unref(evenRowBackgroundColor), | ||
"3da46d73": unref(footerBackgroundColor), | ||
"0163d172": unref(footerFontColor) | ||
})); | ||
@@ -1193,9 +1193,9 @@ const { | ||
"can-expand": column === "expand" | ||
}), | ||
onClick: withModifiers(($event) => column === "expand" ? updateExpandingItemIndexList(index) : null, ["stop"]) | ||
}) | ||
}, [ | ||
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": expandingItemIndexList.value.includes(index) }]) | ||
}, null, 2)) : column === "checkbox" ? (openBlock(), createBlock(SingleSelectCheckBox, { | ||
class: normalizeClass(["expand-icon", { "expanding": expandingItemIndexList.value.includes(index) }]), | ||
onClick: withModifiers(($event) => updateExpandingItemIndexList(index), ["stop"]) | ||
}, null, 10, _hoisted_6)) : column === "checkbox" ? (openBlock(), createBlock(SingleSelectCheckBox, { | ||
key: 2, | ||
@@ -1207,3 +1207,3 @@ checked: item[column], | ||
], 64)) | ||
], 14, _hoisted_6); | ||
], 6); | ||
}), 128)) | ||
@@ -1277,3 +1277,3 @@ ], 8, _hoisted_5), | ||
}); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-491f8c20"]]); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4ebd2b7e"]]); | ||
if (typeof window !== "undefined" && window.Vue) { | ||
@@ -1280,0 +1280,0 @@ window.Vue.createApp({}).component("Vue3EasyDataTable", DataTable); |
@@ -1,1 +0,1 @@ | ||
(function(e,x){typeof exports=="object"&&typeof module!="undefined"?module.exports=x(require("vue")):typeof define=="function"&&define.amd?define(["vue"],x):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=x(e.Vue))})(this,function(e){"use strict";var Ft=Object.defineProperty,Tt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var be=(e,x,g)=>x in e?Ft(e,x,{enumerable:!0,configurable:!0,writable:!0,value:g}):e[x]=g,C=(e,x)=>{for(var g in x||(x={}))Ht.call(x,g)&&be(e,g,x[g]);if(ke)for(var g of ke(x))Ot.call(x,g)&&be(e,g,x[g]);return e},R=(e,x)=>Tt(e,zt(x));var x="",g=(r,_)=>{const l=r.__vccOpts||r;for(const[n,f]of _)l[n]=f;return l};const Ce=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),Se=["onClick"],Be=["checked"],Pe=Ce(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var we=g(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:_}){const l=r;e.useCssVars(w=>({"7f84b28f":e.unref(b)}));const n=e.computed(()=>l.status==="allSelected"),f=()=>{_("change",!n.value)},b=e.inject("themeColor");return(w,z)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(f,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(n),class:e.normalizeClass(r.status)},null,10,Be),Pe],8,Se))}}),[["__scopeId","data-v-566775ba"]]),Rt="";const Ne=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),$e=["checked"],Ee=Ne(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Ie=g(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:_}){e.useCssVars(n=>({"20cfc5a0":e.unref(l)}));const l=e.inject("themeColor");return(n,f)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:f[0]||(f[0]=e.withModifiers(b=>_("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,$e),Ee]))}}),[["__scopeId","data-v-39f156fd"]]),At="";const Ve=r=>(e.pushScopeId("data-v-0ed08e20"),r=r(),e.popScopeId(),r),Fe={class:"easy-data-table__rows-selector"},Te={class:"rows-input"},ze=Ve(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),He=["onClick"];var Oe=g(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:_}){const l=r;e.useCssVars(h=>({"83c11052":e.unref(m),"6b60f418":e.unref(i),"346ac97c":e.unref(d)}));const n=e.ref(!1),f=e.ref(!1),b=e.inject("dataTable");e.watch(n,h=>{if(h&&b){const S=window.innerHeight,k=b.value.getBoundingClientRect().height,E=b.value.getBoundingClientRect().top;S-(k+E)<=100?f.value=!0:f.value=!1}});const w=e.computed({get:()=>l.modelValue,set:h=>{_("update:modelValue",h)}}),z=h=>{w.value=h,n.value=!1},M=(h,S)=>{let k=h.parentNode;for(;k!=null;){if(k.classList&&k.classList.contains(S))return!0;k=k.parentNode}return!1},H=h=>{M(h.target,"easy-data-table__rows-selector")||(n.value=!1)};e.onMounted(()=>{document.addEventListener("click",H)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",H)});const d=e.inject("themeColor"),i=e.inject("footerBackgroundColor"),m=e.inject("footerFontColor");return(h,S)=>(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:S[0]||(S[0]=k=>n.value=!n.value)},[e.createElementVNode("div",Te,e.toDisplayString(e.unref(w)),1),ze]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:n.value,inside:f.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,k=>(e.openBlock(),e.createElementBlock("li",{key:k,class:e.normalizeClass({selected:k===e.unref(w)}),onClick:E=>z(k)},e.toDisplayString(k),11,He))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),jt="";const j=r=>(e.pushScopeId("data-v-969989cc"),r=r(),e.popScopeId(),r),Le={class:"lds-ring"},Re=[j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1))];var Me=g(e.defineComponent({setup(r){e.useCssVars(n=>({"284c10f4":e.unref(l),"90c4d0a4":e.unref(_)}));const _=e.inject("themeColor"),l=e.inject("loadingEntitySizePx");return(n,f)=>(e.openBlock(),e.createElementBlock("div",Le,Re))}}),[["__scopeId","data-v-969989cc"]]),Kt="";const Ae={class:"buttons-pagination"},De=["onClick"];var je=g(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:_}){const l=r;e.useCssVars(d=>({aa5730a0:e.unref(z),"24829312":e.unref(M),"98a0e762":e.unref(H)}));const n=7,f=d=>{d.type==="button"&&!d.active&&_("updatePage",d.page)},b=e.computed(()=>{const d=[];if(l.maxPaginationNumber<=n)for(let i=1;i<=l.maxPaginationNumber;i+=1)d.push({type:"button",page:i,active:i===l.currentPaginationNumber});else if([1,2,l.maxPaginationNumber,l.maxPaginationNumber-1].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)if(i<=3)d.push({type:"button",page:i,active:i===l.currentPaginationNumber});else if(i===4)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-i);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else if([3,4].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)i<=5?d.push({type:"button",page:i,active:i===l.currentPaginationNumber}):i===6?d.push({type:"omission"}):d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else if([l.maxPaginationNumber-2,l.maxPaginationNumber-3].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)if(i===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(i===2)d.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-i);d.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else for(let i=1;i<=n;i+=1)if(i===1)d.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(i===2||i===6)d.push({type:"omission"});else if(i===7)d.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else{const m=4-i,h=l.currentPaginationNumber-m;d.push({type:"button",page:h,active:h===l.currentPaginationNumber})}return d}),w=e.inject("rowHeight"),z=e.computed(()=>`${w*.6}px`),M=e.inject("rowBorderColor"),H=e.inject("themeColor");return(d,i)=>(e.openBlock(),e.createElementBlock("div",Ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:m.type==="button",active:m.type==="button"&&m.active,omission:m.type==="omission"}]),onClick:S=>f(m)},e.toDisplayString(m.type==="button"?m.page:"..."),11,De))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Xt="";const te=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),We=[te(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],qe=[te(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Je=g(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:_}){const l=e.useSlots();return(n,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:f[0]||(f[0]=b=>_("clickPrevPage"))},We,2),e.unref(l).buttonsPagination?e.renderSlot(n.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":r.isLastPage}]),onClick:f[1]||(f[1]=b=>_("clickNextPage"))},qe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),eo="";const Ue={key:0},Ge=["onClick"],Ke={key:1,class:"header-item"},Qe={key:1,class:"header-text"},Xe=["onClick"],Ye=["onClick"],Ze={key:0},ve=["colspan"],et={class:"loading-entity"},tt={key:1,class:"data-table__message"},ot={key:0,class:"data-table__footer"},nt={key:0,class:"footer__rows-per-page"},at={class:"footer__items-index"};var oe=g(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},filterOptions:{type:Array,default:null},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},fixedExpand:{type:Boolean,default:!1},expandColumnWidth:{type:Number,default:36},checkboxColumnWidth:{type:Number,default:null},hideRowsPerPage:{type:Boolean,default:!1},noThPadding:{type:Boolean,default:!1},noTdPadding:{type:Boolean,default:!1},rowsPerPageMessage:{type:String,default:"rows per page:"}},emits:["update:itemsSelected","update:serverOptions","clickRow"],setup(r,{expose:_,emit:l}){const n=r;e.useCssVars(o=>({"0c67db22":e.unref(b),"49fc9db0":e.unref(it),"13c71094":e.unref(i),"079a4638":e.unref(st),"48a60539":e.unref(ft),"98cc86a0":e.unref(rt),"3f298311":e.unref(k),"7af8bd5a":e.unref(z),"076f652a":e.unref(lt),"8e055054":e.unref(f),"198ed024":e.unref(w),"31d166ef":r.headerBackgroundColor,"63e322d3":e.unref(ct),"58e9c354":e.unref(dt),"46d94434":e.unref(pt),"7287eb9a":e.unref(M),"0daeb8d9":e.unref(H),"659369e6":e.unref(h),"3d5e06ce":e.unref(m),a53d53be:e.unref(d),cf1f56c0:e.unref(S)}));const{rowBorderColor:f,tableBorderColor:b,headerFontColor:w,rowFontColor:z,rowHoverBackgroundColor:M,rowHoverFontColor:H,footerBackgroundColor:d,rowBackgroundColor:i,evenRowBackgroundColor:m,evenRowFontColor:h,footerFontColor:S}=e.toRefs(n),k=e.computed(()=>`${n.tableFontSize}px`),E=e.computed(()=>n.tableFontSize*(n.dense?2:3)),rt=e.computed(()=>`${E.value}px`),lt=e.computed(()=>`-${E.value}px`),st=e.computed(()=>n.tableHeight?`${n.tableHeight}px`:null),it=e.computed(()=>`${E.value*5}px`),ne=e.computed(()=>Math.round(n.tableFontSize/2.5)),ct=e.computed(()=>`${ne.value}px`),ae=e.computed(()=>Math.round(ne.value)),dt=e.computed(()=>`-${ae.value}px`),pt=e.computed(()=>`${ae.value}px`),ut=e.computed(()=>`${n.tableFontSize*5}px`),ft=e.computed(()=>n.tableHeight?`${n.tableHeight-E.value}px`:`${n.tableFontSize*5*2}px`),mt=e.computed(()=>{var o;return(o=n.checkboxColumnWidth)!=null?o:1.3*n.tableFontSize+20});e.provide("themeColor",n.themeColor),e.provide("loadingEntitySizePx",ut.value),e.provide("rowHeight",E.value),e.provide("rowBorderColor",f.value),e.provide("footerBackgroundColor",d.value),e.provide("footerFontColor",S.value);const O=e.useSlots(),gt=e.computed(()=>O.body),ht=e.computed(()=>O.pagination),yt=e.computed(()=>O.loading),re=e.computed(()=>O.expand),le=e.ref(),Q=e.ref();e.provide("dataTable",le);const se=e.ref(!1);e.onMounted(()=>{Q.value.addEventListener("scroll",()=>{se.value=Q.value.scrollLeft>0})});const u=e.computed({get:()=>{if(n.serverOptions){const{page:o,rowsPerPage:a,sortBy:t,sortType:s}=n.serverOptions;return{page:o,rowsPerPage:a,sortBy:t!=null?t:null,sortType:s!=null?s:null}}return null},set:o=>{l("update:serverOptions",o)}}),X=e.computed(()=>n.itemsSelected!==null),B=e.computed(()=>u.value!==null),xt=e.computed(()=>!B.value&&n.rowsItems.findIndex(o=>o===n.rowsPerPage)===-1?[n.rowsPerPage,...n.rowsItems]:n.rowsItems),_t=()=>n.sortBy!==""?{sortBy:n.sortBy,sortDesc:n.sortType==="desc"}:null,V=e.ref(_t()),W=e.computed(()=>n.headers.findIndex(o=>o.fixed)!==-1),kt=e.computed(()=>W.value?n.headers.filter(o=>o.fixed):[]),bt=e.computed(()=>n.headers.filter(o=>!o.fixed)),L=e.computed(()=>{const a=[...kt.value,...bt.value].map(p=>{const I=p;return p.sortable&&(I.sortType="none"),u.value&&p.value===u.value.sortBy&&u.value.sortType&&(I.sortType=u.value.sortType),!B.value&&V.value&&p.value===V.value.sortBy&&(I.sortType=V.value.sortDesc?"desc":"asc"),I});let t=[];re.value?t=[n.fixedExpand||W.value?{text:"",value:"expand",fixed:!0,width:n.expandColumnWidth}:{text:"",value:"expand"},...a]:t=a;let s=[];n.showIndex?s=[n.fixedIndex||W.value?{text:"#",value:"index",fixed:!0,width:n.indexColumnWidth}:{text:"#",value:"index"},...t]:s=t;let c=[];return X.value?c=[n.fixedCheckbox||W.value?{text:"checkbox",value:"checkbox",fixed:!0,width:mt.value}:{text:"checkbox",value:"checkbox"},...s]:c=s,c}),A=e.ref([]),Ct=o=>{const a=A.value.indexOf(o);a!==-1?A.value.splice(a,1):A.value.push(o)},N=e.computed(()=>L.value.filter(o=>o.fixed)),ie=e.computed(()=>N.value.length?N.value[N.value.length-1].value:""),St=o=>{var t;const a=(t=o.width)!=null?t:N.value.length?100:null;if(a)return`width: ${a}px; min-width: ${a}px;`},Bt=e.computed(()=>{if(!N.value.length)return[];const o=N.value.map(a=>{var t;return(t=a.width)!=null?t:100});return N.value.map((a,t)=>{var s,c;return{value:a.value,fixed:(s=a.fixed)!=null?s:!0,width:(c=a.width)!=null?c:100,distance:t===0?0:o.reduce((p,I,Vt)=>{let _e=p;return Vt<t&&(_e+=I),_e})}})}),ce=(o,a="th")=>{if(!N.value.length)return;const t=Bt.value.find(s=>s.value===o);if(t)return`left: ${t.distance}px;z-index: ${a==="th"?3:1}; position: sticky`},de=e.computed(()=>L.value.map(o=>o.value)),D=(o,a)=>{if(o.includes(".")){let t="";return o.split(".").forEach((c,p)=>{t=p===0?a[c]:t[c]}),t}return a[o]},Pt=(o,a)=>{const t=D(o,a);return Array.isArray(t)?t.join(","):t},P=e.computed({get:()=>{var o;return(o=n.itemsSelected)!=null?o:[]},set:o=>{l("update:itemsSelected",o)}}),pe=e.computed(()=>{if(!B.value&&n.searchValue!==""){const o=new RegExp(n.searchValue,"i");return n.items.filter(a=>o.test(n.searchField!==""?a[n.searchField]:Object.values(a).join(" ")))}return n.items}),F=e.computed(()=>{let o=[...pe.value];return n.filterOptions?(n.filterOptions.forEach(a=>{o=o.filter(t=>{const{field:s,comparison:c,criteria:p}=a;switch(c){case"=":return t[s]===p;case"!=":return t[s]!==p;case">":return t[s]>p;case"<":return t[s]<p;case"<=":return t[s]<=p;case">=":return t[s]>=p;case"between":return t[s]>=Math.min(...p)&&t[s]<=Math.max(...p);default:return t[s]===p}})}),o):pe.value}),q=e.computed(()=>P.value.length===0||P.value.every(a=>F.value.findIndex(t=>JSON.stringify(a)===JSON.stringify(t))===-1)?"noneSelected":P.value.length===F.value.length&&P.value.every(t=>F.value.findIndex(s=>JSON.stringify(t)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),y=e.ref(B.value?n.serverOptions.page:1),{items:Y}=e.toRefs(n);e.watch(Y,()=>{B.value||(y.value=1)},{deep:!0});const $=e.ref(B.value?n.serverOptions.rowsPerPage:n.rowsPerPage);e.watch($,o=>{u.value&&(u.value=R(C({},u.value),{page:1,rowsPerPage:o})),y.value=1});const wt=(o,a)=>{let t=null;a==="none"?t="asc":a==="asc"?t="desc":t=null,u.value?u.value=R(C({},u.value),{sortBy:t!==null?o:null,sortType:t}):t===null?V.value=null:V.value={sortBy:o,sortDesc:t==="desc"}},ue=e.computed(()=>{if(B.value)return n.items;if(V.value===null)return F.value;const{sortBy:o,sortDesc:a}=V.value;return[...F.value].sort((s,c)=>D(o,s)<D(o,c)?a?1:-1:D(o,s)>D(o,c)?a?-1:1:0)}),Z=e.computed(()=>B.value?n.serverItemsLength:F.value.length),fe=e.computed(()=>B.value?y.value*$.value:Math.min(F.value.length,y.value*$.value)),me=e.computed(()=>(y.value-1)*$.value+1),J=e.computed(()=>Math.ceil(Z.value/$.value)),U=e.computed(()=>y.value===J.value),G=e.computed(()=>y.value===1),{loading:T}=e.toRefs(n),v=()=>{if(!U.value&&!T.value)if(u.value){const o=y.value+1;u.value=R(C({},u.value),{page:o})}else y.value+=1},ee=()=>{if(!G.value&&!T.value)if(u.value){const o=y.value-1;u.value=R(C({},u.value),{page:o})}else y.value-=1},ge=o=>{T.value||(u.value?u.value=R(C({},u.value),{page:o}):y.value=o)};e.watch(T,(o,a)=>{u.value&&o===!1&&a===!0&&(y.value=u.value.page)});const he=e.computed(()=>B.value?n.items:ue.value.slice(me.value-1,fe.value)),ye=e.computed(()=>$.value*(y.value-1)+1),Nt=e.computed(()=>$.value*y.value),K=e.computed(()=>n.showIndex?he.value.map((o,a)=>C({index:ye.value+a},o)):he.value),xe=e.computed(()=>X.value?q.value==="allSelected"?K.value.map(o=>C({checkbox:!0},o)):q.value==="noneSelected"?K.value.map(o=>C({checkbox:!1},o)):K.value.map(o=>{const a=P.value.findIndex(t=>{const s=C({},o);return delete s.index,JSON.stringify(t)===JSON.stringify(s)})!==-1;return C({checkbox:a},o)}):K.value),$t=o=>{P.value=o?ue.value:[]},Et=o=>{const a=o.checkbox;if(delete o.checkbox,delete o.index,a)P.value=P.value.filter(t=>JSON.stringify(t)!==JSON.stringify(o));else{const t=P.value;t.unshift(o),P.value=t}},It=o=>{const a=C({},o);if(X.value){const{checkbox:t}=o;delete a.checkbox,a.isSelected=t}if(n.showIndex){const{index:t}=o;delete a.index,a.indexInCurrentPage=t}l("clickRow",a)};return _({clientItemsLength:Z,currentPageFirstIndex:ye,currentPageLastIndex:Nt,maxPaginationNumber:J,currentPaginationNumber:y,isLastPage:U,isFirstPage:G,nextPage:v,prevPage:ee,updatePage:ge}),(o,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:le,class:"vue3-easy-data-table"},[e.createElementVNode("div",{ref_key:"tableBody",ref:Q,class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"fixed-height":r.tableHeight,"show-shadow":se.value}])},[e.createElementVNode("table",{class:e.normalizeClass({fixed:e.unref(N).length})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,s)=>(e.openBlock(),e.createElementBlock("col",{key:s,style:e.normalizeStyle(St(t))},null,4))),128))]),e.unref(L).length&&!r.hideHeader?(e.openBlock(),e.createElementBlock("thead",Ue,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass({sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",fixed:t.fixed,"has-shadow":t.value===e.unref(ie),"no-padding":r.noThPadding}),style:e.normalizeStyle(ce(t.value)),onClick:e.withModifiers(c=>t.sortable&&t.sortType?wt(t.value,t.sortType):null,["stop"])},[t.text==="checkbox"?(e.openBlock(),e.createBlock(we,{key:e.unref(q),status:e.unref(q),onChange:$t},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ke,[e.unref(O)[`header-${t.value}`]?e.renderSlot(o.$slots,`header-${t.value}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):(e.openBlock(),e.createElementBlock("span",Qe,e.toDisplayString(t.text),1)),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,Ge))),128))])])):e.createCommentVNode("",!0),e.unref(gt)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.unref(Y).length&&e.unref(de).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating,"hover-to-change-color":r.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(xe),(t,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s},[e.createElementVNode("tr",{onClick:c=>It(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(de),(c,p)=>(e.openBlock(),e.createElementBlock("td",{key:p,style:e.normalizeStyle(ce(c,"td")),class:e.normalizeClass({"has-shadow":c===e.unref(ie),"no-padding":r.noTdPadding,"can-expand":c==="expand"}),onClick:e.withModifiers(I=>c==="expand"?Ct(s):null,["stop"])},[e.unref(O)[`item-${c}`]?e.renderSlot(o.$slots,`item-${c}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):c==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:A.value.includes(s)}])},null,2)):c==="checkbox"?(e.openBlock(),e.createBlock(Ie,{key:2,checked:t[c],onChange:I=>Et(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(Pt(c,t)),1)],64))],14,Ye))),128))],8,Xe),e.unref(re)&&A.value.includes(s)?(e.openBlock(),e.createElementBlock("tr",Ze,[e.createElementVNode("td",{class:"expand-td",colspan:e.unref(L).length},[e.renderSlot(o.$slots,"expand",e.normalizeProps(e.guardReactiveProps(t)),void 0,!0)],8,ve)])):e.createCommentVNode("",!0)],64))),128))],2)):e.createCommentVNode("",!0)],64))],2),e.unref(T)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!e.unref(Y).length&&e.unref(T)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":r.hideFooter}])},null,2),e.createElementVNode("div",et,[e.unref(yt)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Me,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(xe).length&&!e.unref(T)?(e.openBlock(),e.createElementBlock("div",tt,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0)],2),r.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ot,[r.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",nt,[e.createTextVNode(e.toDisplayString(r.rowsPerPageMessage)+" ",1),e.createVNode(Oe,{modelValue:$.value,"onUpdate:modelValue":a[0]||(a[0]=t=>$.value=t),"rows-items":e.unref(xt)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",at,e.toDisplayString(`${e.unref(me)}-${e.unref(fe)}`)+" of "+e.toDisplayString(e.unref(Z)),1),e.unref(ht)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(G),isLastPage:e.unref(U),currentPaginationNumber:y.value,maxPaginationNumber:e.unref(J),nextPage:v,prevPage:ee})),void 0,!0):(e.openBlock(),e.createBlock(Je,{key:2,"is-first-page":e.unref(G),"is-last-page":e.unref(U),onClickNextPage:v,onClickPrevPage:ee},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(je,{"current-pagination-number":y.value,"max-pagination-number":e.unref(J),onUpdatePage:ge},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],512))}}),[["__scopeId","data-v-491f8c20"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",oe),oe}); | ||
(function(e,x){typeof exports=="object"&&typeof module!="undefined"?module.exports=x(require("vue")):typeof define=="function"&&define.amd?define(["vue"],x):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=x(e.Vue))})(this,function(e){"use strict";var Ft=Object.defineProperty,Tt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var be=(e,x,g)=>x in e?Ft(e,x,{enumerable:!0,configurable:!0,writable:!0,value:g}):e[x]=g,C=(e,x)=>{for(var g in x||(x={}))Ht.call(x,g)&&be(e,g,x[g]);if(ke)for(var g of ke(x))Ot.call(x,g)&&be(e,g,x[g]);return e},R=(e,x)=>Tt(e,zt(x));var x="",g=(r,_)=>{const l=r.__vccOpts||r;for(const[n,f]of _)l[n]=f;return l};const Ce=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),Se=["onClick"],Be=["checked"],Pe=Ce(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var we=g(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:_}){const l=r;e.useCssVars(w=>({"7f84b28f":e.unref(b)}));const n=e.computed(()=>l.status==="allSelected"),f=()=>{_("change",!n.value)},b=e.inject("themeColor");return(w,z)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(f,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(n),class:e.normalizeClass(r.status)},null,10,Be),Pe],8,Se))}}),[["__scopeId","data-v-566775ba"]]),Rt="";const Ne=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),$e=["checked"],Ee=Ne(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var Ie=g(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:_}){e.useCssVars(n=>({"20cfc5a0":e.unref(l)}));const l=e.inject("themeColor");return(n,f)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:f[0]||(f[0]=e.withModifiers(b=>_("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,$e),Ee]))}}),[["__scopeId","data-v-39f156fd"]]),At="";const Ve=r=>(e.pushScopeId("data-v-0ed08e20"),r=r(),e.popScopeId(),r),Fe={class:"easy-data-table__rows-selector"},Te={class:"rows-input"},ze=Ve(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),He=["onClick"];var Oe=g(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:_}){const l=r;e.useCssVars(h=>({"83c11052":e.unref(m),"6b60f418":e.unref(i),"346ac97c":e.unref(c)}));const n=e.ref(!1),f=e.ref(!1),b=e.inject("dataTable");e.watch(n,h=>{if(h&&b){const S=window.innerHeight,k=b.value.getBoundingClientRect().height,E=b.value.getBoundingClientRect().top;S-(k+E)<=100?f.value=!0:f.value=!1}});const w=e.computed({get:()=>l.modelValue,set:h=>{_("update:modelValue",h)}}),z=h=>{w.value=h,n.value=!1},M=(h,S)=>{let k=h.parentNode;for(;k!=null;){if(k.classList&&k.classList.contains(S))return!0;k=k.parentNode}return!1},H=h=>{M(h.target,"easy-data-table__rows-selector")||(n.value=!1)};e.onMounted(()=>{document.addEventListener("click",H)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",H)});const c=e.inject("themeColor"),i=e.inject("footerBackgroundColor"),m=e.inject("footerFontColor");return(h,S)=>(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:S[0]||(S[0]=k=>n.value=!n.value)},[e.createElementVNode("div",Te,e.toDisplayString(e.unref(w)),1),ze]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:n.value,inside:f.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,k=>(e.openBlock(),e.createElementBlock("li",{key:k,class:e.normalizeClass({selected:k===e.unref(w)}),onClick:E=>z(k)},e.toDisplayString(k),11,He))),128))],2)]))}}),[["__scopeId","data-v-0ed08e20"]]),jt="";const j=r=>(e.pushScopeId("data-v-969989cc"),r=r(),e.popScopeId(),r),Le={class:"lds-ring"},Re=[j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1)),j(()=>e.createElementVNode("div",null,null,-1))];var Me=g(e.defineComponent({setup(r){e.useCssVars(n=>({"284c10f4":e.unref(l),"90c4d0a4":e.unref(_)}));const _=e.inject("themeColor"),l=e.inject("loadingEntitySizePx");return(n,f)=>(e.openBlock(),e.createElementBlock("div",Le,Re))}}),[["__scopeId","data-v-969989cc"]]),Kt="";const Ae={class:"buttons-pagination"},De=["onClick"];var je=g(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:_}){const l=r;e.useCssVars(c=>({aa5730a0:e.unref(z),"24829312":e.unref(M),"98a0e762":e.unref(H)}));const n=7,f=c=>{c.type==="button"&&!c.active&&_("updatePage",c.page)},b=e.computed(()=>{const c=[];if(l.maxPaginationNumber<=n)for(let i=1;i<=l.maxPaginationNumber;i+=1)c.push({type:"button",page:i,active:i===l.currentPaginationNumber});else if([1,2,l.maxPaginationNumber,l.maxPaginationNumber-1].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)if(i<=3)c.push({type:"button",page:i,active:i===l.currentPaginationNumber});else if(i===4)c.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-i);c.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else if([3,4].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)i<=5?c.push({type:"button",page:i,active:i===l.currentPaginationNumber}):i===6?c.push({type:"omission"}):c.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else if([l.maxPaginationNumber-2,l.maxPaginationNumber-3].includes(l.currentPaginationNumber))for(let i=1;i<=n;i+=1)if(i===1)c.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(i===2)c.push({type:"omission"});else{const m=l.maxPaginationNumber-(n-i);c.push({type:"button",page:m,active:m===l.currentPaginationNumber})}else for(let i=1;i<=n;i+=1)if(i===1)c.push({type:"button",page:1,active:l.currentPaginationNumber===1});else if(i===2||i===6)c.push({type:"omission"});else if(i===7)c.push({type:"button",page:l.maxPaginationNumber,active:l.maxPaginationNumber===l.currentPaginationNumber});else{const m=4-i,h=l.currentPaginationNumber-m;c.push({type:"button",page:h,active:h===l.currentPaginationNumber})}return c}),w=e.inject("rowHeight"),z=e.computed(()=>`${w*.6}px`),M=e.inject("rowBorderColor"),H=e.inject("themeColor");return(c,i)=>(e.openBlock(),e.createElementBlock("div",Ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(m,h)=>(e.openBlock(),e.createElementBlock("div",{key:h,class:e.normalizeClass(["item",{button:m.type==="button",active:m.type==="button"&&m.active,omission:m.type==="omission"}]),onClick:S=>f(m)},e.toDisplayString(m.type==="button"?m.page:"..."),11,De))),128))]))}}),[["__scopeId","data-v-4f534e20"]]),Xt="";const te=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),We=[te(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],qe=[te(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var Je=g(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:_}){const l=e.useSlots();return(n,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:f[0]||(f[0]=b=>_("clickPrevPage"))},We,2),e.unref(l).buttonsPagination?e.renderSlot(n.$slots,"buttonsPagination",{key:0},void 0,!0):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["next-page__click-button",{"last-page":r.isLastPage}]),onClick:f[1]||(f[1]=b=>_("clickNextPage"))},qe,2)],64))}}),[["__scopeId","data-v-c9da5286"]]),eo="";const Ue={key:0},Ge=["onClick"],Ke={key:1,class:"header-item"},Qe={key:1,class:"header-text"},Xe=["onClick"],Ye=["onClick"],Ze={key:0},ve=["colspan"],et={class:"loading-entity"},tt={key:1,class:"data-table__message"},ot={key:0,class:"data-table__footer"},nt={key:0,class:"footer__rows-per-page"},at={class:"footer__items-index"};var oe=g(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},rowBorderColor:{type:String,default:"#e0e0e0"},tableBorderColor:{type:String,default:"#e0e0e0"},rowBackgroundColor:{type:String,default:"#fff"},footerBackgroundColor:{type:String,default:"#fff"},rowFontColor:{type:String,default:"#212121"},footerFontColor:{type:String,default:"#212121"},emptyMessage:{type:String,default:"No Available Data"},fixedHeader:{type:Boolean,default:!0},headerFontColor:{type:String,default:"#373737"},headerBackgroundColor:{type:String,default:"#fff"},tableFontSize:{type:Number,default:12},evenRowBackgroundColor:{type:String,default:"#fafafa"},evenRowFontColor:{type:String,default:"#212121"},headers:{type:Array,required:!0},hoverToChangeColor:{type:Boolean,default:!0},items:{type:Array,required:!0},tableHeight:{type:Number,default:()=>null},itemsSelected:{type:Array,default:null},searchField:{type:String,default:""},searchValue:{type:String,default:""},rowsPerPage:{type:Number,default:25},rowsItems:{type:Array,default:()=>[25,50,100]},rowHoverBackgroundColor:{type:String,default:"#eee"},rowHoverFontColor:{type:String,default:"#212121"},loading:{type:Boolean,deault:!1},serverOptions:{type:Object,default:null},serverItemsLength:{type:Number,default:0},sortBy:{type:String,default:""},sortType:{type:String,default:"asc"},themeColor:{type:String,default:"#42b883"},dense:{type:Boolean,default:!1},showIndex:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},filterOptions:{type:Array,default:null},fixedCheckbox:{type:Boolean,default:!1},fixedIndex:{type:Boolean,default:!1},indexColumnWidth:{type:Number,default:60},fixedExpand:{type:Boolean,default:!1},expandColumnWidth:{type:Number,default:36},checkboxColumnWidth:{type:Number,default:null},hideRowsPerPage:{type:Boolean,default:!1},noThPadding:{type:Boolean,default:!1},noTdPadding:{type:Boolean,default:!1},rowsPerPageMessage:{type:String,default:"rows per page:"}},emits:["update:itemsSelected","update:serverOptions","clickRow"],setup(r,{expose:_,emit:l}){const n=r;e.useCssVars(o=>({"7c380ee0":e.unref(b),d66f320c:e.unref(it),"5ab18a82":e.unref(i),"5f236636":e.unref(st),"7ed9bba7":e.unref(ft),"6d607282":e.unref(rt),"55abcaff":e.unref(k),"4193a5c1":e.unref(z),"5f38d6bd":e.unref(lt),"97c40e78":e.unref(f),"5c2c14c0":e.unref(w),"7bd7037e":r.headerBackgroundColor,aa64c67e:e.unref(ct),"7ee86b78":e.unref(dt),"0c23d3f4":e.unref(pt),"033b1328":e.unref(M),"07b6492b":e.unref(H),fa9b2f0a:e.unref(h),"95044c88":e.unref(m),"3da46d73":e.unref(c),"0163d172":e.unref(S)}));const{rowBorderColor:f,tableBorderColor:b,headerFontColor:w,rowFontColor:z,rowHoverBackgroundColor:M,rowHoverFontColor:H,footerBackgroundColor:c,rowBackgroundColor:i,evenRowBackgroundColor:m,evenRowFontColor:h,footerFontColor:S}=e.toRefs(n),k=e.computed(()=>`${n.tableFontSize}px`),E=e.computed(()=>n.tableFontSize*(n.dense?2:3)),rt=e.computed(()=>`${E.value}px`),lt=e.computed(()=>`-${E.value}px`),st=e.computed(()=>n.tableHeight?`${n.tableHeight}px`:null),it=e.computed(()=>`${E.value*5}px`),ne=e.computed(()=>Math.round(n.tableFontSize/2.5)),ct=e.computed(()=>`${ne.value}px`),ae=e.computed(()=>Math.round(ne.value)),dt=e.computed(()=>`-${ae.value}px`),pt=e.computed(()=>`${ae.value}px`),ut=e.computed(()=>`${n.tableFontSize*5}px`),ft=e.computed(()=>n.tableHeight?`${n.tableHeight-E.value}px`:`${n.tableFontSize*5*2}px`),mt=e.computed(()=>{var o;return(o=n.checkboxColumnWidth)!=null?o:1.3*n.tableFontSize+20});e.provide("themeColor",n.themeColor),e.provide("loadingEntitySizePx",ut.value),e.provide("rowHeight",E.value),e.provide("rowBorderColor",f.value),e.provide("footerBackgroundColor",c.value),e.provide("footerFontColor",S.value);const O=e.useSlots(),gt=e.computed(()=>O.body),ht=e.computed(()=>O.pagination),yt=e.computed(()=>O.loading),re=e.computed(()=>O.expand),le=e.ref(),Q=e.ref();e.provide("dataTable",le);const se=e.ref(!1);e.onMounted(()=>{Q.value.addEventListener("scroll",()=>{se.value=Q.value.scrollLeft>0})});const u=e.computed({get:()=>{if(n.serverOptions){const{page:o,rowsPerPage:a,sortBy:t,sortType:s}=n.serverOptions;return{page:o,rowsPerPage:a,sortBy:t!=null?t:null,sortType:s!=null?s:null}}return null},set:o=>{l("update:serverOptions",o)}}),X=e.computed(()=>n.itemsSelected!==null),B=e.computed(()=>u.value!==null),xt=e.computed(()=>!B.value&&n.rowsItems.findIndex(o=>o===n.rowsPerPage)===-1?[n.rowsPerPage,...n.rowsItems]:n.rowsItems),_t=()=>n.sortBy!==""?{sortBy:n.sortBy,sortDesc:n.sortType==="desc"}:null,V=e.ref(_t()),W=e.computed(()=>n.headers.findIndex(o=>o.fixed)!==-1),kt=e.computed(()=>W.value?n.headers.filter(o=>o.fixed):[]),bt=e.computed(()=>n.headers.filter(o=>!o.fixed)),L=e.computed(()=>{const a=[...kt.value,...bt.value].map(p=>{const I=p;return p.sortable&&(I.sortType="none"),u.value&&p.value===u.value.sortBy&&u.value.sortType&&(I.sortType=u.value.sortType),!B.value&&V.value&&p.value===V.value.sortBy&&(I.sortType=V.value.sortDesc?"desc":"asc"),I});let t=[];re.value?t=[n.fixedExpand||W.value?{text:"",value:"expand",fixed:!0,width:n.expandColumnWidth}:{text:"",value:"expand"},...a]:t=a;let s=[];n.showIndex?s=[n.fixedIndex||W.value?{text:"#",value:"index",fixed:!0,width:n.indexColumnWidth}:{text:"#",value:"index"},...t]:s=t;let d=[];return X.value?d=[n.fixedCheckbox||W.value?{text:"checkbox",value:"checkbox",fixed:!0,width:mt.value}:{text:"checkbox",value:"checkbox"},...s]:d=s,d}),A=e.ref([]),Ct=o=>{const a=A.value.indexOf(o);a!==-1?A.value.splice(a,1):A.value.push(o)},N=e.computed(()=>L.value.filter(o=>o.fixed)),ie=e.computed(()=>N.value.length?N.value[N.value.length-1].value:""),St=o=>{var t;const a=(t=o.width)!=null?t:N.value.length?100:null;if(a)return`width: ${a}px; min-width: ${a}px;`},Bt=e.computed(()=>{if(!N.value.length)return[];const o=N.value.map(a=>{var t;return(t=a.width)!=null?t:100});return N.value.map((a,t)=>{var s,d;return{value:a.value,fixed:(s=a.fixed)!=null?s:!0,width:(d=a.width)!=null?d:100,distance:t===0?0:o.reduce((p,I,Vt)=>{let _e=p;return Vt<t&&(_e+=I),_e})}})}),ce=(o,a="th")=>{if(!N.value.length)return;const t=Bt.value.find(s=>s.value===o);if(t)return`left: ${t.distance}px;z-index: ${a==="th"?3:1}; position: sticky`},de=e.computed(()=>L.value.map(o=>o.value)),D=(o,a)=>{if(o.includes(".")){let t="";return o.split(".").forEach((d,p)=>{t=p===0?a[d]:t[d]}),t}return a[o]},Pt=(o,a)=>{const t=D(o,a);return Array.isArray(t)?t.join(","):t},P=e.computed({get:()=>{var o;return(o=n.itemsSelected)!=null?o:[]},set:o=>{l("update:itemsSelected",o)}}),pe=e.computed(()=>{if(!B.value&&n.searchValue!==""){const o=new RegExp(n.searchValue,"i");return n.items.filter(a=>o.test(n.searchField!==""?a[n.searchField]:Object.values(a).join(" ")))}return n.items}),F=e.computed(()=>{let o=[...pe.value];return n.filterOptions?(n.filterOptions.forEach(a=>{o=o.filter(t=>{const{field:s,comparison:d,criteria:p}=a;switch(d){case"=":return t[s]===p;case"!=":return t[s]!==p;case">":return t[s]>p;case"<":return t[s]<p;case"<=":return t[s]<=p;case">=":return t[s]>=p;case"between":return t[s]>=Math.min(...p)&&t[s]<=Math.max(...p);default:return t[s]===p}})}),o):pe.value}),q=e.computed(()=>P.value.length===0||P.value.every(a=>F.value.findIndex(t=>JSON.stringify(a)===JSON.stringify(t))===-1)?"noneSelected":P.value.length===F.value.length&&P.value.every(t=>F.value.findIndex(s=>JSON.stringify(t)===JSON.stringify(s))!==-1)?"allSelected":"partSelected"),y=e.ref(B.value?n.serverOptions.page:1),{items:Y}=e.toRefs(n);e.watch(Y,()=>{B.value||(y.value=1)},{deep:!0});const $=e.ref(B.value?n.serverOptions.rowsPerPage:n.rowsPerPage);e.watch($,o=>{u.value&&(u.value=R(C({},u.value),{page:1,rowsPerPage:o})),y.value=1});const wt=(o,a)=>{let t=null;a==="none"?t="asc":a==="asc"?t="desc":t=null,u.value?u.value=R(C({},u.value),{sortBy:t!==null?o:null,sortType:t}):t===null?V.value=null:V.value={sortBy:o,sortDesc:t==="desc"}},ue=e.computed(()=>{if(B.value)return n.items;if(V.value===null)return F.value;const{sortBy:o,sortDesc:a}=V.value;return[...F.value].sort((s,d)=>D(o,s)<D(o,d)?a?1:-1:D(o,s)>D(o,d)?a?-1:1:0)}),Z=e.computed(()=>B.value?n.serverItemsLength:F.value.length),fe=e.computed(()=>B.value?y.value*$.value:Math.min(F.value.length,y.value*$.value)),me=e.computed(()=>(y.value-1)*$.value+1),J=e.computed(()=>Math.ceil(Z.value/$.value)),U=e.computed(()=>y.value===J.value),G=e.computed(()=>y.value===1),{loading:T}=e.toRefs(n),v=()=>{if(!U.value&&!T.value)if(u.value){const o=y.value+1;u.value=R(C({},u.value),{page:o})}else y.value+=1},ee=()=>{if(!G.value&&!T.value)if(u.value){const o=y.value-1;u.value=R(C({},u.value),{page:o})}else y.value-=1},ge=o=>{T.value||(u.value?u.value=R(C({},u.value),{page:o}):y.value=o)};e.watch(T,(o,a)=>{u.value&&o===!1&&a===!0&&(y.value=u.value.page)});const he=e.computed(()=>B.value?n.items:ue.value.slice(me.value-1,fe.value)),ye=e.computed(()=>$.value*(y.value-1)+1),Nt=e.computed(()=>$.value*y.value),K=e.computed(()=>n.showIndex?he.value.map((o,a)=>C({index:ye.value+a},o)):he.value),xe=e.computed(()=>X.value?q.value==="allSelected"?K.value.map(o=>C({checkbox:!0},o)):q.value==="noneSelected"?K.value.map(o=>C({checkbox:!1},o)):K.value.map(o=>{const a=P.value.findIndex(t=>{const s=C({},o);return delete s.index,JSON.stringify(t)===JSON.stringify(s)})!==-1;return C({checkbox:a},o)}):K.value),$t=o=>{P.value=o?ue.value:[]},Et=o=>{const a=o.checkbox;if(delete o.checkbox,delete o.index,a)P.value=P.value.filter(t=>JSON.stringify(t)!==JSON.stringify(o));else{const t=P.value;t.unshift(o),P.value=t}},It=o=>{const a=C({},o);if(X.value){const{checkbox:t}=o;delete a.checkbox,a.isSelected=t}if(n.showIndex){const{index:t}=o;delete a.index,a.indexInCurrentPage=t}l("clickRow",a)};return _({clientItemsLength:Z,currentPageFirstIndex:ye,currentPageLastIndex:Nt,maxPaginationNumber:J,currentPaginationNumber:y,isLastPage:U,isFirstPage:G,nextPage:v,prevPage:ee,updatePage:ge}),(o,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataTable",ref:le,class:"vue3-easy-data-table"},[e.createElementVNode("div",{ref_key:"tableBody",ref:Q,class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"fixed-height":r.tableHeight,"show-shadow":se.value}])},[e.createElementVNode("table",{class:e.normalizeClass({fixed:e.unref(N).length})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,s)=>(e.openBlock(),e.createElementBlock("col",{key:s,style:e.normalizeStyle(St(t))},null,4))),128))]),e.unref(L).length&&!r.hideHeader?(e.openBlock(),e.createElementBlock("thead",Ue,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),(t,s)=>(e.openBlock(),e.createElementBlock("th",{key:s,class:e.normalizeClass({sortable:t.sortable,none:t.sortable&&t.sortType==="none",desc:t.sortable&&t.sortType==="desc",asc:t.sortable&&t.sortType==="asc",fixed:t.fixed,"has-shadow":t.value===e.unref(ie),"no-padding":r.noThPadding}),style:e.normalizeStyle(ce(t.value)),onClick:e.withModifiers(d=>t.sortable&&t.sortType?wt(t.value,t.sortType):null,["stop"])},[t.text==="checkbox"?(e.openBlock(),e.createBlock(we,{key:e.unref(q),status:e.unref(q),onChange:$t},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ke,[e.unref(O)[`header-${t.value}`]?e.renderSlot(o.$slots,`header-${t.value}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):(e.openBlock(),e.createElementBlock("span",Qe,e.toDisplayString(t.text),1)),t.sortable?(e.openBlock(),e.createElementBlock("i",{key:t.sortType?t.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:t.sortType==="desc"}])},null,2)):e.createCommentVNode("",!0)]))],14,Ge))),128))])])):e.createCommentVNode("",!0),e.unref(gt)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.unref(Y).length&&e.unref(de).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating,"hover-to-change-color":r.hoverToChangeColor})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(xe),(t,s)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s},[e.createElementVNode("tr",{onClick:d=>It(t)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(de),(d,p)=>(e.openBlock(),e.createElementBlock("td",{key:p,style:e.normalizeStyle(ce(d,"td")),class:e.normalizeClass({"has-shadow":d===e.unref(ie),"no-padding":r.noTdPadding,"can-expand":d==="expand"})},[e.unref(O)[`item-${d}`]?e.renderSlot(o.$slots,`item-${d}`,e.normalizeProps(e.mergeProps({key:0},t)),void 0,!0):d==="expand"?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(["expand-icon",{expanding:A.value.includes(s)}]),onClick:e.withModifiers(I=>Ct(s),["stop"])},null,10,Ye)):d==="checkbox"?(e.openBlock(),e.createBlock(Ie,{key:2,checked:t[d],onChange:I=>Et(t)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createTextVNode(e.toDisplayString(Pt(d,t)),1)],64))],6))),128))],8,Xe),e.unref(re)&&A.value.includes(s)?(e.openBlock(),e.createElementBlock("tr",Ze,[e.createElementVNode("td",{class:"expand-td",colspan:e.unref(L).length},[e.renderSlot(o.$slots,"expand",e.normalizeProps(e.guardReactiveProps(t)),void 0,!0)],8,ve)])):e.createCommentVNode("",!0)],64))),128))],2)):e.createCommentVNode("",!0)],64))],2),e.unref(T)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["loading-wrapper",{"initial-loading":!e.unref(Y).length&&e.unref(T)}])},[e.createElementVNode("div",{class:e.normalizeClass(["loading-mask",{"no-footer":r.hideFooter}])},null,2),e.createElementVNode("div",et,[e.unref(yt)?e.renderSlot(o.$slots,"loading",{key:0},void 0,!0):(e.openBlock(),e.createBlock(Me,{key:1}))])],2)):e.createCommentVNode("",!0),!e.unref(xe).length&&!e.unref(T)?(e.openBlock(),e.createElementBlock("div",tt,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0)],2),r.hideFooter?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ot,[r.hideRowsPerPage?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",nt,[e.createTextVNode(e.toDisplayString(r.rowsPerPageMessage)+" ",1),e.createVNode(Oe,{modelValue:$.value,"onUpdate:modelValue":a[0]||(a[0]=t=>$.value=t),"rows-items":e.unref(xt)},null,8,["modelValue","rows-items"])])),e.createElementVNode("div",at,e.toDisplayString(`${e.unref(me)}-${e.unref(fe)}`)+" of "+e.toDisplayString(e.unref(Z)),1),e.unref(ht)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:1},{isFirstPage:e.unref(G),isLastPage:e.unref(U),currentPaginationNumber:y.value,maxPaginationNumber:e.unref(J),nextPage:v,prevPage:ee})),void 0,!0):(e.openBlock(),e.createBlock(Je,{key:2,"is-first-page":e.unref(G),"is-last-page":e.unref(U),onClickNextPage:v,onClickPrevPage:ee},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(je,{"current-pagination-number":y.value,"max-pagination-number":e.unref(J),onUpdatePage:ge},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))]))],512))}}),[["__scopeId","data-v-4ebd2b7e"]]);return typeof window!="undefined"&&window.Vue&&window.Vue.createApp({}).component("Vue3EasyDataTable",oe),oe}); |
@@ -6,3 +6,3 @@ { | ||
"private": false, | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"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
94326