vue3-easy-data-table
Advanced tools
Comparing version 1.0.17 to 1.0.18
@@ -523,10 +523,10 @@ var __defProp = Object.defineProperty; | ||
useCssVars((_ctx) => ({ | ||
"0f664642": unref(borderColor), | ||
"28cc12be": unref(maxHeightPx), | ||
"a88d63e6": unref(fontSizePx), | ||
"4df95d98": unref(rowHeightPx), | ||
"68fc4a72": unref(headerFontColor), | ||
"653e2673": __props.headerBackgroundColor, | ||
"5b2ee9ec": unref(rowHoverColor), | ||
"7177a9bd": unref(bodyFontColor) | ||
"6de0e75a": unref(borderColor), | ||
"3b154e62": unref(maxHeightPx), | ||
"9c92fc48": unref(fontSizePx), | ||
"daa6d176": unref(rowHeightPx), | ||
"01822003": unref(headerFontColor), | ||
"4bb7cb44": __props.headerBackgroundColor, | ||
"4f9eefbd": unref(rowHoverColor), | ||
"65e7af8e": unref(bodyFontColor) | ||
})); | ||
@@ -548,2 +548,3 @@ const { | ||
const ifHasBodySlot = computed(() => slots.body); | ||
const ifHasPaginationSlot = computed(() => slots.pagination); | ||
const serverOptionsComputed = computed({ | ||
@@ -721,2 +722,6 @@ get: () => { | ||
expose({ | ||
maxPaginationNumber, | ||
currentPaginationNumber, | ||
isFirstPage, | ||
isLastPage, | ||
prevPage, | ||
@@ -862,3 +867,4 @@ nextPage | ||
createElementVNode("div", _hoisted_12, toDisplayString(`${unref(firstIndexOfItemsInCurrentPage)}-${unref(lastIndexOfItemsInCurrentPage)}`) + " of " + toDisplayString(unref(totalItemsLength)), 1), | ||
createVNode(PaginationArrows, { | ||
unref(ifHasPaginationSlot) ? renderSlot(_ctx.$slots, "pagination", { key: 0 }, void 0, true) : (openBlock(), createBlock(PaginationArrows, { | ||
key: 1, | ||
"is-first-page": unref(isFirstPage), | ||
@@ -879,3 +885,3 @@ "is-last-page": unref(isLastPage), | ||
} : void 0 | ||
]), 1032, ["is-first-page", "is-last-page"]) | ||
]), 1032, ["is-first-page", "is-last-page"])) | ||
]) | ||
@@ -886,3 +892,3 @@ ]); | ||
}); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-377a37e2"]]); | ||
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7d7f890a"]]); | ||
export { DataTable as default }; |
@@ -1,1 +0,1 @@ | ||
(function(e,m){typeof exports=="object"&&typeof module!="undefined"?module.exports=m(require("vue")):typeof define=="function"&&define.amd?define(["vue"],m):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=m(e.Vue))})(this,function(e){"use strict";var qe=Object.defineProperty,Re=Object.defineProperties;var Je=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var We=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var Q=(e,m,u)=>m in e?qe(e,m,{enumerable:!0,configurable:!0,writable:!0,value:u}):e[m]=u,x=(e,m)=>{for(var u in m||(m={}))We.call(m,u)&&Q(e,u,m[u]);if(K)for(var u of K(m))Ue.call(m,u)&&Q(e,u,m[u]);return e},V=(e,m)=>Re(e,Je(m));var m="",u=(r,f)=>{const s=r.__vccOpts||r;for(const[t,d]of f)s[t]=d;return s};const X=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),Y=["onClick"],Z=["checked"],v=X(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ee=u(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:f}){const s=r;e.useCssVars(B=>({"7f84b28f":e.unref(b)}));const t=e.computed(()=>s.status==="allSelected"),d=()=>{f("change",!t.value)},b=e.inject("themeColor");return(B,P)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(d,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(t),class:e.normalizeClass(r.status)},null,10,Z),v],8,Y))}}),[["__scopeId","data-v-566775ba"]]),Ke="";const te=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),oe=["checked"],ne=te(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var ae=u(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:f}){e.useCssVars(t=>({"20cfc5a0":e.unref(s)}));const s=e.inject("themeColor");return(t,d)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:d[0]||(d[0]=e.withModifiers(b=>f("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,oe),ne]))}}),[["__scopeId","data-v-39f156fd"]]),Xe="";const re=r=>(e.pushScopeId("data-v-490fbe16"),r=r(),e.popScopeId(),r),se={class:"easy-data-table__rows-selector"},le={class:"rows-input"},ce=re(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),ie=["onClick"];var de=u(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:f}){const s=r;e.useCssVars(h=>({"10352173":e.unref(E)}));const t=e.ref(!1),d=e.computed({get:()=>s.modelValue,set:h=>{f("update:modelValue",h)}}),b=h=>{d.value=h,t.value=!1},B=(h,l)=>{let a=h.parentNode;for(;a!=null;){if(a.classList&&a.classList.contains(l))return!0;a=a.parentNode}return!1},P=h=>{B(h.target,"easy-data-table__rows-selector")||(t.value=!1)};e.onMounted(()=>{document.addEventListener("click",P)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",P)});const E=e.inject("themeColor");return(h,l)=>(e.openBlock(),e.createElementBlock("div",se,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:l[0]||(l[0]=a=>t.value=!t.value)},[e.createElementVNode("div",le,e.toDisplayString(e.unref(d)),1),ce]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:t.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,a=>(e.openBlock(),e.createElementBlock("li",{key:a,class:e.normalizeClass({selected:a===e.unref(d)}),onClick:p=>b(a)},e.toDisplayString(a),11,ie))),128))],2)]))}}),[["__scopeId","data-v-490fbe16"]]),Ze="";const pe={class:"loader-line"};var ue=u(e.defineComponent({setup(r){e.useCssVars(s=>({"38295e65":e.unref(f)}));const f=e.inject("themeColor");return(s,t)=>(e.openBlock(),e.createElementBlock("div",pe))}}),[["__scopeId","data-v-1ec0ad4e"]]),et="";const me={class:"buttons-pagination"},fe=["onClick"];var ge=u(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:f}){const s=r;e.useCssVars(l=>({e0267a50:e.unref(E),"6e139f9a":e.unref(P),c360928e:e.unref(h)}));const t=7,d=l=>{l.type==="button"&&!l.active&&f("updatePage",l.page)},b=e.computed(()=>{const l=[];if(s.maxPaginationNumber<=t)for(let a=1;a<=s.maxPaginationNumber;a+=1)l.push({type:"button",page:a,active:a===s.currentPaginationNumber});else if([1,2,s.maxPaginationNumber,s.maxPaginationNumber-1].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)if(a<=3)l.push({type:"button",page:a,active:a===s.currentPaginationNumber});else if(a===4)l.push({type:"omission"});else{const p=s.maxPaginationNumber-(t-a);l.push({type:"button",page:p,active:p===s.currentPaginationNumber})}else if([3,4].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)a<=5?l.push({type:"button",page:a,active:a===s.currentPaginationNumber}):a===6?l.push({type:"omission"}):l.push({type:"button",page:s.maxPaginationNumber,active:s.maxPaginationNumber===s.currentPaginationNumber});else if([s.maxPaginationNumber-2,s.maxPaginationNumber-3].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)if(a===1)l.push({type:"button",page:1,active:s.currentPaginationNumber===1});else if(a===2)l.push({type:"omission"});else{const p=s.maxPaginationNumber-(t-a);l.push({type:"button",page:p,active:p===s.currentPaginationNumber})}else for(let a=1;a<=t;a+=1)if(a===1)l.push({type:"button",page:1,active:s.currentPaginationNumber===1});else if(a===2||a===6)l.push({type:"omission"});else if(a===7)l.push({type:"button",page:s.maxPaginationNumber,active:s.maxPaginationNumber===s.currentPaginationNumber});else{const p=4-a,$=s.currentPaginationNumber-p;l.push({type:"button",page:$,active:$===s.currentPaginationNumber})}return l}),B=e.inject("rowHeight"),P=e.computed(()=>`${B*.6}px`),E=e.inject("borderColor"),h=e.inject("themeColor");return(l,a)=>(e.openBlock(),e.createElementBlock("div",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),(p,$)=>(e.openBlock(),e.createElementBlock("div",{key:$,class:e.normalizeClass(["item",{button:p.type==="button",active:p.type==="button"&&p.active,omission:p.type==="omission"}]),onClick:g=>d(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,fe))),128))]))}}),[["__scopeId","data-v-69ff0f2b"]]),ot="";const D=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),_e=[D(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],he=[D(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var ye=u(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:f}){const s=e.useSlots();return(t,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:d[0]||(d[0]=b=>f("clickPrevPage"))},_e,2),e.unref(s).buttonsPagination?e.renderSlot(t.$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:d[1]||(d[1]=b=>f("clickNextPage"))},he,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);const be={class:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48"},ke=[e.createElementVNode("path",{d:"M576 234.688V1024H448V234.688L213.312 469.312 128 384 512 0l384 384-85.312 85.312L576 234.688z",fill:"#373D41"},null,-1)];function xe(r,f){return e.openBlock(),e.createElementBlock("svg",be,ke)}var Se={render:xe},lt="";const Ce={class:"data-table"},Be={key:0},Pe=["onClick"],Ne={key:1,class:"header-text__wrapper"},we={class:"header-text"},$e=["colspan"],Ve={key:0,class:"data-table__message"},Ee={key:1,class:"data-table__message"},Ie={class:"data-table__footer"},Fe={class:"footer__rows-per-page"},Le=e.createTextVNode(" rows per page: "),Te={class:"footer__items-index"};var Oe=u(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},borderColor:{type:String,default:"#e0e0e0"},bodyFontColor:{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"},bodyFontSize:{type:Number,default:12},headers:{type:Array,required:!0},items:{type:Array,required:!0},maxHeight:{type:Number,default:()=>null},wrapLines:{type:Boolean,default:!1},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]},rowHoverColor:{type:String,default:"#eee"},loading:{type:Boolean,deault:!1},loadingMessage:{type:String,default:"Loading, please wait."},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}},emits:["update:itemsSelected","update:serverOptions"],setup(r,{expose:f,emit:s}){const t=r;e.useCssVars(o=>({"0f664642":e.unref(d),"28cc12be":e.unref(a),a88d63e6:e.unref(E),"4df95d98":e.unref(l),"68fc4a72":e.unref(b),"653e2673":r.headerBackgroundColor,"5b2ee9ec":e.unref(P),"7177a9bd":e.unref(B)}));const{borderColor:d,headerFontColor:b,bodyFontColor:B,rowHoverColor:P}=e.toRefs(t),E=e.computed(()=>`${t.bodyFontSize}px`),h=e.computed(()=>t.bodyFontSize*(t.dense?2:3)),l=e.computed(()=>`${h.value}px`),a=e.computed(()=>t.maxHeight?`${t.maxHeight}px`:null);e.provide("themeColor",t.themeColor),e.provide("rowHeight",h.value),e.provide("borderColor",d.value);const p=e.useSlots(),$=e.computed(()=>p.body),g=e.computed({get:()=>{if(t.serverOptions){const{page:o,rowsPerPage:c,sortBy:n,sortType:i}=t.serverOptions;return{page:o,rowsPerPage:c,sortBy:n!=null?n:null,sortType:i!=null?i:null}}return{page:1,rowsPerPage:25,sortBy:null,sortType:null}},set:o=>{s("update:serverOptions",o)}}),z=e.computed(()=>t.itemsSelected!==null),_=e.computed(()=>t.serverOptions!==null),De=()=>t.sortBy!==""?{sortBy:t.sortBy,sortDesc:t.sortType==="desc"}:null,N=e.ref(De()),T=e.computed(()=>{const o=t.headers.map(i=>{const k=i;return i.sortable&&(k.sortType="none"),_.value&&i.value===g.value.sortBy&&g.value.sortType&&(k.sortType=g.value.sortType),!_.value&&N.value&&i.value===N.value.sortBy&&(k.sortType=N.value.sortDesc?"desc":"asc"),k}),c=t.showIndex?[{text:"#",value:"index"},...o]:o;return z.value?[{text:"checkbox",value:"checkbox"},...c]:c}),O=e.computed(()=>T.value.map(o=>o.value)),S=e.computed({get:()=>{var o;return(o=t.itemsSelected)!=null?o:[]},set:o=>{s("update:itemsSelected",o)}}),F=e.computed(()=>S.value.length===t.items.length?"allSelected":S.value.length===0?"noneSelected":"partSelected"),I=e.computed(()=>{if(!_.value&&t.searchValue!==""){const o=new RegExp(t.searchValue,"i");return t.items.filter(c=>o.test(t.searchField!==""?c[t.searchField]:Object.values(c).join(" ")))}return t.items}),y=e.ref(_.value?t.serverOptions.page:1),C=e.ref(_.value?t.serverOptions.rowsPerPage:t.rowsPerPage);e.watch(C,o=>{_.value&&(g.value=V(x({},g.value),{page:1,rowsPerPage:o})),y.value=1});const ze=(o,c)=>{let n=null;c==="none"?n="asc":c==="asc"?n="desc":n=null,_.value?g.value=V(x({},g.value),{sortBy:n!==null?o:null,sortType:n}):n===null?N.value=null:N.value={sortBy:o,sortDesc:n==="desc"}},He=e.computed(()=>{if(_.value)return t.items;if(N.value===null)return I.value;const{sortBy:o,sortDesc:c}=N.value;return[...I.value].sort((i,k)=>i[o]<k[o]?c?1:-1:i[o]>k[o]?c?-1:1:0)}),H=e.computed(()=>_.value?t.serverItemsLength:I.value.length),A=e.computed(()=>_.value?y.value*C.value:Math.min(I.value.length,y.value*C.value)),M=e.computed(()=>(y.value-1)*C.value+1),j=e.computed(()=>Math.ceil(H.value/C.value)),q=e.computed(()=>y.value===j.value),R=e.computed(()=>y.value===1),{loading:w}=e.toRefs(t),J=()=>{if(!q.value&&!w.value)if(_.value){const o=y.value+1;g.value=V(x({},g.value),{page:o})}else y.value+=1},W=()=>{if(!R.value&&!w.value)if(_.value){const o=y.value-1;g.value=V(x({},g.value),{page:o})}else y.value-=1};f({prevPage:W,nextPage:J});const Ae=o=>{w.value||(_.value?g.value=V(x({},g.value),{page:o}):y.value=o)};e.watch(w,(o,c)=>{_.value&&o===!1&&c===!0&&(y.value=g.value.page)});const U=e.computed(()=>_.value?t.items:He.value.slice(M.value-1,A.value)),L=e.computed(()=>{if(t.showIndex){const o=C.value*(y.value-1);return U.value.map((c,n)=>x({index:o+n+1},c))}return U.value}),G=e.computed(()=>z.value?F.value==="allSelected"?L.value.map(o=>x({checkbox:!0},o)):F.value==="noneSelected"?L.value.map(o=>x({checkbox:!1},o)):L.value.map(o=>{const c=S.value.findIndex(n=>JSON.stringify(n)===JSON.stringify(o))!==-1;return x({checkbox:c},o)}):L.value),Me=o=>{S.value=o?I.value:[]},je=o=>{const c=o.checkbox;if(delete o.checkbox,c)S.value=S.value.filter(n=>JSON.stringify(n)!==JSON.stringify(o));else{const n=S.value;n.unshift(o),S.value=n}};return(o,c)=>(e.openBlock(),e.createElementBlock("div",Ce,[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"wrap-lines":r.wrapLines}])},[e.createElementVNode("table",null,[e.unref(T).length?(e.openBlock(),e.createElementBlock("thead",Be,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(T),(n,i)=>(e.openBlock(),e.createElementBlock("th",{key:i,class:e.normalizeClass({sortable:n.sortable,none:n.sortable&&n.sortType==="none",desc:n.sortable&&n.sortType==="desc",asc:n.sortable&&n.sortType==="asc"}),onClick:k=>n.sortable&&n.sortType?ze(n.value,n.sortType):null},[n.text==="checkbox"?(e.openBlock(),e.createBlock(ee,{key:e.unref(F),status:e.unref(F),onChange:Me},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",Ne,[e.createElementVNode("span",we,e.toDisplayString(n.text),1),n.sortable?(e.openBlock(),e.createBlock(e.unref(Se),{key:n.sortType?n.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:n.sortType==="desc"}])},null,8,["class"])):e.createCommentVNode("",!0)]))],10,Pe))),128))]),e.unref(w)?(e.openBlock(),e.createElementBlock("th",{key:0,class:"loading-th",colspan:e.unref(O).length},[e.createVNode(ue)],8,$e)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref($)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[r.items.length&&e.unref(O).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(G),n=>(e.openBlock(),e.createElementBlock("tr",{key:JSON.stringify(n)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(O),(i,k)=>(e.openBlock(),e.createElementBlock("td",{key:k},[e.unref(p)[i]?e.renderSlot(o.$slots,i,e.normalizeProps(e.mergeProps({key:0},n)),void 0,!0):i==="checkbox"?(e.openBlock(),e.createBlock(ae,{key:1,checked:n[i],onChange:it=>je(n)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(Array.isArray(n[i])?n[i].join(","):n[i]),1)],64))]))),128))]))),128))],2)):e.createCommentVNode("",!0)],64))]),!e.unref(G).length&&!e.unref(w)?(e.openBlock(),e.createElementBlock("div",Ve,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0),!r.items.length&&e.unref(w)?(e.openBlock(),e.createElementBlock("div",Ee,e.toDisplayString(r.loadingMessage),1)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",Ie,[e.createElementVNode("div",Fe,[Le,e.createVNode(de,{modelValue:C.value,"onUpdate:modelValue":c[0]||(c[0]=n=>C.value=n),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",Te,e.toDisplayString(`${e.unref(M)}-${e.unref(A)}`)+" of "+e.toDisplayString(e.unref(H)),1),e.createVNode(ye,{"is-first-page":e.unref(R),"is-last-page":e.unref(q),onClickNextPage:J,onClickPrevPage:W},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(ge,{"current-pagination-number":y.value,"max-pagination-number":e.unref(j),onUpdatePage:Ae},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"])])]))}}),[["__scopeId","data-v-377a37e2"]]);return Oe}); | ||
(function(e,m){typeof exports=="object"&&typeof module!="undefined"?module.exports=m(require("vue")):typeof define=="function"&&define.amd?define(["vue"],m):(e=typeof globalThis!="undefined"?globalThis:e||self,e["vue3-easy-data-table"]=m(e.Vue))})(this,function(e){"use strict";var Re=Object.defineProperty,Je=Object.defineProperties;var We=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var Ue=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var X=(e,m,u)=>m in e?Re(e,m,{enumerable:!0,configurable:!0,writable:!0,value:u}):e[m]=u,x=(e,m)=>{for(var u in m||(m={}))Ue.call(m,u)&&X(e,u,m[u]);if(Q)for(var u of Q(m))Ge.call(m,u)&&X(e,u,m[u]);return e},V=(e,m)=>Je(e,We(m));var m="",u=(r,f)=>{const s=r.__vccOpts||r;for(const[t,d]of f)s[t]=d;return s};const Y=r=>(e.pushScopeId("data-v-566775ba"),r=r(),e.popScopeId(),r),Z=["onClick"],v=["checked"],ee=Y(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var te=u(e.defineComponent({props:{status:{type:String,required:!0}},emits:["change"],setup(r,{emit:f}){const s=r;e.useCssVars(C=>({"7f84b28f":e.unref(k)}));const t=e.computed(()=>s.status==="allSelected"),d=()=>{f("change",!t.value)},k=e.inject("themeColor");return(C,P)=>(e.openBlock(),e.createElementBlock("div",{class:"multi-select__checkbox",onClick:e.withModifiers(d,["stop","prevent"])},[e.createElementVNode("input",{type:"checkbox",checked:e.unref(t),class:e.normalizeClass(r.status)},null,10,v),ee],8,Z))}}),[["__scopeId","data-v-566775ba"]]),Qe="";const oe=r=>(e.pushScopeId("data-v-39f156fd"),r=r(),e.popScopeId(),r),ne=["checked"],ae=oe(()=>e.createElementVNode("label",{for:"checbox"},null,-1));var re=u(e.defineComponent({props:{checked:{type:Boolean,required:!0}},emits:["change"],setup(r,{emit:f}){e.useCssVars(t=>({"20cfc5a0":e.unref(s)}));const s=e.inject("themeColor");return(t,d)=>(e.openBlock(),e.createElementBlock("div",{class:"single-select__checkbox",onClick:d[0]||(d[0]=e.withModifiers(k=>f("change"),["stop","prevent"]))},[e.createElementVNode("input",{type:"checkbox",checked:r.checked},null,8,ne),ae]))}}),[["__scopeId","data-v-39f156fd"]]),Ye="";const se=r=>(e.pushScopeId("data-v-490fbe16"),r=r(),e.popScopeId(),r),le={class:"easy-data-table__rows-selector"},ce={class:"rows-input"},ie=se(()=>e.createElementVNode("div",{class:"triangle"},null,-1)),de=["onClick"];var pe=u(e.defineComponent({props:{modelValue:{type:Number,required:!0},rowsItems:{type:Array,required:!0}},emits:["update:modelValue"],setup(r,{emit:f}){const s=r;e.useCssVars(h=>({"10352173":e.unref(E)}));const t=e.ref(!1),d=e.computed({get:()=>s.modelValue,set:h=>{f("update:modelValue",h)}}),k=h=>{d.value=h,t.value=!1},C=(h,l)=>{let a=h.parentNode;for(;a!=null;){if(a.classList&&a.classList.contains(l))return!0;a=a.parentNode}return!1},P=h=>{C(h.target,"easy-data-table__rows-selector")||(t.value=!1)};e.onMounted(()=>{document.addEventListener("click",P)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",P)});const E=e.inject("themeColor");return(h,l)=>(e.openBlock(),e.createElementBlock("div",le,[e.createElementVNode("div",{class:"rows-input__wrapper",onClick:l[0]||(l[0]=a=>t.value=!t.value)},[e.createElementVNode("div",ce,e.toDisplayString(e.unref(d)),1),ie]),e.createElementVNode("ul",{class:e.normalizeClass(["select-items",{show:t.value}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.rowsItems,a=>(e.openBlock(),e.createElementBlock("li",{key:a,class:e.normalizeClass({selected:a===e.unref(d)}),onClick:p=>k(a)},e.toDisplayString(a),11,de))),128))],2)]))}}),[["__scopeId","data-v-490fbe16"]]),ve="";const ue={class:"loader-line"};var me=u(e.defineComponent({setup(r){e.useCssVars(s=>({"38295e65":e.unref(f)}));const f=e.inject("themeColor");return(s,t)=>(e.openBlock(),e.createElementBlock("div",ue))}}),[["__scopeId","data-v-1ec0ad4e"]]),tt="";const fe={class:"buttons-pagination"},ge=["onClick"];var _e=u(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:f}){const s=r;e.useCssVars(l=>({e0267a50:e.unref(E),"6e139f9a":e.unref(P),c360928e:e.unref(h)}));const t=7,d=l=>{l.type==="button"&&!l.active&&f("updatePage",l.page)},k=e.computed(()=>{const l=[];if(s.maxPaginationNumber<=t)for(let a=1;a<=s.maxPaginationNumber;a+=1)l.push({type:"button",page:a,active:a===s.currentPaginationNumber});else if([1,2,s.maxPaginationNumber,s.maxPaginationNumber-1].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)if(a<=3)l.push({type:"button",page:a,active:a===s.currentPaginationNumber});else if(a===4)l.push({type:"omission"});else{const p=s.maxPaginationNumber-(t-a);l.push({type:"button",page:p,active:p===s.currentPaginationNumber})}else if([3,4].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)a<=5?l.push({type:"button",page:a,active:a===s.currentPaginationNumber}):a===6?l.push({type:"omission"}):l.push({type:"button",page:s.maxPaginationNumber,active:s.maxPaginationNumber===s.currentPaginationNumber});else if([s.maxPaginationNumber-2,s.maxPaginationNumber-3].includes(s.currentPaginationNumber))for(let a=1;a<=t;a+=1)if(a===1)l.push({type:"button",page:1,active:s.currentPaginationNumber===1});else if(a===2)l.push({type:"omission"});else{const p=s.maxPaginationNumber-(t-a);l.push({type:"button",page:p,active:p===s.currentPaginationNumber})}else for(let a=1;a<=t;a+=1)if(a===1)l.push({type:"button",page:1,active:s.currentPaginationNumber===1});else if(a===2||a===6)l.push({type:"omission"});else if(a===7)l.push({type:"button",page:s.maxPaginationNumber,active:s.maxPaginationNumber===s.currentPaginationNumber});else{const p=4-a,$=s.currentPaginationNumber-p;l.push({type:"button",page:$,active:$===s.currentPaginationNumber})}return l}),C=e.inject("rowHeight"),P=e.computed(()=>`${C*.6}px`),E=e.inject("borderColor"),h=e.inject("themeColor");return(l,a)=>(e.openBlock(),e.createElementBlock("div",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(k),(p,$)=>(e.openBlock(),e.createElementBlock("div",{key:$,class:e.normalizeClass(["item",{button:p.type==="button",active:p.type==="button"&&p.active,omission:p.type==="omission"}]),onClick:M=>d(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,ge))),128))]))}}),[["__scopeId","data-v-69ff0f2b"]]),nt="";const A=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),he=[A(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],ye=[A(()=>e.createElementVNode("span",{class:"arrow arrow-left"},null,-1))];var ke=u(e.defineComponent({props:{isFirstPage:{type:Boolean,required:!1},isLastPage:{type:Boolean,required:!1}},emits:["clickPrevPage","clickNextPage"],setup(r,{emit:f}){const s=e.useSlots();return(t,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["previous-page__click-button",{"first-page":r.isFirstPage}]),onClick:d[0]||(d[0]=k=>f("clickPrevPage"))},he,2),e.unref(s).buttonsPagination?e.renderSlot(t.$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:d[1]||(d[1]=k=>f("clickNextPage"))},ye,2)],64))}}),[["__scopeId","data-v-c9da5286"]]);const be={class:"icon",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48"},xe=[e.createElementVNode("path",{d:"M576 234.688V1024H448V234.688L213.312 469.312 128 384 512 0l384 384-85.312 85.312L576 234.688z",fill:"#373D41"},null,-1)];function Se(r,f){return e.openBlock(),e.createElementBlock("svg",be,xe)}var Be={render:Se},ct="";const Ce={class:"data-table"},Pe={key:0},Ne=["onClick"],we={key:1,class:"header-text__wrapper"},$e={class:"header-text"},Ve=["colspan"],Ee={key:0,class:"data-table__message"},Ie={key:1,class:"data-table__message"},Fe={class:"data-table__footer"},Le={class:"footer__rows-per-page"},Te=e.createTextVNode(" rows per page: "),Oe={class:"footer__items-index"};var De=u(e.defineComponent({props:{alternating:{type:Boolean,default:!1},buttonsPagination:{type:Boolean,default:!1},borderColor:{type:String,default:"#e0e0e0"},bodyFontColor:{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"},bodyFontSize:{type:Number,default:12},headers:{type:Array,required:!0},items:{type:Array,required:!0},maxHeight:{type:Number,default:()=>null},wrapLines:{type:Boolean,default:!1},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]},rowHoverColor:{type:String,default:"#eee"},loading:{type:Boolean,deault:!1},loadingMessage:{type:String,default:"Loading, please wait."},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}},emits:["update:itemsSelected","update:serverOptions"],setup(r,{expose:f,emit:s}){const t=r;e.useCssVars(o=>({"6de0e75a":e.unref(d),"3b154e62":e.unref(a),"9c92fc48":e.unref(E),daa6d176:e.unref(l),"01822003":e.unref(k),"4bb7cb44":r.headerBackgroundColor,"4f9eefbd":e.unref(P),"65e7af8e":e.unref(C)}));const{borderColor:d,headerFontColor:k,bodyFontColor:C,rowHoverColor:P}=e.toRefs(t),E=e.computed(()=>`${t.bodyFontSize}px`),h=e.computed(()=>t.bodyFontSize*(t.dense?2:3)),l=e.computed(()=>`${h.value}px`),a=e.computed(()=>t.maxHeight?`${t.maxHeight}px`:null);e.provide("themeColor",t.themeColor),e.provide("rowHeight",h.value),e.provide("borderColor",d.value);const p=e.useSlots(),$=e.computed(()=>p.body),M=e.computed(()=>p.pagination),y=e.computed({get:()=>{if(t.serverOptions){const{page:o,rowsPerPage:c,sortBy:n,sortType:i}=t.serverOptions;return{page:o,rowsPerPage:c,sortBy:n!=null?n:null,sortType:i!=null?i:null}}return{page:1,rowsPerPage:25,sortBy:null,sortType:null}},set:o=>{s("update:serverOptions",o)}}),j=e.computed(()=>t.itemsSelected!==null),g=e.computed(()=>t.serverOptions!==null),ze=()=>t.sortBy!==""?{sortBy:t.sortBy,sortDesc:t.sortType==="desc"}:null,N=e.ref(ze()),T=e.computed(()=>{const o=t.headers.map(i=>{const b=i;return i.sortable&&(b.sortType="none"),g.value&&i.value===y.value.sortBy&&y.value.sortType&&(b.sortType=y.value.sortType),!g.value&&N.value&&i.value===N.value.sortBy&&(b.sortType=N.value.sortDesc?"desc":"asc"),b}),c=t.showIndex?[{text:"#",value:"index"},...o]:o;return j.value?[{text:"checkbox",value:"checkbox"},...c]:c}),O=e.computed(()=>T.value.map(o=>o.value)),S=e.computed({get:()=>{var o;return(o=t.itemsSelected)!=null?o:[]},set:o=>{s("update:itemsSelected",o)}}),F=e.computed(()=>S.value.length===t.items.length?"allSelected":S.value.length===0?"noneSelected":"partSelected"),I=e.computed(()=>{if(!g.value&&t.searchValue!==""){const o=new RegExp(t.searchValue,"i");return t.items.filter(c=>o.test(t.searchField!==""?c[t.searchField]:Object.values(c).join(" ")))}return t.items}),_=e.ref(g.value?t.serverOptions.page:1),B=e.ref(g.value?t.serverOptions.rowsPerPage:t.rowsPerPage);e.watch(B,o=>{g.value&&(y.value=V(x({},y.value),{page:1,rowsPerPage:o})),_.value=1});const He=(o,c)=>{let n=null;c==="none"?n="asc":c==="asc"?n="desc":n=null,g.value?y.value=V(x({},y.value),{sortBy:n!==null?o:null,sortType:n}):n===null?N.value=null:N.value={sortBy:o,sortDesc:n==="desc"}},Ae=e.computed(()=>{if(g.value)return t.items;if(N.value===null)return I.value;const{sortBy:o,sortDesc:c}=N.value;return[...I.value].sort((i,b)=>i[o]<b[o]?c?1:-1:i[o]>b[o]?c?-1:1:0)}),q=e.computed(()=>g.value?t.serverItemsLength:I.value.length),R=e.computed(()=>g.value?_.value*B.value:Math.min(I.value.length,_.value*B.value)),J=e.computed(()=>(_.value-1)*B.value+1),D=e.computed(()=>Math.ceil(q.value/B.value)),z=e.computed(()=>_.value===D.value),H=e.computed(()=>_.value===1),{loading:w}=e.toRefs(t),W=()=>{if(!z.value&&!w.value)if(g.value){const o=_.value+1;y.value=V(x({},y.value),{page:o})}else _.value+=1},U=()=>{if(!H.value&&!w.value)if(g.value){const o=_.value-1;y.value=V(x({},y.value),{page:o})}else _.value-=1};f({maxPaginationNumber:D,currentPaginationNumber:_,isFirstPage:H,isLastPage:z,prevPage:U,nextPage:W});const Me=o=>{w.value||(g.value?y.value=V(x({},y.value),{page:o}):_.value=o)};e.watch(w,(o,c)=>{g.value&&o===!1&&c===!0&&(_.value=y.value.page)});const G=e.computed(()=>g.value?t.items:Ae.value.slice(J.value-1,R.value)),L=e.computed(()=>{if(t.showIndex){const o=B.value*(_.value-1);return G.value.map((c,n)=>x({index:o+n+1},c))}return G.value}),K=e.computed(()=>j.value?F.value==="allSelected"?L.value.map(o=>x({checkbox:!0},o)):F.value==="noneSelected"?L.value.map(o=>x({checkbox:!1},o)):L.value.map(o=>{const c=S.value.findIndex(n=>JSON.stringify(n)===JSON.stringify(o))!==-1;return x({checkbox:c},o)}):L.value),je=o=>{S.value=o?I.value:[]},qe=o=>{const c=o.checkbox;if(delete o.checkbox,c)S.value=S.value.filter(n=>JSON.stringify(n)!==JSON.stringify(o));else{const n=S.value;n.unshift(o),S.value=n}};return(o,c)=>(e.openBlock(),e.createElementBlock("div",Ce,[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"wrap-lines":r.wrapLines}])},[e.createElementVNode("table",null,[e.unref(T).length?(e.openBlock(),e.createElementBlock("thead",Pe,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(T),(n,i)=>(e.openBlock(),e.createElementBlock("th",{key:i,class:e.normalizeClass({sortable:n.sortable,none:n.sortable&&n.sortType==="none",desc:n.sortable&&n.sortType==="desc",asc:n.sortable&&n.sortType==="asc"}),onClick:b=>n.sortable&&n.sortType?He(n.value,n.sortType):null},[n.text==="checkbox"?(e.openBlock(),e.createBlock(te,{key:e.unref(F),status:e.unref(F),onChange:je},null,8,["status"])):(e.openBlock(),e.createElementBlock("span",we,[e.createElementVNode("span",$e,e.toDisplayString(n.text),1),n.sortable?(e.openBlock(),e.createBlock(e.unref(Be),{key:n.sortType?n.sortType:"none",class:e.normalizeClass(["sortType-icon",{desc:n.sortType==="desc"}])},null,8,["class"])):e.createCommentVNode("",!0)]))],10,Ne))),128))]),e.unref(w)?(e.openBlock(),e.createElementBlock("th",{key:0,class:"loading-th",colspan:e.unref(O).length},[e.createVNode(me)],8,Ve)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.unref($)?e.renderSlot(o.$slots,"body",{key:1},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[r.items.length&&e.unref(O).length?(e.openBlock(),e.createElementBlock("tbody",{key:0,class:e.normalizeClass({"row-alternation":r.alternating})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(K),n=>(e.openBlock(),e.createElementBlock("tr",{key:JSON.stringify(n)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(O),(i,b)=>(e.openBlock(),e.createElementBlock("td",{key:b},[e.unref(p)[i]?e.renderSlot(o.$slots,i,e.normalizeProps(e.mergeProps({key:0},n)),void 0,!0):i==="checkbox"?(e.openBlock(),e.createBlock(re,{key:1,checked:n[i],onChange:dt=>qe(n)},null,8,["checked","onChange"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(Array.isArray(n[i])?n[i].join(","):n[i]),1)],64))]))),128))]))),128))],2)):e.createCommentVNode("",!0)],64))]),!e.unref(K).length&&!e.unref(w)?(e.openBlock(),e.createElementBlock("div",Ee,e.toDisplayString(r.emptyMessage),1)):e.createCommentVNode("",!0),!r.items.length&&e.unref(w)?(e.openBlock(),e.createElementBlock("div",Ie,e.toDisplayString(r.loadingMessage),1)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",Fe,[e.createElementVNode("div",Le,[Te,e.createVNode(pe,{modelValue:B.value,"onUpdate:modelValue":c[0]||(c[0]=n=>B.value=n),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",Oe,e.toDisplayString(`${e.unref(J)}-${e.unref(R)}`)+" of "+e.toDisplayString(e.unref(q)),1),e.unref(M)?e.renderSlot(o.$slots,"pagination",{key:0},void 0,!0):(e.openBlock(),e.createBlock(ke,{key:1,"is-first-page":e.unref(H),"is-last-page":e.unref(z),onClickNextPage:W,onClickPrevPage:U},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(_e,{"current-pagination-number":_.value,"max-pagination-number":e.unref(D),onUpdatePage:Me},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))])]))}}),[["__scopeId","data-v-7d7f890a"]]);return De}); |
@@ -6,3 +6,3 @@ { | ||
"private": false, | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"types": "./types/main.d.ts", | ||
@@ -9,0 +9,0 @@ "files": [ |
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
74354
1006