vueye-table 2.0.0-alpha.2 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -13
- package/README.md +55 -30
- package/dist/components/core/VueyeTable/VueyeTable.vue.d.ts +20 -33
- package/dist/components/core/VueyeTable/api.d.ts +14 -0
- package/dist/components/core/VueyeTable/{VueyeBody → components/VueyeBody}/VueyeBody.vue.d.ts +8 -9
- package/dist/components/core/VueyeTable/components/VueyeBody/index.d.ts +2 -0
- package/dist/components/core/VueyeTable/components/VueyeDropdown/api.d.ts +17 -0
- package/dist/components/core/VueyeTable/components/VueyeDropdown/index.d.ts +4 -0
- package/dist/components/core/VueyeTable/{VueyeHead → components/VueyeHead}/VueyeHead.vue.d.ts +2 -3
- package/dist/components/core/VueyeTable/{VueyePagination → components/VueyePagination}/VueyePagination.vue.d.ts +12 -12
- package/dist/components/core/VueyeTable/components/VueyePagination/index.d.ts +2 -0
- package/dist/components/core/VueyeTable/components/index.d.ts +4 -0
- package/dist/components/core/VueyeTable/composables/index.d.ts +3 -0
- package/dist/components/core/VueyeTable/composables/usePagination.d.ts +11 -0
- package/dist/components/core/VueyeTable/types/Utils.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/vueye-table.js +314 -367
- package/dist/vueye-table.umd.cjs +1 -1
- package/package.json +86 -103
- package/dist/components/core/VueyeTable/VSelect.d.ts +0 -15
- package/dist/components/core/VueyeTable/VueyeBody/index.d.ts +0 -2
- package/dist/components/core/VueyeTable/VueyePagination/index.d.ts +0 -6
- package/dist/components/core/VueyeTable/util-components/VueyeDropdown.vue.d.ts +0 -53
- package/dist/data/product.d.ts +0 -14
- package/dist/data/user.d.ts +0 -22
- package/dist/types.d.ts +0 -8
- /package/dist/components/core/VueyeTable/{VueyeHead → components/VueyeHead}/index.d.ts +0 -0
package/dist/vueye-table.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u["vueye-table"]={},u.Vue))})(this,function(u,e){"use strict";function L(a){return e.getCurrentScope()?(e.onScopeDispose(a),!0):!1}function N(a){return typeof a=="function"?a():e.unref(a)}const C=typeof window<"u"&&typeof document<"u",V=()=>{},A=D();function D(){var a;return C&&((a=window==null?void 0:window.navigator)==null?void 0:a.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent)}function y(a){const o=N(a);return(o==null?void 0:o.$el)??o}const S=C?window:void 0;function B(...a){let o,t,n,s;if(typeof a[0]=="string"||Array.isArray(a[0])?([t,n,s]=a,o=S):[o,t,n,s]=a,!o)return V;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const l=[],d=()=>{l.forEach(c=>c()),l.length=0},f=(c,g,i,r)=>(c.addEventListener(g,i,r),()=>c.removeEventListener(g,i,r)),m=e.watch(()=>[y(o),N(s)],([c,g])=>{d(),c&&l.push(...t.flatMap(i=>n.map(r=>f(c,i,r,g))))},{immediate:!0,flush:"post"}),_=()=>{m(),d()};return L(_),_}let w=!1;function I(a,o,t={}){const{window:n=S,ignore:s=[],capture:l=!0,detectIframe:d=!1}=t;if(!n)return;A&&!w&&(w=!0,Array.from(n.document.body.children).forEach(i=>i.addEventListener("click",V)),n.document.documentElement.addEventListener("click",V));let f=!0;const m=i=>s.some(r=>{if(typeof r=="string")return Array.from(n.document.querySelectorAll(r)).some(p=>p===i.target||i.composedPath().includes(p));{const p=y(r);return p&&(i.target===p||i.composedPath().includes(p))}}),c=[B(n,"click",i=>{const r=y(a);if(!(!r||r===i.target||i.composedPath().includes(r))){if(i.detail===0&&(f=!m(i)),!f){f=!0;return}o(i)}},{passive:!0,capture:l}),B(n,"pointerdown",i=>{const r=y(a);r&&(f=!i.composedPath().includes(r)&&!m(i))},{passive:!0}),d&&B(n,"blur",i=>{setTimeout(()=>{var p;const r=y(a);((p=n.document.activeElement)==null?void 0:p.tagName)==="IFRAME"&&!(r!=null&&r.contains(n.document.activeElement))&&o(i)},0)})].filter(Boolean);return()=>c.forEach(i=>i())}const R={class:"relative"},T=["aria-expanded"],H=e.createElementVNode("span",{class:"i-solar-alt-arrow-down-linear"},null,-1),F={class:"py-1",role:"none"},j=["onClick"],M=e.defineComponent({__name:"VueyeDropdown",props:{options:{default:()=>[]},modelValue:{default:""},label:{default:""},defaultValue:{}},emits:["update:modelValue"],setup(a,{emit:o}){const t=a,n=e.ref(null);I(n,()=>{s.value=!1});const s=e.ref(!1),l=e.ref(-1),d=e.computed(()=>t.options[l.value]??t.defaultValue),f=`dropdown-label-${Math.random().toString(36).substring(2,9)}`;function m(){s.value=!s.value}function _(c){l.value=c,s.value=!1,o("update:modelValue",d.value.value)}return e.watchEffect(()=>{const c=t.options.findIndex(g=>g.value===t.modelValue);c!==-1&&(l.value=c)}),(c,g)=>(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("button",{type:"button",class:"bg-slate-100 dark:bg-primary-900 border flex items-center space-x-2 rtl:space-x-reverse border-primary-300 dark:border-primary-900 rounded-md shadow-sm py-2 px-4 text-sm font-medium text-slate-700 dark:text-slate-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",onClick:m,"aria-expanded":e.unref(s),"aria-haspopup":!0},[e.createElementVNode("span",null,e.toDisplayString(e.unref(d).label),1),H],8,T),e.unref(s)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-slate-100 dark:bg-primary-950 ring-1 ring-black ring-opacity-5 focus:outline-none",role:"menu","aria-orientation":"vertical","aria-labelledby":f,ref_key:"target",ref:n},[e.createElementVNode("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.options,(i,r)=>(e.openBlock(),e.createElementBlock("button",{key:r,class:e.normalizeClass([{"text-slate-700 bg-slate-200 dark:text-slate-300 dark:bg-primary-900 ":r===e.unref(l),"text-slate-700 dark:text-slate-50 hover:bg-slate-50":r!==e.unref(l)},"block px-4 py-2 text-sm text-left w-full text-slate-700 dark:text-slate-50 hover:bg-slate-200 hover:text-slate-900 focus:outline-none focus:bg-slate-100 focus:text-slate-900 dark:hover:text-slate-300 dark:hover:bg-primary-900"]),role:"menuitem",onClick:p=>_(r)},e.toDisplayString(i.label),11,j))),128))])],512)):e.createCommentVNode("",!0)]))}}),h=a=>(e.pushScopeId("data-v-d06f6d12"),a=a(),e.popScopeId(),a),z={class:"pagination__wrapper"},K={class:"pagination__details"},W={class:"pagination__btn-list"},U=["disabled"],q=[h(()=>e.createElementVNode("span",{class:"sr-only"},"First page",-1)),h(()=>e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-alt-arrow-left-linear"},null,-1))],G=["disabled"],J=[h(()=>e.createElementVNode("span",{class:"sr-only"},"Previous page",-1)),h(()=>e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-double-alt-arrow-left-linear"},null,-1))],Q=["onClick"],X={key:1,class:"pagination__btn"},Y=["disabled"],Z=[h(()=>e.createElementVNode("span",{class:"sr-only"},"Next page",-1)),h(()=>e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-alt-arrow-right-linear"},null,-1))],x=["disabled"],v=[h(()=>e.createElementVNode("span",{class:"sr-only"},"Last page",-1)),h(()=>e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-double-alt-arrow-right-linear"},null,-1))],ee=e.defineComponent({__name:"VueyePagination",props:{perPage:{default:10},currentPage:{default:1},total:{default:0},perPageOptions:{default:()=>[10,20,30,40,50]}},emits:["update:currentPage","update:perPage"],setup(a,{emit:o}){const t=a,n=e.computed(()=>Math.ceil(t.total/t.perPage)),s=e.computed(()=>t.perPageOptions.map(r=>({value:r,label:r.toString()}))),l=e.computed(()=>s.value.find(r=>r.value===t.perPage)),d=e.computed(()=>Array.from({length:n.value},(r,p)=>p+1).reduce((r,p)=>(p===1||p===t.total||p>=t.currentPage-2&&p<=t.currentPage+2?r.push(p):(p===t.currentPage-3||p===t.currentPage+3)&&r.push("..."),r),[]));function f(){t.currentPage<n.value&&o("update:currentPage",t.currentPage+1)}function m(){t.currentPage>1&&o("update:currentPage",t.currentPage-1)}function _(){t.currentPage>1&&o("update:currentPage",1)}function c(){t.currentPage<n.value&&o("update:currentPage",t.total)}function g(r){r>0&&r<=n.value&&o("update:currentPage",r)}function i(r){o("update:perPage",Number(r))}return(r,p)=>(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",null,[e.createVNode(M,{options:e.unref(s),"default-value":e.unref(l),label:"Per page","onUpdate:modelValue":i},null,8,["options","default-value"])]),e.createElementVNode("div",null,[e.createElementVNode("span",K,e.toDisplayString((r.currentPage-1)*r.perPage+1)+" - "+e.toDisplayString(r.currentPage*r.perPage>r.total?r.total:r.currentPage*r.perPage)+" of "+e.toDisplayString(r.total),1)]),e.createElementVNode("ul",W,[e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:_,disabled:r.currentPage===1},q,8,U)]),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:m,disabled:r.currentPage===1},J,8,G)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(d),b=>(e.openBlock(),e.createElementBlock("li",{key:b},[typeof b=="number"?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["pagination__btn",{"pagination__btn--current":b===r.currentPage}]),onClick:Ae=>g(b)},e.toDisplayString(b),11,Q)):(e.openBlock(),e.createElementBlock("span",X,"..."))]))),128)),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:f,disabled:r.currentPage===e.unref(n)},Z,8,Y)]),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:c,disabled:r.currentPage===e.unref(n)},v,8,x)])])]))}}),Ce="",te=((a,o)=>{const t=a.__vccOpts||a;for(const[n,s]of o)t[n]=s;return t})(ee,[["__scopeId","data-v-d06f6d12"]]);function k(a){let o=1;return a.forEach(t=>{t.children&&(o=Math.max(o,k(t.children)+1))}),o}function $(a){let o=0;return a.forEach(t=>{t.children?o+=$(t.children):o++}),o}function P(a,o,t=[],n=0,s=0){return a.forEach(l=>{if(t[n]||(t[n]=[]),l.children){const{children:d,...f}=l,m=$(d);t[n].push({...f,colSpan:m,scope:"colgroup"}),P(d,o,t,n+1,s+1)}else{const d=o-s;t[n].push({...l,key:l.key,label:l.label,rowSpan:d,scope:"col"})}}),t}function E(a,o="",t=[]){return a.forEach(n=>{n.children?E(n.children,`${o}${n.key}.`,t):t.push(`${o}${n.key}`)}),t}function ne(a){const o=k(a);return P(a,o).reduce((s,l)=>[...s,...l],[])}const oe=(a,o)=>{const t=o.split(".");let n=a;for(let s=0;s<t.length;s++)if(n[t[s]])n=n[t[s]];else return;return n};function O(a,o,t=0,n=a.length){return a.map(s=>E(o).map(l=>({[l]:oe(s,l)})).reduce((l,d)=>({...l,...d}),{})).slice(t,n)}function ae(a,o,t){return{bodyRows:e.computed(()=>{const s=t.value.perPage*(t.value.currentPage-1),l=t.value.perPage*t.value.currentPage;return O(a,e.unref(o),s,l)})}}function re(a){const o=e.unref(a)??[];return{headers:e.computed(()=>P(o,k(o)))}}const le={key:0},se=["colspan"],ce=[e.createElementVNode("div",{class:"flex justify-center items-center"},[e.createElementVNode("div",{class:"loader animate-spin ease-linear rounded-full border-8 border-t-8 border-t-primary-300 dark:border-t-primary-800 dark:border-primary-600 border-primary-200 h-16 w-16"})],-1)],ie=["id"],de=e.defineComponent({__name:"VueyeBody",props:{loading:{type:Boolean,default:!1},bodyRows:{default:()=>[]},itemValue:{default:"id"}},setup(a){const o=a,t=e.computed(()=>Object.keys(o.bodyRows[0]).length);return(n,s)=>(e.openBlock(),e.createElementBlock("tbody",null,[n.loading?(e.openBlock(),e.createElementBlock("tr",le,[e.createElementVNode("td",{colspan:e.unref(t)},ce,8,se)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(n.bodyRows,l=>(e.openBlock(),e.createElementBlock("tr",{key:l[n.itemValue]},[e.renderSlot(n.$slots,"default",{row:l},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Object.keys(l),d=>(e.openBlock(),e.createElementBlock("td",{key:`${l[n.itemValue]}.${d}`,id:`${l[n.itemValue]}.${d}`},[e.renderSlot(n.$slots,"default",{cell:l[d],key:`${l[n.itemValue]}.${d}`},()=>[e.createTextVNode(e.toDisplayString(l[d]),1)])],8,ie))),128))])]))),128))]))}}),pe=["colspan","rowspan","scope"],ue=e.defineComponent({__name:"VueyeHead",props:{columnHeaders:{default:()=>[]}},setup(a){return(o,t)=>(e.openBlock(),e.createElementBlock("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.columnHeaders,(n,s)=>(e.openBlock(),e.createElementBlock("tr",{key:s},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n,l=>e.renderSlot(o.$slots,`headerCell.${l.key}`,{key:l.key,headerCell:l},()=>[e.createElementVNode("th",{colspan:l.colSpan,rowspan:l.rowSpan,scope:l.scope,class:e.normalizeClass([l.className,"th"])},[e.renderSlot(o.$slots,`headerCellContent.${l.key}`,{headerCellContent:l},()=>[e.createElementVNode("span",{class:e.normalizeClass(l.labelClassName)},e.toDisplayString(l.label),3)])],10,pe)])),128))]))),128))]))}}),fe={class:"table__wrapper"},me={class:"table__caption"},ge={class:"table__summary"},_e={class:"table__pagination-wrapper"},he=e.defineComponent({inheritAttrs:!1,__name:"VueyeTable",props:{itemValue:{default:"id"},columnHeaders:{default:()=>[]},data:{default:()=>[]},perPage:{default:10},currentPage:{default:1},perPageOptions:{default:()=>[5,10,20,30]},loading:{type:Boolean,default:!1},selectable:{type:Boolean,default:!1},caption:{default:""},summary:{default:""}},setup(a){const o=a,t=e.toRef(o,"columnHeaders"),n=e.ref({perPage:o.perPage||10,currentPage:o.currentPage||1}),{headers:s}=re(t),{bodyRows:l}=ae(o.data,t,n),d=e.useSlots(),f=Object.keys(d).filter(c=>c.startsWith("headerCell"));function m(c){n.value.currentPage=c}function _(c){n.value.perPage=c}return(c,g)=>(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("table",{class:e.normalizeClass(c.$attrs.class??"table")},[e.renderSlot(c.$slots,"caption",{},()=>[e.createElementVNode("caption",me,e.toDisplayString(c.caption),1)]),e.createVNode(e.unref(ue),{columnHeaders:e.unref(s)},e.createSlots({_:2},[e.renderList(e.unref(f),i=>({name:i,fn:e.withCtx(r=>[e.renderSlot(c.$slots,i,e.normalizeProps(e.guardReactiveProps(r)))])}))]),1032,["columnHeaders"]),e.createVNode(e.unref(de),{bodyRows:e.unref(l),loading:c.loading},null,8,["bodyRows","loading"]),e.renderSlot(c.$slots,"summary",{},()=>[e.createElementVNode("caption",ge,e.toDisplayString(c.summary),1)])],2),e.createElementVNode("div",_e,[e.createVNode(te,{perPage:e.unref(n).perPage,currentPage:e.unref(n).currentPage,perPageOptions:c.perPageOptions,total:c.data.length,"onUpdate:currentPage":m,"onUpdate:perPage":_},null,8,["perPage","currentPage","perPageOptions","total"])])]))}}),Oe="",Le="";function ye(a){return{headerKeys:e.computed(()=>E(a.flat()))}}u.VueyeTable=he,u.defineColumnHeaders=ne,u.depthCount=k,u.flatHeadersToRows=P,u.getBodyRows=O,u.getHeaderKeys=E,u.leafCount=$,u.useHeaderKeys=ye,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d["vueye-table"]={},d.Vue))})(this,function(d,e){"use strict";const $={itemValue:"id",columnHeaders:()=>[],data:()=>[],perPage:10,currentPage:1,perPageOptions:()=>[5,10,20,30],loading:!1,selectable:!1,caption:"",summary:""},C={options:()=>[],modelValue:"",label:""},w={class:"dropdown__wrapper"},S=["aria-expanded"],D=e.createElementVNode("span",{class:"i-solar-alt-arrow-down-linear"},null,-1),O={class:"py-1",role:"none"},R=["onClick"],H=e.defineComponent({__name:"VueyeDropdown",props:e.mergeDefaults({options:{},modelValue:{},label:{},defaultValue:{}},C),emits:["update:modelValue"],setup(r,{emit:n}){const t=r,o=e.ref(!1),s=e.ref(-1),a=e.computed(()=>t.options[s.value]??t.defaultValue),c=`dropdown-label-${Math.random().toString(36).substring(2,9)}`;function u(){o.value=!o.value}function g(p){s.value=p,o.value=!1,n("update:modelValue",a.value.content)}return e.watchEffect(()=>{const p=t.options.findIndex(i=>i.content===t.modelValue);p!==-1&&(s.value=p)}),(p,i)=>(e.openBlock(),e.createElementBlock("div",w,[e.createElementVNode("button",{type:"button",class:"dropdown__trigger",onClick:u,"aria-expanded":e.unref(o),"aria-haspopup":!0,ref:"buttonRef"},[e.createElementVNode("span",null,e.toDisplayString(e.unref(a).label),1),D],8,S),e.unref(o)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"dropdown__overlay",onClick:u})):e.createCommentVNode("",!0),e.unref(o)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"dropdown__menu",role:"menu","aria-orientation":"vertical","aria-labelledby":c},[e.createElementVNode("div",O,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.options,(b,m)=>(e.openBlock(),e.createElementBlock("button",{key:m,class:e.normalizeClass([{"dropdown__menu__item--selected ":m===e.unref(s)},"dropdown__menu__item"]),role:"menuitem",onClick:l=>g(m)},e.toDisplayString(b.label),11,R))),128))])])):e.createCommentVNode("",!0)]))}}),de="",T={key:0},L=["colspan"],j=[e.createElementVNode("div",{class:"flex justify-center items-center"},[e.createElementVNode("div",{class:"loader animate-spin ease-linear rounded-full border-8 border-t-8 border-t-primary-300 dark:border-t-primary-800 dark:border-primary-600 border-primary-200 h-16 w-16"})],-1)],F=["id"],z=e.defineComponent({__name:"VueyeBody",props:{loading:{type:Boolean,default:!1},bodyRows:{default:()=>[]},itemValue:{default:"id"}},setup(r){const n=r,t=e.computed(()=>Object.keys(n.bodyRows[0]).length);return(o,s)=>(e.openBlock(),e.createElementBlock("tbody",null,[o.loading?(e.openBlock(),e.createElementBlock("tr",T,[e.createElementVNode("td",{colspan:e.unref(t)},j,8,L)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(o.bodyRows,a=>(e.openBlock(),e.createElementBlock("tr",{key:a[o.itemValue]},[e.renderSlot(o.$slots,"default",{row:a},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Object.keys(a),c=>(e.openBlock(),e.createElementBlock("td",{key:`${a[o.itemValue]}.${c}`,id:`${a[o.itemValue]}.${c}`},[e.renderSlot(o.$slots,"default",{cell:a[c],key:`${a[o.itemValue]}.${c}`},()=>[e.createTextVNode(e.toDisplayString(a[c]),1)])],8,F))),128))])]))),128))]))}}),K=["colspan","rowspan","scope"],M=e.defineComponent({__name:"VueyeHead",props:{columnHeaders:{default:()=>[]}},setup(r){return(n,t)=>(e.openBlock(),e.createElementBlock("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.columnHeaders,(o,s)=>(e.openBlock(),e.createElementBlock("tr",{key:s},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o,a=>e.renderSlot(n.$slots,`headerCell.${a.key}`,{key:a.key,headerCell:a},()=>[e.createElementVNode("th",{colspan:a.colSpan,rowspan:a.rowSpan,scope:a.scope,class:e.normalizeClass([a.className,"th"])},[e.renderSlot(n.$slots,`headerCellContent.${a.key}`,{headerCellContent:a},()=>[e.createElementVNode("span",{class:e.normalizeClass(a.labelClassName)},e.toDisplayString(a.label),3)])],10,K)])),128))]))),128))]))}}),U={class:"pagination__wrapper"},I={class:"pagination__details"},A={class:"pagination__btn-list"},q=["disabled"],W=[e.createElementVNode("span",{class:"sr-only"},"First page",-1),e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-alt-arrow-left-linear"},null,-1)],G=["disabled"],J=[e.createElementVNode("span",{class:"sr-only"},"Previous page",-1),e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-double-alt-arrow-left-linear"},null,-1)],Q=["onClick"],X={key:1,class:"pagination__btn"},Y=["disabled"],Z=[e.createElementVNode("span",{class:"sr-only"},"Next page",-1),e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-alt-arrow-right-linear"},null,-1)],x=["disabled"],v=[e.createElementVNode("span",{class:"sr-only"},"Last page",-1),e.createElementVNode("span",{"aria-hidden":"true",class:"i-solar-double-alt-arrow-right-linear"},null,-1)],ee=e.defineComponent({__name:"VueyePagination",props:{perPage:{default:10},currentPage:{default:1},total:{default:0},perPageOptions:{default:()=>[10,20,30,40,50]}},emits:["update:currentPage","update:perPage"],setup(r,{emit:n}){const t=r,o=e.computed(()=>Math.ceil(t.total/t.perPage)),s=e.computed(()=>t.perPageOptions.map(l=>({value:l,label:l.toString()}))),a=e.computed(()=>s.value.find(l=>l.value===t.perPage)),c=e.computed(()=>Array.from({length:o.value},(l,_)=>_+1).reduce((l,_)=>(_===1||_===t.total||_>=t.currentPage-2&&_<=t.currentPage+2?l.push(_):(_===t.currentPage-3||_===t.currentPage+3)&&l.push("..."),l),[]));function u(){t.currentPage<o.value&&n("update:currentPage",t.currentPage+1)}function g(){t.currentPage>1&&n("update:currentPage",t.currentPage-1)}function p(){t.currentPage>1&&n("update:currentPage",1)}function i(){t.currentPage<o.value&&n("update:currentPage",t.total)}function b(l){l>0&&l<=o.value&&n("update:currentPage",l)}function m(l){n("update:perPage",Number(l))}return(l,_)=>(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",null,[e.createVNode(e.unref(H),{options:e.unref(s),"default-value":e.unref(a),label:"Per page","onUpdate:modelValue":m},null,8,["options","default-value"])]),e.createElementVNode("div",null,[e.createElementVNode("span",I,e.toDisplayString((l.currentPage-1)*l.perPage+1)+" - "+e.toDisplayString(l.currentPage*l.perPage>l.total?l.total:l.currentPage*l.perPage)+" of "+e.toDisplayString(l.total),1)]),e.createElementVNode("ul",A,[e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:p,disabled:l.currentPage===1},W,8,q)]),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:g,disabled:l.currentPage===1},J,8,G)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),f=>(e.openBlock(),e.createElementBlock("li",{key:f},[typeof f=="number"?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["pagination__btn",{"pagination__btn--current":f===l.currentPage}]),onClick:Ve=>b(f)},e.toDisplayString(f),11,Q)):(e.openBlock(),e.createElementBlock("span",X,"..."))]))),128)),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:u,disabled:l.currentPage===e.unref(o)},Z,8,Y)]),e.createElementVNode("li",null,[e.createElementVNode("button",{class:"pagination__btn",onClick:i,disabled:l.currentPage===e.unref(o)},v,8,x)])])]))}}),Pe="";function h(r){let n=1;return r.forEach(t=>{t.children&&(n=Math.max(n,h(t.children)+1))}),n}function k(r){let n=0;return r.forEach(t=>{t.children?n+=k(t.children):n++}),n}function y(r,n,t=[],o=0,s=0){return r.forEach(a=>{if(t[o]||(t[o]=[]),a.children){const{children:c,...u}=a,g=k(c);t[o].push({...u,colSpan:g,scope:"colgroup"}),y(c,n,t,o+1,s+1)}else{const c=n-s;t[o].push({...a,key:a.key,label:a.label,rowSpan:c,scope:"col"})}}),t}function P(r,n="",t=[]){return r.forEach(o=>{o.children?P(o.children,`${n}${o.key}.`,t):t.push(`${n}${o.key}`)}),t}function te(r){const n=h(r);return y(r,n).reduce((s,a)=>[...s,...a],[])}const ne=(r,n)=>{const t=n.split(".");let o=r;for(let s=0;s<t.length;s++)if(o[t[s]])o=o[t[s]];else return;return o};function V(r,n,t=0,o=r.length){return r.map(s=>P(n).map(a=>({[a]:ne(s,a)})).reduce((a,c)=>({...a,...c}),{})).slice(t,o)}function oe(r){return{headerKeys:e.computed(()=>P(r.flat()))}}function E(r={}){const n=e.ref({perPage:r.perPage||10,currentPage:r.currentPage||1});function t(s){n.value.currentPage=s}function o(s){n.value.perPage=s}return{pagination:n,updateCurrentPage:t,updatePerPage:o}}function B(r,n,t){return{bodyRows:e.computed(()=>{const s=n.value.perPage*(n.value.currentPage-1),a=n.value.perPage*n.value.currentPage;return V(r,e.unref(t),s,a)})}}function N(r){const n=e.unref(r)??[];return{headers:e.computed(()=>y(n,h(n)))}}const ae={class:"table__wrapper"},re={key:0,class:"table__caption"},le={class:"table__summary"},se={class:"table__pagination-wrapper"},ce=e.defineComponent({inheritAttrs:!1,__name:"VueyeTable",props:e.mergeDefaults({itemValue:{},columnHeaders:{},data:{},perPage:{},currentPage:{},perPageOptions:{},loading:{type:Boolean},selectable:{type:Boolean},caption:{},summary:{}},$),setup(r){const n=r,t=e.toRef(()=>n.columnHeaders),{headers:o}=N(t),s=e.useSlots(),a=Object.keys(s).filter(i=>i.startsWith("headerCell")),{pagination:c,updateCurrentPage:u,updatePerPage:g}=E(n),{bodyRows:p}=B(n.data,c,t);return(i,b)=>(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("table",{class:e.normalizeClass(i.$attrs.class??"table")},[e.renderSlot(i.$slots,"caption",{},()=>[i.caption?(e.openBlock(),e.createElementBlock("caption",re,e.toDisplayString(i.caption),1)):e.createCommentVNode("",!0)]),e.createVNode(e.unref(M),{columnHeaders:e.unref(o)},e.createSlots({_:2},[e.renderList(e.unref(a),m=>({name:m,fn:e.withCtx(l=>[e.renderSlot(i.$slots,m,e.normalizeProps(e.guardReactiveProps(l)))])}))]),1032,["columnHeaders"]),e.createVNode(e.unref(z),{bodyRows:e.unref(p),loading:i.loading},null,8,["bodyRows","loading"]),e.renderSlot(i.$slots,"summary",{},()=>[e.createElementVNode("caption",le,e.toDisplayString(i.summary),1)])],2),e.createElementVNode("div",se,[e.createVNode(e.unref(ee),{perPage:e.unref(c).perPage,currentPage:e.unref(c).currentPage,perPageOptions:i.perPageOptions,total:i.data.length,"onUpdate:currentPage":e.unref(u),"onUpdate:perPage":e.unref(g)},null,8,["perPage","currentPage","perPageOptions","total","onUpdate:currentPage","onUpdate:perPage"])])]))}}),be="",ke="";d.VueyeTable=ce,d.defineColumnHeaders=te,d.depthCount=h,d.flatHeadersToRows=y,d.getBodyRows=V,d.getHeaderKeys=P,d.leafCount=k,d.useBodyRows=B,d.useHeaderKeys=oe,d.useHeaders=N,d.usePagination=E,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,105 +1,88 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"./*": "./dist/vueye-table.js",
|
|
27
|
-
"./dist/style.css": "./dist/style.css"
|
|
2
|
+
"name": "vueye-table",
|
|
3
|
+
"version": "2.0.0-alpha.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Vue data table",
|
|
6
|
+
"author": "Brahim Boussadjra",
|
|
7
|
+
"repository": "https://github.com/boussadjra/vueye-table",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"vue",
|
|
14
|
+
"vite",
|
|
15
|
+
"template"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/vueye-table.umd.cjs",
|
|
19
|
+
"module": "./dist/vueye-table.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/vueye-table.js",
|
|
24
|
+
"require": "./dist/vueye-table.umd.cjs",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
28
26
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"vite": "^4.4.9",
|
|
92
|
-
"vite-plugin-dts": "^3.5.2",
|
|
93
|
-
"vite-plugin-pages": "^0.31.0",
|
|
94
|
-
"vite-plugin-vue-layouts": "^0.8.0",
|
|
95
|
-
"vitest": "^0.34.3",
|
|
96
|
-
"vue-tsc": "^1.8.8"
|
|
97
|
-
},
|
|
98
|
-
"peerDependencies": {
|
|
99
|
-
"vue": "^3.3.4"
|
|
100
|
-
},
|
|
101
|
-
"lint-staged": {
|
|
102
|
-
"*.{js,ts,vue}": "eslint --fix",
|
|
103
|
-
"*.{js,ts,vue,css,scss,json,md}": "prettier --write"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
27
|
+
"./*": "./dist/vueye-table.js",
|
|
28
|
+
"./dist/style.css": "./dist/style.css"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@antfu/eslint-config": "^0.43.1",
|
|
32
|
+
"@egoist/tailwindcss-icons": "^1.2.0",
|
|
33
|
+
"@faker-js/faker": "^8.1.0",
|
|
34
|
+
"@histoire/plugin-vue": "^0.17.1",
|
|
35
|
+
"@iconify-json/solar": "^1.1.5",
|
|
36
|
+
"@iconify-json/tabler": "^1.1.92",
|
|
37
|
+
"@rushstack/eslint-patch": "^1.5.0",
|
|
38
|
+
"@testing-library/vue": "^7.0.0",
|
|
39
|
+
"@types/node": "^20.7.1",
|
|
40
|
+
"@vitejs/plugin-vue": "^4.3.4",
|
|
41
|
+
"@vue/eslint-config-prettier": "^8.0.0",
|
|
42
|
+
"@vue/eslint-config-typescript": "^12.0.0",
|
|
43
|
+
"@vue/tsconfig": "^0.4.0",
|
|
44
|
+
"@vueuse/core": "^10.4.1",
|
|
45
|
+
"@vueuse/head": "^2.0.0",
|
|
46
|
+
"autoprefixer": "^10.4.16",
|
|
47
|
+
"eslint": "^8.50.0",
|
|
48
|
+
"eslint-plugin-import": "^2.28.1",
|
|
49
|
+
"eslint-plugin-vue": "^9.17.0",
|
|
50
|
+
"histoire": "^0.17.2",
|
|
51
|
+
"pathe": "^1.1.1",
|
|
52
|
+
"pnpm": "^8.8.0",
|
|
53
|
+
"postcss": "^8.4.30",
|
|
54
|
+
"prettier": "^3.0.3",
|
|
55
|
+
"tailwindcss": "^3.3.3",
|
|
56
|
+
"tsdoc-markdown": "^0.1.0",
|
|
57
|
+
"typescript": "~5.2.2",
|
|
58
|
+
"unplugin-auto-import": "^0.16.6",
|
|
59
|
+
"unplugin-icons": "^0.17.0",
|
|
60
|
+
"vite": "^4.4.9",
|
|
61
|
+
"vite-bundle-visualizer": "^0.10.0",
|
|
62
|
+
"vite-plugin-dts": "^3.6.0",
|
|
63
|
+
"vitest": "^0.34.5",
|
|
64
|
+
"vue-router": "^4.2.5",
|
|
65
|
+
"vue-tsc": "^1.8.15"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"vue": "^3.3.4"
|
|
69
|
+
},
|
|
70
|
+
"lint-staged": {
|
|
71
|
+
"*.{js,ts,vue}": "eslint --fix",
|
|
72
|
+
"*.{js,ts,vue,css,scss,json,md}": "prettier --write"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"dev": "vite",
|
|
76
|
+
"build": " vite build",
|
|
77
|
+
"preview": "vite preview",
|
|
78
|
+
"story:dev": "histoire dev",
|
|
79
|
+
"story:build": "histoire build",
|
|
80
|
+
"story:preview": "histoire preview",
|
|
81
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
82
|
+
"format": "prettier . --write --ignore-path .gitignore",
|
|
83
|
+
"test:unit": "vitest",
|
|
84
|
+
"pub:release": "pnpm publish --access public",
|
|
85
|
+
"generate-md": "tsdoc --src=api.ts",
|
|
86
|
+
"analyse": "vite-bundle-visualizer dist --port 3000"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type Meta<TData extends Record<TItemValue, unknown>, TItemValue extends string = 'id'> = {
|
|
2
|
-
key: keyof TData;
|
|
3
|
-
label: string;
|
|
4
|
-
children?: Meta<TData, TItemValue>[];
|
|
5
|
-
};
|
|
6
|
-
export type SelectProps<TData extends Record<TItemValue, unknown>, TItemValue extends string = 'id'> = {
|
|
7
|
-
itemValue: TItemValue;
|
|
8
|
-
items: TData[];
|
|
9
|
-
meta: Meta<any>;
|
|
10
|
-
};
|
|
11
|
-
export declare const VSelect: (props: {
|
|
12
|
-
items: any[];
|
|
13
|
-
itemValue: string;
|
|
14
|
-
meta: Meta<any, "id">;
|
|
15
|
-
} & {}) => any;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export type OptionValue = string | number | boolean | object | symbol;
|
|
2
|
-
interface Option {
|
|
3
|
-
value: OptionValue;
|
|
4
|
-
label: string;
|
|
5
|
-
}
|
|
6
|
-
declare const _default: import("vue").DefineComponent<{
|
|
7
|
-
label: {
|
|
8
|
-
type: globalThis.PropType<string>;
|
|
9
|
-
required: true;
|
|
10
|
-
default: string;
|
|
11
|
-
};
|
|
12
|
-
options: {
|
|
13
|
-
type: globalThis.PropType<Option[]>;
|
|
14
|
-
required: true;
|
|
15
|
-
default: () => never[];
|
|
16
|
-
};
|
|
17
|
-
modelValue: {
|
|
18
|
-
type: globalThis.PropType<string | number>;
|
|
19
|
-
required: true;
|
|
20
|
-
default: string;
|
|
21
|
-
};
|
|
22
|
-
defaultValue: {
|
|
23
|
-
type: globalThis.PropType<Option>;
|
|
24
|
-
};
|
|
25
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
|
-
"update:modelValue": (value: OptionValue) => void;
|
|
27
|
-
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
-
label: {
|
|
29
|
-
type: globalThis.PropType<string>;
|
|
30
|
-
required: true;
|
|
31
|
-
default: string;
|
|
32
|
-
};
|
|
33
|
-
options: {
|
|
34
|
-
type: globalThis.PropType<Option[]>;
|
|
35
|
-
required: true;
|
|
36
|
-
default: () => never[];
|
|
37
|
-
};
|
|
38
|
-
modelValue: {
|
|
39
|
-
type: globalThis.PropType<string | number>;
|
|
40
|
-
required: true;
|
|
41
|
-
default: string;
|
|
42
|
-
};
|
|
43
|
-
defaultValue: {
|
|
44
|
-
type: globalThis.PropType<Option>;
|
|
45
|
-
};
|
|
46
|
-
}>> & {
|
|
47
|
-
"onUpdate:modelValue"?: ((value: OptionValue) => any) | undefined;
|
|
48
|
-
}, {
|
|
49
|
-
label: string;
|
|
50
|
-
options: Option[];
|
|
51
|
-
modelValue: string | number;
|
|
52
|
-
}, {}>;
|
|
53
|
-
export default _default;
|
package/dist/data/product.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ColumnHeader } from '../components/core/VueyeTable';
|
|
2
|
-
export declare const headers: ColumnHeader[];
|
|
3
|
-
export declare const data: {
|
|
4
|
-
id: number;
|
|
5
|
-
product: string;
|
|
6
|
-
sales: {
|
|
7
|
-
'2022': {
|
|
8
|
-
jan: number;
|
|
9
|
-
feb: number;
|
|
10
|
-
mar: number;
|
|
11
|
-
};
|
|
12
|
-
'2023': number;
|
|
13
|
-
};
|
|
14
|
-
}[];
|
package/dist/data/user.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const userHeaders: ({
|
|
2
|
-
key: string;
|
|
3
|
-
label: string;
|
|
4
|
-
children?: undefined;
|
|
5
|
-
} | {
|
|
6
|
-
key: string;
|
|
7
|
-
label: string;
|
|
8
|
-
children: {
|
|
9
|
-
key: string;
|
|
10
|
-
label: string;
|
|
11
|
-
}[];
|
|
12
|
-
})[];
|
|
13
|
-
export declare const userRows: {
|
|
14
|
-
name: string;
|
|
15
|
-
age: number;
|
|
16
|
-
address: {
|
|
17
|
-
street: string;
|
|
18
|
-
city: string;
|
|
19
|
-
state: string;
|
|
20
|
-
zip: string;
|
|
21
|
-
};
|
|
22
|
-
}[];
|
package/dist/types.d.ts
DELETED
|
File without changes
|