@toniel/laravel-tanstack-datatable 0.1.5 → 0.1.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTable.vue"],"names":[],"mappings":"AAuYA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAG/B,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;IAGhC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAG9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmJD,iBAAS,cAAc;WA+UT,OAAO,IAA6B;;yBAZrB,GAAG;wBACJ,GAAG;;;;;;;;YACK,GAAG;;;;EAetC;AAuBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;gBAxhBN,yBAAyB,GAAG,IAAI;oBAK5B,MAAM,EAAE;oBADR,MAAM;yBAaD,OAAO;YAdpB,MAAM;UALR,GAAG,EAAE;WAsBJ,MAAM;eAnBF,OAAO;WACX,KAAK,GAAG,IAAI;YAIX,MAAM,GAAG,IAAI;mBACN,KAAK,GAAG,MAAM;kBAGf,iBAAiB;wBACX,OAAO;cACjB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;gBAGlB,OAAO;iBACN,OAAO;cAKV,MAAM;iBACH,MAAM;gBACP,MAAM;oBACF,MAAM;wFA0gBvB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTable.vue"],"names":[],"mappings":"AA4YA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAG/B,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;IAGhC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAG9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmJD,iBAAS,cAAc;WA4VT,OAAO,IAA6B;;yBAZrB,GAAG;wBACJ,GAAG;;;;;;;;YACK,GAAG;;;;EAetC;AAuBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;gBAriBN,yBAAyB,GAAG,IAAI;oBAK5B,MAAM,EAAE;oBADR,MAAM;yBAaD,OAAO;YAdpB,MAAM;UALR,GAAG,EAAE;WAsBJ,MAAM;eAnBF,OAAO;WACX,KAAK,GAAG,IAAI;YAIX,MAAM,GAAG,IAAI;mBACN,KAAK,GAAG,MAAM;kBAGf,iBAAiB;wBACX,OAAO;cACjB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;gBAGlB,OAAO;iBACN,OAAO;cAKV,MAAM;iBACH,MAAM;gBACP,MAAM;oBACF,MAAM;wFAuhBvB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataTablePagination.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTablePagination.vue"],"names":[],"mappings":"AAwOA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAIpF,UAAU,KAAK;IACb,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC7C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;;;;;;;;gBAJc,yBAAyB,GAAG,IAAI;oBAC5B,MAAM,EAAE;oBACR,MAAM;yBACD,OAAO;;AAuT/B,wBASG"}
1
+ {"version":3,"file":"DataTablePagination.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTablePagination.vue"],"names":[],"mappings":"AAyOA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAIpF,UAAU,KAAK;IACb,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC7C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;;;;;;;;gBAJc,yBAAyB,GAAG,IAAI;oBAC5B,MAAM,EAAE;oBACR,MAAM;yBACD,OAAO;;AAmT/B,wBASG"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),h=require("@tanstack/vue-table"),p=require("lucide-vue-next"),E=require("clsx"),S=require("tailwind-merge");function C(){const t=e.ref(!1);if(typeof window<"u"){const l=window.matchMedia("(prefers-color-scheme: dark)");t.value=l.matches,l.addEventListener("change",s=>{t.value=s.matches})}e.watchEffect(()=>{typeof document<"u"&&(t.value?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))});function y(){t.value=!t.value}return{isDarkMode:t,toggleDarkMode:y}}const N={class:"flex flex-col gap-4 px-2 py-4 bg-background text-foreground"},V={key:0,class:"flex justify-center"},P={class:"flex items-center gap-1",role:"navigation","aria-label":"pagination"},D=["disabled"],R=["disabled"],$={class:"flex items-center gap-1"},T=["onClick"],L={key:1,class:"inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"},j=["disabled"],M=["disabled"],F={class:"flex items-center justify-between text-sm text-gray-600 dark:text-gray-300"},z={key:0,class:"flex items-center gap-2"},I=["value"],O=["value"],q={key:1},B=e.defineComponent({__name:"DataTablePagination",props:{pagination:{default:null},perPageOptions:{default:()=>[10,15,25,50,100]},currentPerPage:{default:10},showPerPageSelector:{type:Boolean,default:!0}},emits:["pageChange","perPageChange"],setup(t,{emit:y}){const l=t,s=y,r=e.computed(()=>l.pagination?l.pagination.meta.current_page>1:!1),d=e.computed(()=>l.pagination?l.pagination.meta.current_page<l.pagination.meta.last_page:!1),f=e.computed(()=>{if(!l.pagination)return[];const g=l.pagination.meta.current_page,i=l.pagination.meta.last_page,o=2,n=[],m=[];let k;for(let a=1;a<=i;a++)(a===1||a===i||a>=g-o&&a<=g+o)&&n.push(a);for(const a of n)k&&(a-k===2?m.push(k+1):a-k!==1&&m.push("...")),m.push(a),k=a;return m}),b=g=>{typeof g=="number"&&s("pageChange",g)},u=()=>{r.value&&s("pageChange",1)},v=()=>{d.value&&l.pagination&&s("pageChange",l.pagination.meta.last_page)},w=()=>{r.value&&l.pagination&&s("pageChange",l.pagination.meta.current_page-1)},x=()=>{d.value&&l.pagination&&s("pageChange",l.pagination.meta.current_page+1)};return(g,i)=>(e.openBlock(),e.createElementBlock("div",N,[t.pagination&&t.pagination.meta.last_page>1?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("nav",P,[e.createElementVNode("button",{disabled:!r.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",r.value?"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200":"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"]),onClick:u},[e.createVNode(e.unref(p.ChevronsLeft),{class:"h-4 w-4"}),i[1]||(i[1]=e.createElementVNode("span",{class:"hidden sm:inline"},"First",-1))],10,D),e.createElementVNode("button",{disabled:!r.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",r.value?"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200":"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"]),onClick:w},[e.createVNode(e.unref(p.ChevronLeft),{class:"h-4 w-4"}),i[2]||(i[2]=e.createElementVNode("span",{class:"hidden sm:inline"},"Previous",-1))],10,R),e.createElementVNode("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(o,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n},[o!=="..."?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",o===t.pagination.meta.current_page?"bg-primary text-primary-foreground hover:bg-primary/90 dark:bg-primary dark:text-primary-foreground":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200"]),onClick:m=>b(o)},e.toDisplayString(o),11,T)):(e.openBlock(),e.createElementBlock("span",L," ... "))],64))),128))]),e.createElementVNode("button",{disabled:!d.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",d.value?"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200":"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"]),onClick:x},[i[3]||(i[3]=e.createElementVNode("span",{class:"hidden sm:inline"},"Next",-1)),e.createVNode(e.unref(p.ChevronRight),{class:"h-4 w-4"})],10,j),e.createElementVNode("button",{disabled:!d.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",d.value?"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200":"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"]),onClick:v},[i[4]||(i[4]=e.createElementVNode("span",{class:"hidden sm:inline"},"Last",-1)),e.createVNode(e.unref(p.ChevronsRight),{class:"h-4 w-4"})],10,M)])])):e.createCommentVNode("",!0),e.createElementVNode("div",F,[e.createElementVNode("div",null,[t.pagination&&t.pagination.meta.total>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" Showing "+e.toDisplayString(t.pagination.meta.from)+" to "+e.toDisplayString(t.pagination.meta.to)+" of "+e.toDisplayString(t.pagination.meta.total)+" entries ",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(" No entries found ")],64))]),t.showPerPageSelector?(e.openBlock(),e.createElementBlock("div",z,[i[5]||(i[5]=e.createElementVNode("span",null,"Rows per page:",-1)),e.createElementVNode("select",{value:t.currentPerPage||t.perPageOptions[0],class:"h-10 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 dark:bg-gray-800 dark:text-gray-200 dark:border-gray-700",onChange:i[0]||(i[0]=o=>s("perPageChange",Number(o.target.value)||t.perPageOptions[0]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,o=>(e.openBlock(),e.createElementBlock("option",{key:o,value:o},e.toDisplayString(o),9,O))),128))],40,I)])):e.createCommentVNode("",!0),t.pagination?(e.openBlock(),e.createElementBlock("div",q," Page "+e.toDisplayString(t.pagination.meta.current_page)+" of "+e.toDisplayString(t.pagination.meta.last_page),1)):e.createCommentVNode("",!0)])]))}}),A={class:"flex flex-col gap-4 bg-background text-foreground"},G={class:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"},U={class:"flex flex-col gap-2 sm:flex-row sm:items-center"},_={key:0,class:"relative w-full max-w-sm"},H=["value"],Q={class:"flex items-center gap-2"},W={class:"flex items-center"},J={key:0,class:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg"},K={class:"flex items-center gap-4"},X={class:"text-sm font-medium text-blue-700 dark:text-blue-300"},Y={class:"text-xs text-blue-600 dark:text-blue-400"},Z={class:"flex items-center gap-2"},ee={key:1,class:"flex items-center justify-center p-8"},te={class:"text-lg text-gray-700 dark:text-gray-200"},oe={key:2,class:"flex flex-col items-center p-8"},ne={class:"mb-2 text-lg text-red-600 dark:text-red-400"},ae={class:"mb-4 text-sm text-gray-600 dark:text-gray-300"},re={key:3,class:"rounded-lg border bg-background dark:border-gray-700"},le={key:0,class:"relative"},se={class:"relative w-full overflow-auto"},ie={class:"w-full caption-bottom text-sm"},ce={key:0,class:"mt-4 text-sm text-muted-foreground dark:text-gray-400"},de={key:0,class:"ml-2 text-blue-600 dark:text-blue-400"},ge={class:"[&_tr]:border-b dark:[&_tr]:border-gray-700"},ue=["colspan"],me=["onClick"],ke={key:0},fe={class:"[&_tr:last-child]:border-0 dark:[&_tr:last-child]:border-0"},pe={key:1},ye=["colspan"],be=e.defineComponent({__name:"DataTable",props:{data:{default:()=>[]},columns:{},pagination:{default:null},isLoading:{type:Boolean,default:!1},error:{default:null},search:{default:""},currentPerPage:{default:10},perPageOptions:{default:()=>[10,15,25,50,100]},sortBy:{default:null},sortDirection:{default:"asc"},rowSelection:{default:()=>({})},enableRowSelection:{type:Boolean,default:!1},getRowId:{type:Function,default:t=>t.id},showSearch:{type:Boolean,default:!0},showCaption:{type:Boolean,default:!0},showPerPageSelector:{type:Boolean,default:!0},title:{default:"Items"},itemName:{default:"items"},loadingText:{default:"Loading..."},errorTitle:{default:"Error loading data"},emptyStateText:{default:"📭 No items found"}},emits:["pageChange","perPageChange","searchChange","sortChange","retry","update:rowSelection"],setup(t,{expose:y,emit:l}){const s=l,r=t,d=e.computed(()=>Object.keys(r.rowSelection||{}).filter(o=>{var n;return(n=r.rowSelection)==null?void 0:n[o]}).length),f=e.computed(()=>Object.keys(r.rowSelection||{}).filter(o=>{var n;return(n=r.rowSelection)==null?void 0:n[o]})),b=e.computed(()=>!r.data||!r.rowSelection?[]:r.data.filter(o=>r.rowSelection[r.getRowId(o)])),u=h.useVueTable({get data(){return r.data||[]},columns:r.columns,getCoreRowModel:h.getCoreRowModel(),enableSorting:!0,manualSorting:!0,enableRowSelection:r.enableRowSelection,getRowId:r.getRowId,state:{rowSelection:r.rowSelection||{}},onRowSelectionChange:o=>{const n=typeof o=="function"?o(r.rowSelection||{}):o;s("update:rowSelection",n)},enableMultiRowSelection:!0,enableSubRowSelection:!1}),v=()=>f.value,w=()=>b.value,x=()=>s("update:rowSelection",{}),g=()=>{const o={...r.rowSelection};u.getRowModel().rows.forEach(n=>{o[n.id]=!0}),s("update:rowSelection",o)},i=()=>{const o={...r.rowSelection};u.getRowModel().rows.forEach(n=>{delete o[n.id]}),s("update:rowSelection",o)};return y({getSelectedRowIds:v,getSelectedRowData:w,clearSelection:x,selectAllCurrentPage:g,deselectAllCurrentPage:i,selectedRowCount:d,selectedRowIds:f,selectedRowData:b,table:u}),(o,n)=>{var m,k;return e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("div",G,[e.createElementVNode("div",U,[t.showSearch?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("input",{value:t.search,type:"search",placeholder:"Search...",class:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 ps-14 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-gray-200 dark:placeholder:text-gray-400",onInput:n[0]||(n[0]=a=>s("searchChange",a.target.value))},null,40,H)])):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[e.renderSlot(o.$slots,"filters")])]),e.createElementVNode("div",W,[e.renderSlot(o.$slots,"header")])]),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("div",J,[e.createElementVNode("div",K,[e.createElementVNode("span",X,e.toDisplayString(d.value)+" "+e.toDisplayString(t.itemName)+" selected ",1),e.createElementVNode("div",Y," IDs: "+e.toDisplayString(f.value.slice(0,5).join(", "))+e.toDisplayString(f.value.length>5?"...":""),1)]),e.createElementVNode("div",Z,[e.renderSlot(o.$slots,"bulk-actions",{selectedIds:f.value,selectedData:b.value,selectedCount:d.value,clearSelection:x,selectAllCurrentPage:g,deselectAllCurrentPage:i}),o.$slots["bulk-actions"]?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:x,class:"px-3 py-1 text-sm text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-800 rounded transition-colors"}," Clear Selection "))])])):e.createCommentVNode("",!0),t.isLoading&&!t.data?(e.openBlock(),e.createElementBlock("div",ee,[n[4]||(n[4]=e.createElementVNode("div",{class:"w-8 h-8 mr-3 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin"},null,-1)),e.createElementVNode("div",te,e.toDisplayString(t.loadingText),1)])):t.error?(e.openBlock(),e.createElementBlock("div",oe,[e.createElementVNode("div",ne," ❌ "+e.toDisplayString(t.errorTitle),1),e.createElementVNode("div",ae,e.toDisplayString(t.error.message),1),e.createElementVNode("button",{class:"px-4 py-2 text-white transition-colors bg-gray-900 rounded-md hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200",onClick:n[1]||(n[1]=a=>s("retry"))}," 🔄 Retry ")])):(e.openBlock(),e.createElementBlock("div",re,[t.isLoading?(e.openBlock(),e.createElementBlock("div",le,[...n[5]||(n[5]=[e.createElementVNode("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg"},[e.createElementVNode("div",{class:"w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin"})],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",se,[e.createElementVNode("table",ie,[t.showCaption?(e.openBlock(),e.createElementBlock("caption",ce,[e.createTextVNode(e.toDisplayString(t.title)+" - Total: "+e.toDisplayString(((k=(m=t.pagination)==null?void 0:m.meta)==null?void 0:k.total)||0)+" "+e.toDisplayString(t.itemName)+" ",1),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("span",de," ("+e.toDisplayString(d.value)+" selected) ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("thead",ge,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(u).getHeaderGroups(),a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:hover:bg-gray-800"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.headers,c=>(e.openBlock(),e.createElementBlock("th",{key:c.id,colspan:c.colSpan,class:"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 dark:text-gray-400"},[c.isPlaceholder?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-2",c.column.getCanSort()?"cursor-pointer select-none hover:bg-gray-50 dark:hover:bg-gray-800 p-2 rounded transition-colors":""]),onClick:he=>c.column.getCanSort()?s("sortChange",c.column.id):void 0},[e.createVNode(e.unref(h.FlexRender),{render:c.column.columnDef.header,props:c.getContext()},null,8,["render","props"]),c.column.getCanSort()?(e.openBlock(),e.createElementBlock("div",ke,[t.sortBy!==c.column.id?(e.openBlock(),e.createBlock(e.unref(p.ChevronsUpDown),{key:0,size:10,class:"text-gray-400"})):t.sortBy===c.column.id&&t.sortDirection==="asc"?(e.openBlock(),e.createBlock(e.unref(p.ChevronUp),{key:1,size:10,class:"text-gray-900 dark:text-gray-100"})):t.sortBy===c.column.id&&t.sortDirection==="desc"?(e.openBlock(),e.createBlock(e.unref(p.ChevronDown),{key:2,size:10,class:"text-gray-900 dark:text-gray-100"})):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,me))],8,ue))),128))]))),128))]),e.createElementVNode("tbody",fe,[e.unref(u).getRowModel().rows.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(u).getRowModel().rows,a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:e.normalizeClass(["border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:border-gray-700 dark:hover:bg-gray-800",t.enableRowSelection&&a.getIsSelected()?"bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500":""])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.getVisibleCells(),c=>(e.openBlock(),e.createElementBlock("td",{key:c.id,class:"p-4 align-middle [&:has([role=checkbox])]:pr-0"},[e.createVNode(e.unref(h.FlexRender),{render:c.column.columnDef.cell,props:c.getContext()},null,8,["render","props"])]))),128))],2))),128)):(e.openBlock(),e.createElementBlock("tr",pe,[e.createElementVNode("td",{colspan:t.columns.length,class:"h-24 text-center dark:text-gray-400"},e.toDisplayString(t.emptyStateText),9,ye)]))])])]),e.createVNode(B,{pagination:t.pagination,"current-per-page":t.currentPerPage,"per-page-options":t.perPageOptions,"show-per-page-selector":t.showPerPageSelector,onPageChange:n[2]||(n[2]=a=>s("pageChange",a)),onPerPageChange:n[3]||(n[3]=a=>s("perPageChange",a))},null,8,["pagination","current-per-page","per-page-options","show-per-page-selector"])]))])}}});function xe(...t){return S.twMerge(E.clsx(t))}exports.DataTable=be;exports.DataTablePagination=B;exports.cn=xe;exports.useDarkMode=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("@tanstack/vue-table"),k=require("lucide-vue-next"),E=require("clsx"),C=require("tailwind-merge");function S(){const t=e.ref(!1);if(typeof window<"u"){const r=window.matchMedia("(prefers-color-scheme: dark)");t.value=r.matches,r.addEventListener("change",s=>{t.value=s.matches})}e.watchEffect(()=>{typeof document<"u"&&(t.value?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))});function b(){t.value=!t.value}return{isDarkMode:t,toggleDarkMode:b}}const N={class:"flex flex-col items-center justify-between gap-4 px-2 py-2 sm:flex-row text-foreground bg-background"},V={class:"text-sm text-muted-foreground"},P={class:"flex flex-col items-center gap-4 sm:flex-row"},D={key:0,class:"flex items-center gap-2"},R=["value"],$=["value"],T={key:1,class:"flex items-center justify-center"},L={class:"flex items-center gap-1",role:"navigation","aria-label":"pagination"},j=["disabled"],M=["disabled"],F={class:"hidden items-center gap-1 sm:flex"},z=["onClick"],I={key:1,class:"inline-flex items-center justify-center h-10 min-w-10 px-3 text-muted-foreground"},O=["disabled"],q=["disabled"],B=e.defineComponent({__name:"DataTablePagination",props:{pagination:{default:null},perPageOptions:{default:()=>[10,15,25,50,100]},currentPerPage:{default:10},showPerPageSelector:{type:Boolean,default:!0}},emits:["pageChange","perPageChange"],setup(t,{emit:b}){const r=t,s=b,l=e.computed(()=>r.pagination?r.pagination.meta.current_page>1:!1),d=e.computed(()=>r.pagination?r.pagination.meta.current_page<r.pagination.meta.last_page:!1),p=e.computed(()=>{if(!r.pagination)return[];const u=r.pagination.meta.current_page,c=r.pagination.meta.last_page,o=2,n=[],m=[];let f;for(let a=1;a<=c;a++)(a===1||a===c||a>=u-o&&a<=u+o)&&n.push(a);for(const a of n)f&&(a-f===2?m.push(f+1):a-f!==1&&m.push("...")),m.push(a),f=a;return m}),h=u=>{typeof u=="number"&&s("pageChange",u)},g=()=>{l.value&&s("pageChange",1)},v=()=>{d.value&&r.pagination&&s("pageChange",r.pagination.meta.last_page)},w=()=>{l.value&&r.pagination&&s("pageChange",r.pagination.meta.current_page-1)},y=()=>{d.value&&r.pagination&&s("pageChange",r.pagination.meta.current_page+1)};return(u,c)=>(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",V,[t.pagination&&t.pagination.meta.total>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" Showing "+e.toDisplayString(t.pagination.meta.from)+" to "+e.toDisplayString(t.pagination.meta.to)+" of "+e.toDisplayString(t.pagination.meta.total)+" entries ",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(" No entries to show ")],64))]),e.createElementVNode("div",P,[t.showPerPageSelector?(e.openBlock(),e.createElementBlock("div",D,[c[1]||(c[1]=e.createElementVNode("span",{class:"text-sm"},"Rows per page:",-1)),e.createElementVNode("select",{value:t.currentPerPage||t.perPageOptions[0],class:"h-10 rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onChange:c[0]||(c[0]=o=>s("perPageChange",Number(o.target.value)||t.perPageOptions[0]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.perPageOptions,o=>(e.openBlock(),e.createElementBlock("option",{key:o,value:o},e.toDisplayString(o),9,$))),128))],40,R)])):e.createCommentVNode("",!0),t.pagination&&t.pagination.meta.last_page>1?(e.openBlock(),e.createElementBlock("div",T,[e.createElementVNode("nav",L,[e.createElementVNode("button",{disabled:!l.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",l.value?"hover:bg-accent hover:text-accent-foreground":"opacity-50 cursor-not-allowed"]),onClick:g},[e.createVNode(e.unref(k.ChevronsLeft),{class:"h-5 w-5"}),c[2]||(c[2]=e.createElementVNode("span",{class:"sr-only"},"First",-1))],10,j),e.createElementVNode("button",{disabled:!l.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",l.value?"hover:bg-accent hover:text-accent-foreground":"opacity-50 cursor-not-allowed"]),onClick:w},[e.createVNode(e.unref(k.ChevronLeft),{class:"h-5 w-5"}),c[3]||(c[3]=e.createElementVNode("span",{class:"sr-only"},"Previous",-1))],10,M),e.createElementVNode("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(o,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n},[o!=="..."?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",o===t.pagination.meta.current_page?"bg-primary text-primary-foreground hover:bg-primary/90":"hover:bg-accent hover:text-accent-foreground"]),onClick:m=>h(o)},e.toDisplayString(o),11,z)):(e.openBlock(),e.createElementBlock("span",I," ... "))],64))),128))]),e.createElementVNode("button",{disabled:!d.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",d.value?"hover:bg-accent hover:text-accent-foreground":"opacity-50 cursor-not-allowed"]),onClick:y},[e.createVNode(e.unref(k.ChevronRight),{class:"h-5 w-5"}),c[4]||(c[4]=e.createElementVNode("span",{class:"sr-only"},"Next",-1))],10,O),e.createElementVNode("button",{disabled:!d.value,class:e.normalizeClass(["inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",d.value?"hover:bg-accent hover:text-accent-foreground":"opacity-50 cursor-not-allowed"]),onClick:v},[e.createVNode(e.unref(k.ChevronsRight),{class:"h-5 w-5"}),c[5]||(c[5]=e.createElementVNode("span",{class:"sr-only"},"Last",-1))],10,q)])])):e.createCommentVNode("",!0)])]))}}),_={class:"flex flex-col gap-4 bg-background text-foreground"},A={class:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"},G={class:"flex flex-col gap-2 sm:flex-row sm:items-center"},U={key:0,class:"relative w-full max-w-sm"},H=["value"],Q={class:"flex items-center gap-2"},W={class:"flex items-center"},J={key:0,class:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg"},K={class:"flex items-center gap-4"},X={class:"text-sm font-medium text-blue-700 dark:text-blue-300"},Y={class:"text-xs text-blue-600 dark:text-blue-400"},Z={class:"flex items-center gap-2"},ee={key:1,class:"flex items-center justify-center p-8"},te={class:"text-lg text-gray-700 dark:text-gray-200"},oe={key:2,class:"flex flex-col items-center p-8"},ne={class:"mb-2 text-lg text-red-600 dark:text-red-400"},ae={class:"mb-4 text-sm text-gray-600 dark:text-gray-300"},le={key:3,class:"rounded-lg border bg-background dark:border-gray-700"},re={key:0,class:"relative"},se={class:"relative w-full overflow-auto"},ce={class:"w-full caption-bottom text-sm"},ie={key:0,class:"mt-4 text-sm text-muted-foreground dark:text-gray-400"},de={key:0,class:"ml-2 text-blue-600 dark:text-blue-400"},ue={class:"[&_tr]:border-b bg-muted"},ge=["colspan"],me=["onClick"],fe={key:0},pe={class:"[&_tr:last-child]:border-0 dark:[&_tr:last-child]:border-0"},ke={key:1},be=["colspan"],he={key:1,class:"border-t"},ye=["colspan"],xe=e.defineComponent({__name:"DataTable",props:{data:{default:()=>[]},columns:{},pagination:{default:null},isLoading:{type:Boolean,default:!1},error:{default:null},search:{default:""},currentPerPage:{default:10},perPageOptions:{default:()=>[10,15,25,50,100]},sortBy:{default:null},sortDirection:{default:"asc"},rowSelection:{default:()=>({})},enableRowSelection:{type:Boolean,default:!1},getRowId:{type:Function,default:t=>t.id},showSearch:{type:Boolean,default:!0},showCaption:{type:Boolean,default:!0},showPerPageSelector:{type:Boolean,default:!0},title:{default:"Items"},itemName:{default:"items"},loadingText:{default:"Loading..."},errorTitle:{default:"Error loading data"},emptyStateText:{default:"📭 No items found"}},emits:["pageChange","perPageChange","searchChange","sortChange","retry","update:rowSelection"],setup(t,{expose:b,emit:r}){const s=r,l=t,d=e.computed(()=>Object.keys(l.rowSelection||{}).filter(o=>{var n;return(n=l.rowSelection)==null?void 0:n[o]}).length),p=e.computed(()=>Object.keys(l.rowSelection||{}).filter(o=>{var n;return(n=l.rowSelection)==null?void 0:n[o]})),h=e.computed(()=>!l.data||!l.rowSelection?[]:l.data.filter(o=>l.rowSelection[l.getRowId(o)])),g=x.useVueTable({get data(){return l.data||[]},columns:l.columns,getCoreRowModel:x.getCoreRowModel(),enableSorting:!0,manualSorting:!0,enableRowSelection:l.enableRowSelection,getRowId:l.getRowId,state:{rowSelection:l.rowSelection||{}},onRowSelectionChange:o=>{const n=typeof o=="function"?o(l.rowSelection||{}):o;s("update:rowSelection",n)},enableMultiRowSelection:!0,enableSubRowSelection:!1}),v=()=>p.value,w=()=>h.value,y=()=>s("update:rowSelection",{}),u=()=>{const o={...l.rowSelection};g.getRowModel().rows.forEach(n=>{o[n.id]=!0}),s("update:rowSelection",o)},c=()=>{const o={...l.rowSelection};g.getRowModel().rows.forEach(n=>{delete o[n.id]}),s("update:rowSelection",o)};return b({getSelectedRowIds:v,getSelectedRowData:w,clearSelection:y,selectAllCurrentPage:u,deselectAllCurrentPage:c,selectedRowCount:d,selectedRowIds:p,selectedRowData:h,table:g}),(o,n)=>{var m,f;return e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",A,[e.createElementVNode("div",G,[t.showSearch?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("input",{value:t.search,type:"search",placeholder:"Search...",class:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 ps-14 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-gray-200 dark:placeholder:text-gray-400",onInput:n[0]||(n[0]=a=>s("searchChange",a.target.value))},null,40,H)])):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[e.renderSlot(o.$slots,"filters")])]),e.createElementVNode("div",W,[e.renderSlot(o.$slots,"header")])]),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("div",J,[e.createElementVNode("div",K,[e.createElementVNode("span",X,e.toDisplayString(d.value)+" "+e.toDisplayString(t.itemName)+" selected ",1),e.createElementVNode("div",Y," IDs: "+e.toDisplayString(p.value.slice(0,5).join(", "))+e.toDisplayString(p.value.length>5?"...":""),1)]),e.createElementVNode("div",Z,[e.renderSlot(o.$slots,"bulk-actions",{selectedIds:p.value,selectedData:h.value,selectedCount:d.value,clearSelection:y,selectAllCurrentPage:u,deselectAllCurrentPage:c}),o.$slots["bulk-actions"]?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:y,class:"px-3 py-1 text-sm text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-800 rounded transition-colors"}," Clear Selection "))])])):e.createCommentVNode("",!0),t.isLoading&&!t.data?(e.openBlock(),e.createElementBlock("div",ee,[n[4]||(n[4]=e.createElementVNode("div",{class:"w-8 h-8 mr-3 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin"},null,-1)),e.createElementVNode("div",te,e.toDisplayString(t.loadingText),1)])):t.error?(e.openBlock(),e.createElementBlock("div",oe,[e.createElementVNode("div",ne," ❌ "+e.toDisplayString(t.errorTitle),1),e.createElementVNode("div",ae,e.toDisplayString(t.error.message),1),e.createElementVNode("button",{class:"px-4 py-2 text-white transition-colors bg-gray-900 rounded-md hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200",onClick:n[1]||(n[1]=a=>s("retry"))}," 🔄 Retry ")])):(e.openBlock(),e.createElementBlock("div",le,[t.isLoading?(e.openBlock(),e.createElementBlock("div",re,[...n[5]||(n[5]=[e.createElementVNode("div",{class:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg"},[e.createElementVNode("div",{class:"w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin"})],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",se,[e.createElementVNode("table",ce,[t.showCaption?(e.openBlock(),e.createElementBlock("caption",ie,[e.createTextVNode(e.toDisplayString(t.title)+" - Total: "+e.toDisplayString(((f=(m=t.pagination)==null?void 0:m.meta)==null?void 0:f.total)||0)+" "+e.toDisplayString(t.itemName)+" ",1),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("span",de," ("+e.toDisplayString(d.value)+" selected) ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("thead",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g).getHeaderGroups(),a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:"border-b transition-colors"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.headers,i=>(e.openBlock(),e.createElementBlock("th",{key:i.id,colspan:i.colSpan,class:"h-12 px-4 text-left align-middle font-bold text-muted-foreground [&:has([role=checkbox])]:pr-0"},[i.isPlaceholder?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items-center gap-2",i.column.getCanSort()?"cursor-pointer select-none hover:bg-accent p-2 rounded transition-colors":""]),onClick:we=>i.column.getCanSort()?s("sortChange",i.column.id):void 0},[e.createVNode(e.unref(x.FlexRender),{render:i.column.columnDef.header,props:i.getContext()},null,8,["render","props"]),i.column.getCanSort()?(e.openBlock(),e.createElementBlock("div",fe,[t.sortBy!==i.column.id?(e.openBlock(),e.createBlock(e.unref(k.ChevronsUpDown),{key:0,size:10,class:"text-gray-400"})):t.sortBy===i.column.id&&t.sortDirection==="asc"?(e.openBlock(),e.createBlock(e.unref(k.ChevronUp),{key:1,size:10,class:"text-gray-900 dark:text-gray-100"})):t.sortBy===i.column.id&&t.sortDirection==="desc"?(e.openBlock(),e.createBlock(e.unref(k.ChevronDown),{key:2,size:10,class:"text-gray-900 dark:text-gray-100"})):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,me))],8,ge))),128))]))),128))]),e.createElementVNode("tbody",pe,[e.unref(g).getRowModel().rows.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(g).getRowModel().rows,a=>(e.openBlock(),e.createElementBlock("tr",{key:a.id,class:e.normalizeClass(["border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:border-gray-700 dark:hover:bg-gray-800",t.enableRowSelection&&a.getIsSelected()?"bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500":""])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.getVisibleCells(),i=>(e.openBlock(),e.createElementBlock("td",{key:i.id,class:"p-4 align-middle [&:has([role=checkbox])]:pr-0"},[e.createVNode(e.unref(x.FlexRender),{render:i.column.columnDef.cell,props:i.getContext()},null,8,["render","props"])]))),128))],2))),128)):(e.openBlock(),e.createElementBlock("tr",ke,[e.createElementVNode("td",{colspan:t.columns.length,class:"h-24 text-center dark:text-gray-400"},e.toDisplayString(t.emptyStateText),9,be)]))]),t.pagination&&t.pagination.meta.last_page>1?(e.openBlock(),e.createElementBlock("tfoot",he,[e.createElementVNode("tr",null,[e.createElementVNode("td",{colspan:t.columns.length,class:"p-0"},[e.createVNode(B,{pagination:t.pagination,"current-per-page":t.currentPerPage,"per-page-options":t.perPageOptions,"show-per-page-selector":t.showPerPageSelector,onPageChange:n[2]||(n[2]=a=>s("pageChange",a)),onPerPageChange:n[3]||(n[3]=a=>s("perPageChange",a))},null,8,["pagination","current-per-page","per-page-options","show-per-page-selector"])],8,ye)])])):e.createCommentVNode("",!0)])])]))])}}});function ve(...t){return C.twMerge(E.clsx(t))}exports.DataTable=xe;exports.DataTablePagination=B;exports.cn=ve;exports.useDarkMode=S;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { ref as E, watchEffect as O, defineComponent as I, computed as P, createElementBlock as n, openBlock as t, createCommentVNode as f, createElementVNode as a, normalizeClass as w, createVNode as C, unref as b, Fragment as h, renderList as S, toDisplayString as d, createTextVNode as L, renderSlot as B, createBlock as N } from "vue";
1
+ import { ref as E, watchEffect as O, defineComponent as I, computed as P, createElementBlock as a, openBlock as o, createElementVNode as t, Fragment as p, createTextVNode as L, toDisplayString as u, createCommentVNode as f, renderList as S, normalizeClass as k, createVNode as C, unref as b, renderSlot as B, createBlock as N } from "vue";
2
2
  import { useVueTable as V, getCoreRowModel as z, FlexRender as M } from "@tanstack/vue-table";
3
- import { ChevronsLeft as F, ChevronLeft as A, ChevronRight as G, ChevronsRight as U, ChevronsUpDown as _, ChevronUp as H, ChevronDown as Q } from "lucide-vue-next";
3
+ import { ChevronsLeft as F, ChevronLeft as _, ChevronRight as A, ChevronsRight as G, ChevronsUpDown as U, ChevronUp as H, ChevronDown as Q } from "lucide-vue-next";
4
4
  import { clsx as W } from "clsx";
5
5
  import { twMerge as q } from "tailwind-merge";
6
- function We() {
6
+ function Je() {
7
7
  const e = E(!1);
8
8
  if (typeof window < "u") {
9
9
  const i = window.matchMedia("(prefers-color-scheme: dark)");
@@ -22,20 +22,20 @@ function We() {
22
22
  toggleDarkMode: R
23
23
  };
24
24
  }
25
- const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground" }, K = {
25
+ const J = { class: "flex flex-col items-center justify-between gap-4 px-2 py-2 sm:flex-row text-foreground bg-background" }, K = { class: "text-sm text-muted-foreground" }, X = { class: "flex flex-col items-center gap-4 sm:flex-row" }, Y = {
26
26
  key: 0,
27
- class: "flex justify-center"
28
- }, X = {
27
+ class: "flex items-center gap-2"
28
+ }, Z = ["value"], ee = ["value"], te = {
29
+ key: 1,
30
+ class: "flex items-center justify-center"
31
+ }, oe = {
29
32
  class: "flex items-center gap-1",
30
33
  role: "navigation",
31
34
  "aria-label": "pagination"
32
- }, Y = ["disabled"], Z = ["disabled"], ee = { class: "flex items-center gap-1" }, te = ["onClick"], ae = {
35
+ }, ne = ["disabled"], ae = ["disabled"], se = { class: "hidden items-center gap-1 sm:flex" }, re = ["onClick"], le = {
33
36
  key: 1,
34
- class: "inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"
35
- }, oe = ["disabled"], ne = ["disabled"], re = { class: "flex items-center justify-between text-sm text-gray-600 dark:text-gray-300" }, se = {
36
- key: 0,
37
- class: "flex items-center gap-2"
38
- }, le = ["value"], ie = ["value"], de = { key: 1 }, ce = /* @__PURE__ */ I({
37
+ class: "inline-flex items-center justify-center h-10 min-w-10 px-3 text-muted-foreground"
38
+ }, ie = ["disabled"], ce = ["disabled"], de = /* @__PURE__ */ I({
39
39
  __name: "DataTablePagination",
40
40
  props: {
41
41
  pagination: { default: null },
@@ -49,17 +49,17 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
49
49
  () => i.pagination ? i.pagination.meta.current_page > 1 : !1
50
50
  ), m = P(
51
51
  () => i.pagination ? i.pagination.meta.current_page < i.pagination.meta.last_page : !1
52
- ), k = P(() => {
52
+ ), w = P(() => {
53
53
  if (!i.pagination) return [];
54
- const y = i.pagination.meta.current_page, g = i.pagination.meta.last_page, o = 2, r = [], p = [];
55
- let v;
56
- for (let s = 1; s <= g; s++)
57
- (s === 1 || s === g || s >= y - o && s <= y + o) && r.push(s);
58
- for (const s of r)
59
- v && (s - v === 2 ? p.push(v + 1) : s - v !== 1 && p.push("...")), p.push(s), v = s;
60
- return p;
61
- }), $ = (y) => {
62
- typeof y == "number" && c("pageChange", y);
54
+ const h = i.pagination.meta.current_page, d = i.pagination.meta.last_page, n = 2, s = [], v = [];
55
+ let y;
56
+ for (let r = 1; r <= d; r++)
57
+ (r === 1 || r === d || r >= h - n && r <= h + n) && s.push(r);
58
+ for (const r of s)
59
+ y && (r - y === 2 ? v.push(y + 1) : r - y !== 1 && v.push("...")), v.push(r), y = r;
60
+ return v;
61
+ }), $ = (h) => {
62
+ typeof h == "number" && c("pageChange", h);
63
63
  }, x = () => {
64
64
  l.value && c("pageChange", 1);
65
65
  }, T = () => {
@@ -69,99 +69,98 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
69
69
  }, D = () => {
70
70
  m.value && i.pagination && c("pageChange", i.pagination.meta.current_page + 1);
71
71
  };
72
- return (y, g) => (t(), n("div", J, [
73
- e.pagination && e.pagination.meta.last_page > 1 ? (t(), n("div", K, [
74
- a("nav", X, [
75
- a("button", {
76
- disabled: !l.value,
77
- class: w([
78
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
79
- l.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
80
- ]),
81
- onClick: x
82
- }, [
83
- C(b(F), { class: "h-4 w-4" }),
84
- g[1] || (g[1] = a("span", { class: "hidden sm:inline" }, "First", -1))
85
- ], 10, Y),
86
- a("button", {
87
- disabled: !l.value,
88
- class: w([
89
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
90
- l.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
91
- ]),
92
- onClick: j
93
- }, [
94
- C(b(A), { class: "h-4 w-4" }),
95
- g[2] || (g[2] = a("span", { class: "hidden sm:inline" }, "Previous", -1))
96
- ], 10, Z),
97
- a("div", ee, [
98
- (t(!0), n(h, null, S(k.value, (o, r) => (t(), n(h, { key: r }, [
99
- o !== "..." ? (t(), n("button", {
100
- key: 0,
101
- class: w([
102
- "inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",
103
- o === e.pagination.meta.current_page ? "bg-primary text-primary-foreground hover:bg-primary/90 dark:bg-primary dark:text-primary-foreground" : "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200"
104
- ]),
105
- onClick: (p) => $(o)
106
- }, d(o), 11, te)) : (t(), n("span", ae, " ... "))
107
- ], 64))), 128))
108
- ]),
109
- a("button", {
110
- disabled: !m.value,
111
- class: w([
112
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
113
- m.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
114
- ]),
115
- onClick: D
116
- }, [
117
- g[3] || (g[3] = a("span", { class: "hidden sm:inline" }, "Next", -1)),
118
- C(b(G), { class: "h-4 w-4" })
119
- ], 10, oe),
120
- a("button", {
121
- disabled: !m.value,
122
- class: w([
123
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
124
- m.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
125
- ]),
126
- onClick: T
127
- }, [
128
- g[4] || (g[4] = a("span", { class: "hidden sm:inline" }, "Last", -1)),
129
- C(b(U), { class: "h-4 w-4" })
130
- ], 10, ne)
131
- ])
132
- ])) : f("", !0),
133
- a("div", re, [
134
- a("div", null, [
135
- e.pagination && e.pagination.meta.total > 0 ? (t(), n(h, { key: 0 }, [
136
- L(" Showing " + d(e.pagination.meta.from) + " to " + d(e.pagination.meta.to) + " of " + d(e.pagination.meta.total) + " entries ", 1)
137
- ], 64)) : (t(), n(h, { key: 1 }, [
138
- L(" No entries found ")
139
- ], 64))
140
- ]),
141
- e.showPerPageSelector ? (t(), n("div", se, [
142
- g[5] || (g[5] = a("span", null, "Rows per page:", -1)),
143
- a("select", {
72
+ return (h, d) => (o(), a("div", J, [
73
+ t("div", K, [
74
+ e.pagination && e.pagination.meta.total > 0 ? (o(), a(p, { key: 0 }, [
75
+ L(" Showing " + u(e.pagination.meta.from) + " to " + u(e.pagination.meta.to) + " of " + u(e.pagination.meta.total) + " entries ", 1)
76
+ ], 64)) : (o(), a(p, { key: 1 }, [
77
+ L(" No entries to show ")
78
+ ], 64))
79
+ ]),
80
+ t("div", X, [
81
+ e.showPerPageSelector ? (o(), a("div", Y, [
82
+ d[1] || (d[1] = t("span", { class: "text-sm" }, "Rows per page:", -1)),
83
+ t("select", {
144
84
  value: e.currentPerPage || e.perPageOptions[0],
145
- class: "h-10 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 dark:bg-gray-800 dark:text-gray-200 dark:border-gray-700",
146
- onChange: g[0] || (g[0] = (o) => c("perPageChange", Number(o.target.value) || e.perPageOptions[0]))
85
+ class: "h-10 rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
86
+ onChange: d[0] || (d[0] = (n) => c("perPageChange", Number(n.target.value) || e.perPageOptions[0]))
147
87
  }, [
148
- (t(!0), n(h, null, S(e.perPageOptions, (o) => (t(), n("option", {
149
- key: o,
150
- value: o
151
- }, d(o), 9, ie))), 128))
152
- ], 40, le)
88
+ (o(!0), a(p, null, S(e.perPageOptions, (n) => (o(), a("option", {
89
+ key: n,
90
+ value: n
91
+ }, u(n), 9, ee))), 128))
92
+ ], 40, Z)
153
93
  ])) : f("", !0),
154
- e.pagination ? (t(), n("div", de, " Page " + d(e.pagination.meta.current_page) + " of " + d(e.pagination.meta.last_page), 1)) : f("", !0)
94
+ e.pagination && e.pagination.meta.last_page > 1 ? (o(), a("div", te, [
95
+ t("nav", oe, [
96
+ t("button", {
97
+ disabled: !l.value,
98
+ class: k([
99
+ "inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",
100
+ l.value ? "hover:bg-accent hover:text-accent-foreground" : "opacity-50 cursor-not-allowed"
101
+ ]),
102
+ onClick: x
103
+ }, [
104
+ C(b(F), { class: "h-5 w-5" }),
105
+ d[2] || (d[2] = t("span", { class: "sr-only" }, "First", -1))
106
+ ], 10, ne),
107
+ t("button", {
108
+ disabled: !l.value,
109
+ class: k([
110
+ "inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",
111
+ l.value ? "hover:bg-accent hover:text-accent-foreground" : "opacity-50 cursor-not-allowed"
112
+ ]),
113
+ onClick: j
114
+ }, [
115
+ C(b(_), { class: "h-5 w-5" }),
116
+ d[3] || (d[3] = t("span", { class: "sr-only" }, "Previous", -1))
117
+ ], 10, ae),
118
+ t("div", se, [
119
+ (o(!0), a(p, null, S(w.value, (n, s) => (o(), a(p, { key: s }, [
120
+ n !== "..." ? (o(), a("button", {
121
+ key: 0,
122
+ class: k([
123
+ "inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",
124
+ n === e.pagination.meta.current_page ? "bg-primary text-primary-foreground hover:bg-primary/90" : "hover:bg-accent hover:text-accent-foreground"
125
+ ]),
126
+ onClick: (v) => $(n)
127
+ }, u(n), 11, re)) : (o(), a("span", le, " ... "))
128
+ ], 64))), 128))
129
+ ]),
130
+ t("button", {
131
+ disabled: !m.value,
132
+ class: k([
133
+ "inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",
134
+ m.value ? "hover:bg-accent hover:text-accent-foreground" : "opacity-50 cursor-not-allowed"
135
+ ]),
136
+ onClick: D
137
+ }, [
138
+ C(b(A), { class: "h-5 w-5" }),
139
+ d[4] || (d[4] = t("span", { class: "sr-only" }, "Next", -1))
140
+ ], 10, ie),
141
+ t("button", {
142
+ disabled: !m.value,
143
+ class: k([
144
+ "inline-flex items-center justify-center gap-1 h-10 w-10 text-sm font-medium transition-colors rounded-md p-2",
145
+ m.value ? "hover:bg-accent hover:text-accent-foreground" : "opacity-50 cursor-not-allowed"
146
+ ]),
147
+ onClick: T
148
+ }, [
149
+ C(b(G), { class: "h-5 w-5" }),
150
+ d[5] || (d[5] = t("span", { class: "sr-only" }, "Last", -1))
151
+ ], 10, ce)
152
+ ])
153
+ ])) : f("", !0)
155
154
  ])
156
155
  ]));
157
156
  }
158
- }), ge = { class: "flex flex-col gap-4 bg-background text-foreground" }, ue = { class: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" }, me = { class: "flex flex-col gap-2 sm:flex-row sm:items-center" }, fe = {
157
+ }), ue = { class: "flex flex-col gap-4 bg-background text-foreground" }, ge = { class: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" }, me = { class: "flex flex-col gap-2 sm:flex-row sm:items-center" }, fe = {
159
158
  key: 0,
160
159
  class: "relative w-full max-w-sm"
161
- }, be = ["value"], ye = { class: "flex items-center gap-2" }, he = { class: "flex items-center" }, xe = {
160
+ }, be = ["value"], he = { class: "flex items-center gap-2" }, pe = { class: "flex items-center" }, xe = {
162
161
  key: 0,
163
162
  class: "flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg"
164
- }, pe = { class: "flex items-center gap-4" }, ve = { class: "text-sm font-medium text-blue-700 dark:text-blue-300" }, ke = { class: "text-xs text-blue-600 dark:text-blue-400" }, we = { class: "flex items-center gap-2" }, Ce = {
163
+ }, ve = { class: "flex items-center gap-4" }, ye = { class: "text-sm font-medium text-blue-700 dark:text-blue-300" }, we = { class: "text-xs text-blue-600 dark:text-blue-400" }, ke = { class: "flex items-center gap-2" }, Ce = {
165
164
  key: 1,
166
165
  class: "flex items-center justify-center p-8"
167
166
  }, Se = { class: "text-lg text-gray-700 dark:text-gray-200" }, Pe = {
@@ -179,7 +178,10 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
179
178
  }, Le = {
180
179
  key: 0,
181
180
  class: "ml-2 text-blue-600 dark:text-blue-400"
182
- }, Me = { class: "[&_tr]:border-b dark:[&_tr]:border-gray-700" }, Ie = ["colspan"], Ee = ["onClick"], Oe = { key: 0 }, Ve = { class: "[&_tr:last-child]:border-0 dark:[&_tr:last-child]:border-0" }, ze = { key: 1 }, Fe = ["colspan"], qe = /* @__PURE__ */ I({
181
+ }, Me = { class: "[&_tr]:border-b bg-muted" }, Ie = ["colspan"], Ee = ["onClick"], Oe = { key: 0 }, Ve = { class: "[&_tr:last-child]:border-0 dark:[&_tr:last-child]:border-0" }, ze = { key: 1 }, Fe = ["colspan"], _e = {
182
+ key: 1,
183
+ class: "border-t"
184
+ }, Ae = ["colspan"], Ke = /* @__PURE__ */ I({
183
185
  __name: "DataTable",
184
186
  props: {
185
187
  data: { default: () => [] },
@@ -207,16 +209,16 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
207
209
  emits: ["pageChange", "perPageChange", "searchChange", "sortChange", "retry", "update:rowSelection"],
208
210
  setup(e, { expose: R, emit: i }) {
209
211
  const c = i, l = e, m = P(() => Object.keys(l.rowSelection || {}).filter(
210
- (o) => {
211
- var r;
212
- return (r = l.rowSelection) == null ? void 0 : r[o];
212
+ (n) => {
213
+ var s;
214
+ return (s = l.rowSelection) == null ? void 0 : s[n];
213
215
  }
214
- ).length), k = P(() => Object.keys(l.rowSelection || {}).filter(
215
- (o) => {
216
- var r;
217
- return (r = l.rowSelection) == null ? void 0 : r[o];
216
+ ).length), w = P(() => Object.keys(l.rowSelection || {}).filter(
217
+ (n) => {
218
+ var s;
219
+ return (s = l.rowSelection) == null ? void 0 : s[n];
218
220
  }
219
- )), $ = P(() => !l.data || !l.rowSelection ? [] : l.data.filter((o) => l.rowSelection[l.getRowId(o)])), x = V({
221
+ )), $ = P(() => !l.data || !l.rowSelection ? [] : l.data.filter((n) => l.rowSelection[l.getRowId(n)])), x = V({
220
222
  get data() {
221
223
  return l.data || [];
222
224
  },
@@ -229,130 +231,130 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
229
231
  state: {
230
232
  rowSelection: l.rowSelection || {}
231
233
  },
232
- onRowSelectionChange: (o) => {
233
- const r = typeof o == "function" ? o(l.rowSelection || {}) : o;
234
- c("update:rowSelection", r);
234
+ onRowSelectionChange: (n) => {
235
+ const s = typeof n == "function" ? n(l.rowSelection || {}) : n;
236
+ c("update:rowSelection", s);
235
237
  },
236
238
  enableMultiRowSelection: !0,
237
239
  enableSubRowSelection: !1
238
- }), T = () => k.value, j = () => $.value, D = () => c("update:rowSelection", {}), y = () => {
239
- const o = { ...l.rowSelection };
240
- x.getRowModel().rows.forEach((r) => {
241
- o[r.id] = !0;
242
- }), c("update:rowSelection", o);
243
- }, g = () => {
244
- const o = { ...l.rowSelection };
245
- x.getRowModel().rows.forEach((r) => {
246
- delete o[r.id];
247
- }), c("update:rowSelection", o);
240
+ }), T = () => w.value, j = () => $.value, D = () => c("update:rowSelection", {}), h = () => {
241
+ const n = { ...l.rowSelection };
242
+ x.getRowModel().rows.forEach((s) => {
243
+ n[s.id] = !0;
244
+ }), c("update:rowSelection", n);
245
+ }, d = () => {
246
+ const n = { ...l.rowSelection };
247
+ x.getRowModel().rows.forEach((s) => {
248
+ delete n[s.id];
249
+ }), c("update:rowSelection", n);
248
250
  };
249
251
  return R({
250
252
  getSelectedRowIds: T,
251
253
  getSelectedRowData: j,
252
254
  clearSelection: D,
253
- selectAllCurrentPage: y,
254
- deselectAllCurrentPage: g,
255
+ selectAllCurrentPage: h,
256
+ deselectAllCurrentPage: d,
255
257
  selectedRowCount: m,
256
- selectedRowIds: k,
258
+ selectedRowIds: w,
257
259
  selectedRowData: $,
258
260
  table: x
259
- }), (o, r) => {
260
- var p, v;
261
- return t(), n("div", ge, [
262
- a("div", ue, [
263
- a("div", me, [
264
- e.showSearch ? (t(), n("div", fe, [
265
- a("input", {
261
+ }), (n, s) => {
262
+ var v, y;
263
+ return o(), a("div", ue, [
264
+ t("div", ge, [
265
+ t("div", me, [
266
+ e.showSearch ? (o(), a("div", fe, [
267
+ t("input", {
266
268
  value: e.search,
267
269
  type: "search",
268
270
  placeholder: "Search...",
269
271
  class: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 ps-14 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-gray-800 dark:text-gray-200 dark:placeholder:text-gray-400",
270
- onInput: r[0] || (r[0] = (s) => c("searchChange", s.target.value))
272
+ onInput: s[0] || (s[0] = (r) => c("searchChange", r.target.value))
271
273
  }, null, 40, be)
272
274
  ])) : f("", !0),
273
- a("div", ye, [
274
- B(o.$slots, "filters")
275
+ t("div", he, [
276
+ B(n.$slots, "filters")
275
277
  ])
276
278
  ]),
277
- a("div", he, [
278
- B(o.$slots, "header")
279
+ t("div", pe, [
280
+ B(n.$slots, "header")
279
281
  ])
280
282
  ]),
281
- e.enableRowSelection && m.value > 0 ? (t(), n("div", xe, [
282
- a("div", pe, [
283
- a("span", ve, d(m.value) + " " + d(e.itemName) + " selected ", 1),
284
- a("div", ke, " IDs: " + d(k.value.slice(0, 5).join(", ")) + d(k.value.length > 5 ? "..." : ""), 1)
283
+ e.enableRowSelection && m.value > 0 ? (o(), a("div", xe, [
284
+ t("div", ve, [
285
+ t("span", ye, u(m.value) + " " + u(e.itemName) + " selected ", 1),
286
+ t("div", we, " IDs: " + u(w.value.slice(0, 5).join(", ")) + u(w.value.length > 5 ? "..." : ""), 1)
285
287
  ]),
286
- a("div", we, [
287
- B(o.$slots, "bulk-actions", {
288
- selectedIds: k.value,
288
+ t("div", ke, [
289
+ B(n.$slots, "bulk-actions", {
290
+ selectedIds: w.value,
289
291
  selectedData: $.value,
290
292
  selectedCount: m.value,
291
293
  clearSelection: D,
292
- selectAllCurrentPage: y,
293
- deselectAllCurrentPage: g
294
+ selectAllCurrentPage: h,
295
+ deselectAllCurrentPage: d
294
296
  }),
295
- o.$slots["bulk-actions"] ? f("", !0) : (t(), n("button", {
297
+ n.$slots["bulk-actions"] ? f("", !0) : (o(), a("button", {
296
298
  key: 0,
297
299
  onClick: D,
298
300
  class: "px-3 py-1 text-sm text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-800 rounded transition-colors"
299
301
  }, " Clear Selection "))
300
302
  ])
301
303
  ])) : f("", !0),
302
- e.isLoading && !e.data ? (t(), n("div", Ce, [
303
- r[4] || (r[4] = a("div", { class: "w-8 h-8 mr-3 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" }, null, -1)),
304
- a("div", Se, d(e.loadingText), 1)
305
- ])) : e.error ? (t(), n("div", Pe, [
306
- a("div", Re, " ❌ " + d(e.errorTitle), 1),
307
- a("div", $e, d(e.error.message), 1),
308
- a("button", {
304
+ e.isLoading && !e.data ? (o(), a("div", Ce, [
305
+ s[4] || (s[4] = t("div", { class: "w-8 h-8 mr-3 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" }, null, -1)),
306
+ t("div", Se, u(e.loadingText), 1)
307
+ ])) : e.error ? (o(), a("div", Pe, [
308
+ t("div", Re, " ❌ " + u(e.errorTitle), 1),
309
+ t("div", $e, u(e.error.message), 1),
310
+ t("button", {
309
311
  class: "px-4 py-2 text-white transition-colors bg-gray-900 rounded-md hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-200",
310
- onClick: r[1] || (r[1] = (s) => c("retry"))
312
+ onClick: s[1] || (s[1] = (r) => c("retry"))
311
313
  }, " 🔄 Retry ")
312
- ])) : (t(), n("div", De, [
313
- e.isLoading ? (t(), n("div", Te, [...r[5] || (r[5] = [
314
- a("div", { class: "absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg" }, [
315
- a("div", { class: "w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" })
314
+ ])) : (o(), a("div", De, [
315
+ e.isLoading ? (o(), a("div", Te, [...s[5] || (s[5] = [
316
+ t("div", { class: "absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg" }, [
317
+ t("div", { class: "w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" })
316
318
  ], -1)
317
319
  ])])) : f("", !0),
318
- a("div", je, [
319
- a("table", Be, [
320
- e.showCaption ? (t(), n("caption", Ne, [
321
- L(d(e.title) + " - Total: " + d(((v = (p = e.pagination) == null ? void 0 : p.meta) == null ? void 0 : v.total) || 0) + " " + d(e.itemName) + " ", 1),
322
- e.enableRowSelection && m.value > 0 ? (t(), n("span", Le, " (" + d(m.value) + " selected) ", 1)) : f("", !0)
320
+ t("div", je, [
321
+ t("table", Be, [
322
+ e.showCaption ? (o(), a("caption", Ne, [
323
+ L(u(e.title) + " - Total: " + u(((y = (v = e.pagination) == null ? void 0 : v.meta) == null ? void 0 : y.total) || 0) + " " + u(e.itemName) + " ", 1),
324
+ e.enableRowSelection && m.value > 0 ? (o(), a("span", Le, " (" + u(m.value) + " selected) ", 1)) : f("", !0)
323
325
  ])) : f("", !0),
324
- a("thead", Me, [
325
- (t(!0), n(h, null, S(b(x).getHeaderGroups(), (s) => (t(), n("tr", {
326
- key: s.id,
327
- class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:hover:bg-gray-800"
326
+ t("thead", Me, [
327
+ (o(!0), a(p, null, S(b(x).getHeaderGroups(), (r) => (o(), a("tr", {
328
+ key: r.id,
329
+ class: "border-b transition-colors"
328
330
  }, [
329
- (t(!0), n(h, null, S(s.headers, (u) => (t(), n("th", {
330
- key: u.id,
331
- colspan: u.colSpan,
332
- class: "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 dark:text-gray-400"
331
+ (o(!0), a(p, null, S(r.headers, (g) => (o(), a("th", {
332
+ key: g.id,
333
+ colspan: g.colSpan,
334
+ class: "h-12 px-4 text-left align-middle font-bold text-muted-foreground [&:has([role=checkbox])]:pr-0"
333
335
  }, [
334
- u.isPlaceholder ? f("", !0) : (t(), n("div", {
336
+ g.isPlaceholder ? f("", !0) : (o(), a("div", {
335
337
  key: 0,
336
- class: w([
338
+ class: k([
337
339
  "flex items-center gap-2",
338
- u.column.getCanSort() ? "cursor-pointer select-none hover:bg-gray-50 dark:hover:bg-gray-800 p-2 rounded transition-colors" : ""
340
+ g.column.getCanSort() ? "cursor-pointer select-none hover:bg-accent p-2 rounded transition-colors" : ""
339
341
  ]),
340
- onClick: (Ae) => u.column.getCanSort() ? c("sortChange", u.column.id) : void 0
342
+ onClick: (Ge) => g.column.getCanSort() ? c("sortChange", g.column.id) : void 0
341
343
  }, [
342
344
  C(b(M), {
343
- render: u.column.columnDef.header,
344
- props: u.getContext()
345
+ render: g.column.columnDef.header,
346
+ props: g.getContext()
345
347
  }, null, 8, ["render", "props"]),
346
- u.column.getCanSort() ? (t(), n("div", Oe, [
347
- e.sortBy !== u.column.id ? (t(), N(b(_), {
348
+ g.column.getCanSort() ? (o(), a("div", Oe, [
349
+ e.sortBy !== g.column.id ? (o(), N(b(U), {
348
350
  key: 0,
349
351
  size: 10,
350
352
  class: "text-gray-400"
351
- })) : e.sortBy === u.column.id && e.sortDirection === "asc" ? (t(), N(b(H), {
353
+ })) : e.sortBy === g.column.id && e.sortDirection === "asc" ? (o(), N(b(H), {
352
354
  key: 1,
353
355
  size: 10,
354
356
  class: "text-gray-900 dark:text-gray-100"
355
- })) : e.sortBy === u.column.id && e.sortDirection === "desc" ? (t(), N(b(Q), {
357
+ })) : e.sortBy === g.column.id && e.sortDirection === "desc" ? (o(), N(b(Q), {
356
358
  key: 2,
357
359
  size: 10,
358
360
  class: "text-gray-900 dark:text-gray-100"
@@ -362,51 +364,60 @@ const J = { class: "flex flex-col gap-4 px-2 py-4 bg-background text-foreground"
362
364
  ], 8, Ie))), 128))
363
365
  ]))), 128))
364
366
  ]),
365
- a("tbody", Ve, [
366
- b(x).getRowModel().rows.length > 0 ? (t(!0), n(h, { key: 0 }, S(b(x).getRowModel().rows, (s) => (t(), n("tr", {
367
- key: s.id,
368
- class: w([
367
+ t("tbody", Ve, [
368
+ b(x).getRowModel().rows.length > 0 ? (o(!0), a(p, { key: 0 }, S(b(x).getRowModel().rows, (r) => (o(), a("tr", {
369
+ key: r.id,
370
+ class: k([
369
371
  "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:border-gray-700 dark:hover:bg-gray-800",
370
- e.enableRowSelection && s.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
372
+ e.enableRowSelection && r.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
371
373
  ])
372
374
  }, [
373
- (t(!0), n(h, null, S(s.getVisibleCells(), (u) => (t(), n("td", {
374
- key: u.id,
375
+ (o(!0), a(p, null, S(r.getVisibleCells(), (g) => (o(), a("td", {
376
+ key: g.id,
375
377
  class: "p-4 align-middle [&:has([role=checkbox])]:pr-0"
376
378
  }, [
377
379
  C(b(M), {
378
- render: u.column.columnDef.cell,
379
- props: u.getContext()
380
+ render: g.column.columnDef.cell,
381
+ props: g.getContext()
380
382
  }, null, 8, ["render", "props"])
381
383
  ]))), 128))
382
- ], 2))), 128)) : (t(), n("tr", ze, [
383
- a("td", {
384
+ ], 2))), 128)) : (o(), a("tr", ze, [
385
+ t("td", {
384
386
  colspan: e.columns.length,
385
387
  class: "h-24 text-center dark:text-gray-400"
386
- }, d(e.emptyStateText), 9, Fe)
388
+ }, u(e.emptyStateText), 9, Fe)
387
389
  ]))
388
- ])
390
+ ]),
391
+ e.pagination && e.pagination.meta.last_page > 1 ? (o(), a("tfoot", _e, [
392
+ t("tr", null, [
393
+ t("td", {
394
+ colspan: e.columns.length,
395
+ class: "p-0"
396
+ }, [
397
+ C(de, {
398
+ pagination: e.pagination,
399
+ "current-per-page": e.currentPerPage,
400
+ "per-page-options": e.perPageOptions,
401
+ "show-per-page-selector": e.showPerPageSelector,
402
+ onPageChange: s[2] || (s[2] = (r) => c("pageChange", r)),
403
+ onPerPageChange: s[3] || (s[3] = (r) => c("perPageChange", r))
404
+ }, null, 8, ["pagination", "current-per-page", "per-page-options", "show-per-page-selector"])
405
+ ], 8, Ae)
406
+ ])
407
+ ])) : f("", !0)
389
408
  ])
390
- ]),
391
- C(ce, {
392
- pagination: e.pagination,
393
- "current-per-page": e.currentPerPage,
394
- "per-page-options": e.perPageOptions,
395
- "show-per-page-selector": e.showPerPageSelector,
396
- onPageChange: r[2] || (r[2] = (s) => c("pageChange", s)),
397
- onPerPageChange: r[3] || (r[3] = (s) => c("perPageChange", s))
398
- }, null, 8, ["pagination", "current-per-page", "per-page-options", "show-per-page-selector"])
409
+ ])
399
410
  ]))
400
411
  ]);
401
412
  };
402
413
  }
403
414
  });
404
- function Je(...e) {
415
+ function Xe(...e) {
405
416
  return q(W(e));
406
417
  }
407
418
  export {
408
- qe as DataTable,
409
- ce as DataTablePagination,
410
- Je as cn,
411
- We as useDarkMode
419
+ Ke as DataTable,
420
+ de as DataTablePagination,
421
+ Xe as cn,
422
+ Je as useDarkMode
412
423
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toniel/laravel-tanstack-datatable",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Vue 3 DataTable components for Laravel pagination with TanStack Query and shadcn-vue",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",