Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue3-easy-data-table

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-easy-data-table - npm Package Compare versions

Comparing version 1.0.24 to 1.0.25

18

dist/vue3-easy-data-table.es.js

@@ -523,10 +523,10 @@ var __defProp = Object.defineProperty;

useCssVars((_ctx) => ({
"387cf8f3": unref(borderColor),
"51e2c56f": unref(maxHeightPx),
"42cdfd88": unref(fontSizePx),
"021a03e5": unref(rowHeightPx),
"25af86ba": unref(headerFontColor),
"bd842038": __props.headerBackgroundColor,
"cd389746": unref(rowHoverColor),
"a0a717a4": unref(bodyFontColor)
"27bc4fd9": unref(borderColor),
"41221c55": unref(maxHeightPx),
"b77f94d4": unref(fontSizePx),
"1d4d4a6a": unref(rowHeightPx),
"25149eee": unref(headerFontColor),
"67425f4a": __props.headerBackgroundColor,
"93ae2c7a": unref(rowHoverColor),
"671cacd8": unref(bodyFontColor)
}));

@@ -895,3 +895,3 @@ const {

});
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-20988f14"]]);
var DataTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e0181f12"]]);
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 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(B=>({"7f84b28f":e.unref(k)}));const t=e.computed(()=>s.status==="allSelected"),d=()=>{f("change",!t.value)},k=e.inject("themeColor");return(B,C)=>(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},B=(h,l)=>{let a=h.parentNode;for(;a!=null;){if(a.classList&&a.classList.contains(l))return!0;a=a.parentNode}return!1},C=h=>{B(h.target,"easy-data-table__rows-selector")||(t.value=!1)};e.onMounted(()=>{document.addEventListener("click",C)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",C)});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(C),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}),B=e.inject("rowHeight"),C=e.computed(()=>`${B*.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:q=>d(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,ge))),128))]))}}),[["__scopeId","data-v-69ff0f2b"]]),nt="";const j=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),he=[j(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],ye=[j(()=>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 Pe(r,f){return e.openBlock(),e.createElementBlock("svg",be,xe)}var Se={render:Pe},ct="";const Be={class:"data-table"},Ce={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 ze=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=>({"387cf8f3":e.unref(d),"51e2c56f":e.unref(a),"42cdfd88":e.unref(E),"021a03e5":e.unref(l),"25af86ba":e.unref(k),bd842038:r.headerBackgroundColor,cd389746:e.unref(C),a0a717a4:e.unref(B)}));const{borderColor:d,headerFontColor:k,bodyFontColor:B,rowHoverColor:C}=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),q=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)}}),R=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()),D=e.computed(()=>{const o=t.headers.map(i=>{const b=i;return i.sortable&&(b.sortType="none"),_.value&&i.value===y.value.sortBy&&y.value.sortType&&(b.sortType=y.value.sortType),!_.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 R.value?[{text:"checkbox",value:"checkbox"},...c]:c}),H=e.computed(()=>D.value.map(o=>o.value)),P=e.computed({get:()=>{var o;return(o=t.itemsSelected)!=null?o:[]},set:o=>{s("update:itemsSelected",o)}}),F=e.computed(()=>P.value.length===t.items.length?"allSelected":P.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}),g=e.ref(_.value?t.serverOptions.page:1),S=e.ref(_.value?t.serverOptions.rowsPerPage:t.rowsPerPage);e.watch(S,o=>{_.value&&(y.value=V(x({},y.value),{page:1,rowsPerPage:o})),g.value=1});const He=(o,c)=>{let n=null;c==="none"?n="asc":c==="asc"?n="desc":n=null,_.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(_.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)}),J=e.computed(()=>_.value?t.serverItemsLength:I.value.length),W=e.computed(()=>_.value?g.value*S.value:Math.min(I.value.length,g.value*S.value)),U=e.computed(()=>(g.value-1)*S.value+1),L=e.computed(()=>Math.ceil(J.value/S.value)),T=e.computed(()=>g.value===L.value),O=e.computed(()=>g.value===1),{loading:w}=e.toRefs(t),A=()=>{if(!T.value&&!w.value)if(_.value){const o=g.value+1;y.value=V(x({},y.value),{page:o})}else g.value+=1},M=()=>{if(!O.value&&!w.value)if(_.value){const o=g.value-1;y.value=V(x({},y.value),{page:o})}else g.value-=1};f({maxPaginationNumber:L,currentPaginationNumber:g,isLastPage:T,isFirstPage:O,nextPage:A,prevPage:M});const Me=o=>{w.value||(_.value?y.value=V(x({},y.value),{page:o}):g.value=o)};e.watch(w,(o,c)=>{_.value&&o===!1&&c===!0&&(g.value=y.value.page)});const G=e.computed(()=>_.value?t.items:Ae.value.slice(U.value-1,W.value)),z=e.computed(()=>{if(t.showIndex){const o=S.value*(g.value-1);return G.value.map((c,n)=>x({index:o+n+1},c))}return G.value}),K=e.computed(()=>R.value?F.value==="allSelected"?z.value.map(o=>x({checkbox:!0},o)):F.value==="noneSelected"?z.value.map(o=>x({checkbox:!1},o)):z.value.map(o=>{const c=P.value.findIndex(n=>JSON.stringify(n)===JSON.stringify(o))!==-1;return x({checkbox:c},o)}):z.value),je=o=>{P.value=o?I.value:[]},qe=o=>{const c=o.checkbox;if(delete o.checkbox,c)P.value=P.value.filter(n=>JSON.stringify(n)!==JSON.stringify(o));else{const n=P.value;n.unshift(o),P.value=n}};return(o,c)=>(e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"wrap-lines":r.wrapLines}])},[e.createElementVNode("table",null,[e.unref(D).length?(e.openBlock(),e.createElementBlock("thead",Ce,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(D),(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(Se),{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(H).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(H).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(H),(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:S.value,"onUpdate:modelValue":c[0]||(c[0]=n=>S.value=n),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",Oe,e.toDisplayString(`${e.unref(U)}-${e.unref(W)}`)+" of "+e.toDisplayString(e.unref(J)),1),e.unref(q)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:0},{isFirstPage:e.unref(O),isLastPage:e.unref(T),currentPaginationNumber:g.value,maxPaginationNumber:e.unref(L),nextPage:A,prevPage:M})),void 0,!0):(e.openBlock(),e.createBlock(ke,{key:1,"is-first-page":e.unref(O),"is-last-page":e.unref(T),onClickNextPage:A,onClickPrevPage:M},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(_e,{"current-pagination-number":g.value,"max-pagination-number":e.unref(L),onUpdatePage:Me},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))])]))}}),[["__scopeId","data-v-20988f14"]]);return ze});
(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,g)=>{const s=r.__vccOpts||r;for(const[t,d]of g)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:g}){const s=r;e.useCssVars(B=>({"7f84b28f":e.unref(k)}));const t=e.computed(()=>s.status==="allSelected"),d=()=>{g("change",!t.value)},k=e.inject("themeColor");return(B,C)=>(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:g}){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=>g("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:g}){const s=r;e.useCssVars(h=>({"10352173":e.unref(E)}));const t=e.ref(!1),d=e.computed({get:()=>s.modelValue,set:h=>{g("update:modelValue",h)}}),k=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},C=h=>{B(h.target,"easy-data-table__rows-selector")||(t.value=!1)};e.onMounted(()=>{document.addEventListener("click",C)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",C)});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(g)}));const g=e.inject("themeColor");return(s,t)=>(e.openBlock(),e.createElementBlock("div",ue))}}),[["__scopeId","data-v-1ec0ad4e"]]),tt="";const ge={class:"buttons-pagination"},fe=["onClick"];var _e=u(e.defineComponent({props:{maxPaginationNumber:{type:Number,required:!0},currentPaginationNumber:{type:Number,required:!0}},emits:["updatePage"],setup(r,{emit:g}){const s=r;e.useCssVars(l=>({e0267a50:e.unref(E),"6e139f9a":e.unref(C),c360928e:e.unref(h)}));const t=7,d=l=>{l.type==="button"&&!l.active&&g("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}),B=e.inject("rowHeight"),C=e.computed(()=>`${B*.6}px`),E=e.inject("borderColor"),h=e.inject("themeColor");return(l,a)=>(e.openBlock(),e.createElementBlock("div",ge,[(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:q=>d(p)},e.toDisplayString(p.type==="button"?p.page:"..."),11,fe))),128))]))}}),[["__scopeId","data-v-69ff0f2b"]]),nt="";const j=r=>(e.pushScopeId("data-v-c9da5286"),r=r(),e.popScopeId(),r),he=[j(()=>e.createElementVNode("span",{class:"arrow arrow-right"},null,-1))],ye=[j(()=>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:g}){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=>g("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=>g("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 Pe(r,g){return e.openBlock(),e.createElementBlock("svg",be,xe)}var Se={render:Pe},ct="";const Be={class:"data-table"},Ce={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 ze=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:g,emit:s}){const t=r;e.useCssVars(o=>({"27bc4fd9":e.unref(d),"41221c55":e.unref(a),b77f94d4:e.unref(E),"1d4d4a6a":e.unref(l),"25149eee":e.unref(k),"67425f4a":r.headerBackgroundColor,"93ae2c7a":e.unref(C),"671cacd8":e.unref(B)}));const{borderColor:d,headerFontColor:k,bodyFontColor:B,rowHoverColor:C}=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),q=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)}}),R=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()),D=e.computed(()=>{const o=t.headers.map(i=>{const b=i;return i.sortable&&(b.sortType="none"),_.value&&i.value===y.value.sortBy&&y.value.sortType&&(b.sortType=y.value.sortType),!_.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 R.value?[{text:"checkbox",value:"checkbox"},...c]:c}),H=e.computed(()=>D.value.map(o=>o.value)),P=e.computed({get:()=>{var o;return(o=t.itemsSelected)!=null?o:[]},set:o=>{s("update:itemsSelected",o)}}),F=e.computed(()=>P.value.length===t.items.length?"allSelected":P.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}),f=e.ref(_.value?t.serverOptions.page:1),S=e.ref(_.value?t.serverOptions.rowsPerPage:t.rowsPerPage);e.watch(S,o=>{_.value&&(y.value=V(x({},y.value),{page:1,rowsPerPage:o})),f.value=1});const He=(o,c)=>{let n=null;c==="none"?n="asc":c==="asc"?n="desc":n=null,_.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(_.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)}),J=e.computed(()=>_.value?t.serverItemsLength:I.value.length),W=e.computed(()=>_.value?f.value*S.value:Math.min(I.value.length,f.value*S.value)),U=e.computed(()=>(f.value-1)*S.value+1),L=e.computed(()=>Math.ceil(J.value/S.value)),T=e.computed(()=>f.value===L.value),O=e.computed(()=>f.value===1),{loading:w}=e.toRefs(t),A=()=>{if(!T.value&&!w.value)if(_.value){const o=f.value+1;y.value=V(x({},y.value),{page:o})}else f.value+=1},M=()=>{if(!O.value&&!w.value)if(_.value){const o=f.value-1;y.value=V(x({},y.value),{page:o})}else f.value-=1};g({maxPaginationNumber:L,currentPaginationNumber:f,isLastPage:T,isFirstPage:O,nextPage:A,prevPage:M});const Me=o=>{w.value||(_.value?y.value=V(x({},y.value),{page:o}):f.value=o)};e.watch(w,(o,c)=>{_.value&&o===!1&&c===!0&&(f.value=y.value.page)});const G=e.computed(()=>_.value?t.items:Ae.value.slice(U.value-1,W.value)),z=e.computed(()=>{if(t.showIndex){const o=S.value*(f.value-1);return G.value.map((c,n)=>x({index:o+n+1},c))}return G.value}),K=e.computed(()=>R.value?F.value==="allSelected"?z.value.map(o=>x({checkbox:!0},o)):F.value==="noneSelected"?z.value.map(o=>x({checkbox:!1},o)):z.value.map(o=>{const c=P.value.findIndex(n=>JSON.stringify(n)===JSON.stringify(o))!==-1;return x({checkbox:c},o)}):z.value),je=o=>{P.value=o?I.value:[]},qe=o=>{const c=o.checkbox;if(delete o.checkbox,c)P.value=P.value.filter(n=>JSON.stringify(n)!==JSON.stringify(o));else{const n=P.value;n.unshift(o),P.value=n}};return(o,c)=>(e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("div",{class:e.normalizeClass(["data-table__body",{"fixed-header":r.fixedHeader,"wrap-lines":r.wrapLines}])},[e.createElementVNode("table",null,[e.unref(D).length?(e.openBlock(),e.createElementBlock("thead",Ce,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(D),(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(Se),{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(H).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(H).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(H),(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:S.value,"onUpdate:modelValue":c[0]||(c[0]=n=>S.value=n),"rows-items":r.rowsItems},null,8,["modelValue","rows-items"])]),e.createElementVNode("div",Oe,e.toDisplayString(`${e.unref(U)}-${e.unref(W)}`)+" of "+e.toDisplayString(e.unref(J)),1),e.unref(q)?e.renderSlot(o.$slots,"pagination",e.normalizeProps(e.mergeProps({key:0},{isFirstPage:e.unref(O),isLastPage:e.unref(T),currentPaginationNumber:f.value,maxPaginationNumber:e.unref(L),nextPage:A,prevPage:M})),void 0,!0):(e.openBlock(),e.createBlock(ke,{key:1,"is-first-page":e.unref(O),"is-last-page":e.unref(T),onClickNextPage:A,onClickPrevPage:M},e.createSlots({_:2},[r.buttonsPagination?{name:"buttonsPagination",fn:e.withCtx(()=>[e.createVNode(_e,{"current-pagination-number":f.value,"max-pagination-number":e.unref(L),onUpdatePage:Me},null,8,["current-pagination-number","max-pagination-number"])])}:void 0]),1032,["is-first-page","is-last-page"]))])]))}}),[["__scopeId","data-v-e0181f12"]]);return ze});

@@ -6,3 +6,3 @@ {

"private": false,
"version": "1.0.24",
"version": "1.0.25",
"types": "./types/main.d.ts",

@@ -9,0 +9,0 @@ "files": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc