@toniel/laravel-tanstack-datatable 0.1.4 → 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.
@@ -10,7 +10,7 @@ interface Props {
10
10
  currentPerPage?: number;
11
11
  perPageOptions?: number[];
12
12
  sortBy?: string | null;
13
- sortDirection?: 'asc' | 'desc';
13
+ sortDirection?: "asc" | "desc";
14
14
  rowSelection?: RowSelectionState;
15
15
  enableRowSelection?: boolean;
16
16
  getRowId?: (row: any) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTable.vue"],"names":[],"mappings":"AA4WA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAK5B,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACZ,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAG9B,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAA;IAG/B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAG7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AA8ID,iBAAS,cAAc;WA8TT,OAAO,IAA6B;;yBAZrB,GAAG;wBACJ,GAAG;;;;;;;;YACK,GAAG;;;;EAetC;AAsBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;gBAjgBN,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;wFAmfvB,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"}
@@ -0,0 +1,5 @@
1
+ export declare function useDarkMode(): {
2
+ isDarkMode: import('vue').Ref<boolean, boolean>;
3
+ toggleDarkMode: () => void;
4
+ };
5
+ //# sourceMappingURL=useDarkMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDarkMode.d.ts","sourceRoot":"","sources":["../../src/composables/useDarkMode.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW;;;EA8B1B"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { useDarkMode } from './composables/useDarkMode';
1
2
  export { default as DataTable } from './components/DataTable.vue';
2
3
  export { default as DataTablePagination } from './components/DataTablePagination.vue';
3
4
  export { cn } from './lib/utils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAGrF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAGvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAGrF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),x=require("@tanstack/vue-table"),y=require("lucide-vue-next"),S=require("clsx"),C=require("tailwind-merge"),E={class:"flex flex-col gap-4 px-2 py-4"},N={key:0,class:"flex justify-center"},V={class:"flex items-center gap-1",role:"navigation","aria-label":"pagination"},P=["disabled"],D=["disabled"],R={class:"flex items-center gap-1"},$=["onClick"],T={key:1,class:"inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"},j=["disabled"],F=["disabled"],L={class:"flex items-center justify-between text-sm text-gray-600 dark:text-gray-300"},I={key:0,class:"flex items-center gap-2"},z=["value"],M=["value"],O={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:h}){const s=t,i=h,l=e.computed(()=>s.pagination?s.pagination.meta.current_page>1:!1),d=e.computed(()=>s.pagination?s.pagination.meta.current_page<s.pagination.meta.last_page:!1),f=e.computed(()=>{if(!s.pagination)return[];const g=s.pagination.meta.current_page,r=s.pagination.meta.last_page,o=2,n=[],m=[];let p;for(let a=1;a<=r;a++)(a===1||a===r||a>=g-o&&a<=g+o)&&n.push(a);for(const a of n)p&&(a-p===2?m.push(p+1):a-p!==1&&m.push("...")),m.push(a),p=a;return m}),k=g=>{typeof g=="number"&&i("pageChange",g)},u=()=>{l.value&&i("pageChange",1)},v=()=>{d.value&&s.pagination&&i("pageChange",s.pagination.meta.last_page)},w=()=>{l.value&&s.pagination&&i("pageChange",s.pagination.meta.current_page-1)},b=()=>{d.value&&s.pagination&&i("pageChange",s.pagination.meta.current_page+1)};return(g,r)=>(e.openBlock(),e.createElementBlock("div",E,[t.pagination&&t.pagination.meta.last_page>1?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("nav",V,[e.createElementVNode("button",{disabled:!l.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",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"]),onClick:u},[e.createVNode(e.unref(y.ChevronsLeft),{class:"h-4 w-4"}),r[1]||(r[1]=e.createElementVNode("span",{class:"hidden sm:inline"},"First",-1))],10,P),e.createElementVNode("button",{disabled:!l.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",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"]),onClick:w},[e.createVNode(e.unref(y.ChevronLeft),{class:"h-4 w-4"}),r[2]||(r[2]=e.createElementVNode("span",{class:"hidden sm:inline"},"Previous",-1))],10,D),e.createElementVNode("div",R,[(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":"hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200"]),onClick:m=>k(o)},e.toDisplayString(o),11,$)):(e.openBlock(),e.createElementBlock("span",T," ... "))],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:b},[r[3]||(r[3]=e.createElementVNode("span",{class:"hidden sm:inline"},"Next",-1)),e.createVNode(e.unref(y.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},[r[4]||(r[4]=e.createElementVNode("span",{class:"hidden sm:inline"},"Last",-1)),e.createVNode(e.unref(y.ChevronsRight),{class:"h-4 w-4"})],10,F)])])):e.createCommentVNode("",!0),e.createElementVNode("div",L,[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",I,[r[5]||(r[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",onChange:r[0]||(r[0]=o=>i("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,M))),128))],40,z)])):e.createCommentVNode("",!0),t.pagination?(e.openBlock(),e.createElementBlock("div",O," Page "+e.toDisplayString(t.pagination.meta.current_page)+" of "+e.toDisplayString(t.pagination.meta.last_page),1)):e.createCommentVNode("",!0)])]))}}),q={class:"flex flex-col gap-4"},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"},_={key:0,class:"relative w-full max-w-sm"},H=["value"],U={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"},Q={class:"text-sm font-medium text-blue-700 dark:text-blue-300"},X={class:"text-xs text-blue-600 dark:text-blue-400"},Y={class:"flex items-center gap-2"},Z={key:1,class:"flex items-center justify-center p-8"},ee={class:"text-lg text-gray-700 dark:text-gray-200"},te={key:2,class:"flex flex-col items-center p-8"},oe={class:"mb-2 text-lg text-red-600 dark:text-red-400"},ne={class:"mb-4 text-sm text-gray-600 dark:text-gray-300"},ae={key:3,class:"rounded-lg border bg-white dark:bg-gray-900"},le={key:0,class:"relative"},re={class:"relative w-full overflow-auto"},se={class:"w-full caption-bottom text-sm"},ie={key:0,class:"mt-4 text-sm text-muted-foreground"},ce={key:0,class:"ml-2 text-blue-600 dark:text-blue-400"},de={class:"[&_tr]:border-b"},ge=["colspan"],ue=["onClick"],me={key:0,class:"flex flex-col"},pe={class:"[&_tr:last-child]:border-0"},fe={key:1},ye=["colspan"],ke=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:h,emit:s}){const i=s,l=t,d=e.computed(()=>Object.keys(l.rowSelection||{}).filter(o=>{var n;return(n=l.rowSelection)==null?void 0:n[o]}).length),f=e.computed(()=>Object.keys(l.rowSelection||{}).filter(o=>{var n;return(n=l.rowSelection)==null?void 0:n[o]})),k=e.computed(()=>!l.data||!l.rowSelection?[]:l.data.filter(o=>l.rowSelection[l.getRowId(o)])),u=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;i("update:rowSelection",n)},enableMultiRowSelection:!0,enableSubRowSelection:!1}),v=()=>f.value,w=()=>k.value,b=()=>i("update:rowSelection",{}),g=()=>{const o={...l.rowSelection};u.getRowModel().rows.forEach(n=>{o[n.id]=!0}),i("update:rowSelection",o)},r=()=>{const o={...l.rowSelection};u.getRowModel().rows.forEach(n=>{delete o[n.id]}),i("update:rowSelection",o)};return h({getSelectedRowIds:v,getSelectedRowData:w,clearSelection:b,selectAllCurrentPage:g,deselectAllCurrentPage:r,selectedRowCount:d,selectedRowIds:f,selectedRowData:k,table:u}),(o,n)=>{var m,p;return e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",A,[e.createElementVNode("div",G,[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",onInput:n[0]||(n[0]=a=>i("searchChange",a.target.value))},null,40,H)])):e.createCommentVNode("",!0),e.createElementVNode("div",U,[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",Q,e.toDisplayString(d.value)+" "+e.toDisplayString(t.itemName)+" selected ",1),e.createElementVNode("div",X," IDs: "+e.toDisplayString(f.value.slice(0,5).join(", "))+e.toDisplayString(f.value.length>5?"...":""),1)]),e.createElementVNode("div",Y,[e.renderSlot(o.$slots,"bulk-actions",{selectedIds:f.value,selectedData:k.value,selectedCount:d.value,clearSelection:b,selectAllCurrentPage:g,deselectAllCurrentPage:r}),o.$slots["bulk-actions"]?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:b,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",Z,[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",ee,e.toDisplayString(t.loadingText),1)])):t.error?(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",oe,"❌ "+e.toDisplayString(t.errorTitle),1),e.createElementVNode("div",ne,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=>i("retry"))}," 🔄 Retry ")])):(e.openBlock(),e.createElementBlock("div",ae,[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",re,[e.createElementVNode("table",se,[t.showCaption?(e.openBlock(),e.createElementBlock("caption",ie,[e.createTextVNode(e.toDisplayString(t.title)+" - Total: "+e.toDisplayString(((p=(m=t.pagination)==null?void 0:m.meta)==null?void 0:p.total)||0)+" "+e.toDisplayString(t.itemName)+" ",1),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("span",ce," ("+e.toDisplayString(d.value)+" selected) ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("thead",de,[(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"},[(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"},[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:xe=>c.column.getCanSort()?i("sortChange",c.column.id):void 0},[e.createVNode(e.unref(x.FlexRender),{render:c.column.columnDef.header,props:c.getContext()},null,8,["render","props"]),c.column.getCanSort()?(e.openBlock(),e.createElementBlock("div",me,[e.createVNode(e.unref(y.ChevronUp),{class:e.normalizeClass(["w-3 h-3 transition-colors",t.sortBy===c.column.id&&t.sortDirection==="asc"?"text-gray-900 dark:text-gray-100":"text-gray-400"])},null,8,["class"]),e.createVNode(e.unref(y.ChevronDown),{class:e.normalizeClass(["w-3 h-3 -mt-1 transition-colors",t.sortBy===c.column.id&&t.sortDirection==="desc"?"text-gray-900 dark:text-gray-100":"text-gray-400"])},null,8,["class"])])):e.createCommentVNode("",!0)],10,ue))],8,ge))),128))]))),128))]),e.createElementVNode("tbody",pe,[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",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(x.FlexRender),{render:c.column.columnDef.cell,props:c.getContext()},null,8,["render","props"])]))),128))],2))),128)):(e.openBlock(),e.createElementBlock("tr",fe,[e.createElementVNode("td",{colspan:t.columns.length,class:"h-24 text-center"},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=>i("pageChange",a)),onPerPageChange:n[3]||(n[3]=a=>i("perPageChange",a))},null,8,["pagination","current-per-page","per-page-options","show-per-page-selector"])]))])}}});function be(...t){return C.twMerge(S.clsx(t))}exports.DataTable=ke;exports.DataTablePagination=B;exports.cn=be;
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,22 +1,41 @@
1
- import { defineComponent as L, computed as P, createElementBlock as a, openBlock as n, createCommentVNode as f, createElementVNode as t, normalizeClass as x, createVNode as h, unref as b, Fragment as p, renderList as S, toDisplayString as i, createTextVNode as B, renderSlot as N } from "vue";
2
- import { useVueTable as M, getCoreRowModel as O, FlexRender as I } from "@tanstack/vue-table";
3
- import { ChevronsLeft as V, ChevronLeft as E, ChevronRight as F, ChevronsRight as z, ChevronUp as A, ChevronDown as G } from "lucide-vue-next";
4
- import { clsx as _ } from "clsx";
5
- import { twMerge as H } from "tailwind-merge";
6
- const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
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
+ import { useVueTable as V, getCoreRowModel as z, FlexRender as M } from "@tanstack/vue-table";
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
+ import { clsx as W } from "clsx";
5
+ import { twMerge as q } from "tailwind-merge";
6
+ function Je() {
7
+ const e = E(!1);
8
+ if (typeof window < "u") {
9
+ const i = window.matchMedia("(prefers-color-scheme: dark)");
10
+ e.value = i.matches, i.addEventListener("change", (c) => {
11
+ e.value = c.matches;
12
+ });
13
+ }
14
+ O(() => {
15
+ typeof document < "u" && (e.value ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
16
+ });
17
+ function R() {
18
+ e.value = !e.value;
19
+ }
20
+ return {
21
+ isDarkMode: e,
22
+ toggleDarkMode: R
23
+ };
24
+ }
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 = {
7
26
  key: 0,
8
- class: "flex justify-center"
9
- }, q = {
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 = {
10
32
  class: "flex items-center gap-1",
11
33
  role: "navigation",
12
34
  "aria-label": "pagination"
13
- }, J = ["disabled"], K = ["disabled"], Q = { class: "flex items-center gap-1" }, X = ["onClick"], Y = {
35
+ }, ne = ["disabled"], ae = ["disabled"], se = { class: "hidden items-center gap-1 sm:flex" }, re = ["onClick"], le = {
14
36
  key: 1,
15
- class: "inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"
16
- }, Z = ["disabled"], ee = ["disabled"], te = { class: "flex items-center justify-between text-sm text-gray-600 dark:text-gray-300" }, oe = {
17
- key: 0,
18
- class: "flex items-center gap-2"
19
- }, ae = ["value"], ne = ["value"], re = { key: 1 }, se = /* @__PURE__ */ L({
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({
20
39
  __name: "DataTablePagination",
21
40
  props: {
22
41
  pagination: { default: null },
@@ -25,145 +44,144 @@ const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
25
44
  showPerPageSelector: { type: Boolean, default: !0 }
26
45
  },
27
46
  emits: ["pageChange", "perPageChange"],
28
- setup(e, { emit: T }) {
29
- const c = e, g = T, l = P(
30
- () => c.pagination ? c.pagination.meta.current_page > 1 : !1
47
+ setup(e, { emit: R }) {
48
+ const i = e, c = R, l = P(
49
+ () => i.pagination ? i.pagination.meta.current_page > 1 : !1
31
50
  ), m = P(
32
- () => c.pagination ? c.pagination.meta.current_page < c.pagination.meta.last_page : !1
33
- ), C = P(() => {
34
- if (!c.pagination) return [];
35
- const y = c.pagination.meta.current_page, d = c.pagination.meta.last_page, o = 2, r = [], w = [];
36
- let k;
37
- for (let s = 1; s <= d; s++)
38
- (s === 1 || s === d || s >= y - o && s <= y + o) && r.push(s);
39
- for (const s of r)
40
- k && (s - k === 2 ? w.push(k + 1) : s - k !== 1 && w.push("...")), w.push(s), k = s;
41
- return w;
42
- }), R = (y) => {
43
- typeof y == "number" && g("pageChange", y);
44
- }, v = () => {
45
- l.value && g("pageChange", 1);
46
- }, D = () => {
47
- m.value && c.pagination && g("pageChange", c.pagination.meta.last_page);
51
+ () => i.pagination ? i.pagination.meta.current_page < i.pagination.meta.last_page : !1
52
+ ), w = P(() => {
53
+ if (!i.pagination) return [];
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
+ }, x = () => {
64
+ l.value && c("pageChange", 1);
65
+ }, T = () => {
66
+ m.value && i.pagination && c("pageChange", i.pagination.meta.last_page);
48
67
  }, j = () => {
49
- l.value && c.pagination && g("pageChange", c.pagination.meta.current_page - 1);
50
- }, $ = () => {
51
- m.value && c.pagination && g("pageChange", c.pagination.meta.current_page + 1);
68
+ l.value && i.pagination && c("pageChange", i.pagination.meta.current_page - 1);
69
+ }, D = () => {
70
+ m.value && i.pagination && c("pageChange", i.pagination.meta.current_page + 1);
52
71
  };
53
- return (y, d) => (n(), a("div", U, [
54
- e.pagination && e.pagination.meta.last_page > 1 ? (n(), a("div", W, [
55
- t("nav", q, [
56
- t("button", {
57
- disabled: !l.value,
58
- class: x([
59
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
60
- 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"
61
- ]),
62
- onClick: v
63
- }, [
64
- h(b(V), { class: "h-4 w-4" }),
65
- d[1] || (d[1] = t("span", { class: "hidden sm:inline" }, "First", -1))
66
- ], 10, J),
67
- t("button", {
68
- disabled: !l.value,
69
- class: x([
70
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
71
- 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"
72
- ]),
73
- onClick: j
74
- }, [
75
- h(b(E), { class: "h-4 w-4" }),
76
- d[2] || (d[2] = t("span", { class: "hidden sm:inline" }, "Previous", -1))
77
- ], 10, K),
78
- t("div", Q, [
79
- (n(!0), a(p, null, S(C.value, (o, r) => (n(), a(p, { key: r }, [
80
- o !== "..." ? (n(), a("button", {
81
- key: 0,
82
- class: x([
83
- "inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",
84
- o === e.pagination.meta.current_page ? "bg-primary text-primary-foreground hover:bg-primary/90" : "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200"
85
- ]),
86
- onClick: (w) => R(o)
87
- }, i(o), 11, X)) : (n(), a("span", Y, " ... "))
88
- ], 64))), 128))
89
- ]),
90
- t("button", {
91
- disabled: !m.value,
92
- class: x([
93
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
94
- 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"
95
- ]),
96
- onClick: $
97
- }, [
98
- d[3] || (d[3] = t("span", { class: "hidden sm:inline" }, "Next", -1)),
99
- h(b(F), { class: "h-4 w-4" })
100
- ], 10, Z),
101
- t("button", {
102
- disabled: !m.value,
103
- class: x([
104
- "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
105
- 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"
106
- ]),
107
- onClick: D
108
- }, [
109
- d[4] || (d[4] = t("span", { class: "hidden sm:inline" }, "Last", -1)),
110
- h(b(z), { class: "h-4 w-4" })
111
- ], 10, ee)
112
- ])
113
- ])) : f("", !0),
114
- t("div", te, [
115
- t("div", null, [
116
- e.pagination && e.pagination.meta.total > 0 ? (n(), a(p, { key: 0 }, [
117
- B(" Showing " + i(e.pagination.meta.from) + " to " + i(e.pagination.meta.to) + " of " + i(e.pagination.meta.total) + " entries ", 1)
118
- ], 64)) : (n(), a(p, { key: 1 }, [
119
- B(" No entries found ")
120
- ], 64))
121
- ]),
122
- e.showPerPageSelector ? (n(), a("div", oe, [
123
- d[5] || (d[5] = t("span", null, "Rows per page:", -1)),
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)),
124
83
  t("select", {
125
84
  value: e.currentPerPage || e.perPageOptions[0],
126
- 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",
127
- onChange: d[0] || (d[0] = (o) => g("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]))
128
87
  }, [
129
- (n(!0), a(p, null, S(e.perPageOptions, (o) => (n(), a("option", {
130
- key: o,
131
- value: o
132
- }, i(o), 9, ne))), 128))
133
- ], 40, ae)
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)
134
93
  ])) : f("", !0),
135
- e.pagination ? (n(), a("div", re, " Page " + i(e.pagination.meta.current_page) + " of " + i(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)
136
154
  ])
137
155
  ]));
138
156
  }
139
- }), le = { class: "flex flex-col gap-4" }, ie = { class: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" }, de = { class: "flex flex-col gap-2 sm:flex-row sm:items-center" }, ce = {
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 = {
140
158
  key: 0,
141
159
  class: "relative w-full max-w-sm"
142
- }, ge = ["value"], ue = { class: "flex items-center gap-2" }, me = { class: "flex items-center" }, fe = {
160
+ }, be = ["value"], he = { class: "flex items-center gap-2" }, pe = { class: "flex items-center" }, xe = {
143
161
  key: 0,
144
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"
145
- }, be = { class: "flex items-center gap-4" }, ye = { class: "text-sm font-medium text-blue-700 dark:text-blue-300" }, xe = { class: "text-xs text-blue-600 dark:text-blue-400" }, he = { class: "flex items-center gap-2" }, pe = {
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 = {
146
164
  key: 1,
147
165
  class: "flex items-center justify-center p-8"
148
- }, ve = { class: "text-lg text-gray-700 dark:text-gray-200" }, we = {
166
+ }, Se = { class: "text-lg text-gray-700 dark:text-gray-200" }, Pe = {
149
167
  key: 2,
150
168
  class: "flex flex-col items-center p-8"
151
- }, ke = { class: "mb-2 text-lg text-red-600 dark:text-red-400" }, Ce = { class: "mb-4 text-sm text-gray-600 dark:text-gray-300" }, Se = {
169
+ }, Re = { class: "mb-2 text-lg text-red-600 dark:text-red-400" }, $e = { class: "mb-4 text-sm text-gray-600 dark:text-gray-300" }, De = {
152
170
  key: 3,
153
- class: "rounded-lg border bg-white dark:bg-gray-900"
154
- }, Pe = {
171
+ class: "rounded-lg border bg-background dark:border-gray-700"
172
+ }, Te = {
155
173
  key: 0,
156
174
  class: "relative"
157
- }, Re = { class: "relative w-full overflow-auto" }, $e = { class: "w-full caption-bottom text-sm" }, Te = {
175
+ }, je = { class: "relative w-full overflow-auto" }, Be = { class: "w-full caption-bottom text-sm" }, Ne = {
158
176
  key: 0,
159
- class: "mt-4 text-sm text-muted-foreground"
160
- }, De = {
177
+ class: "mt-4 text-sm text-muted-foreground dark:text-gray-400"
178
+ }, Le = {
161
179
  key: 0,
162
180
  class: "ml-2 text-blue-600 dark:text-blue-400"
163
- }, je = { class: "[&_tr]:border-b" }, Ne = ["colspan"], Be = ["onClick"], Ie = {
164
- key: 0,
165
- class: "flex flex-col"
166
- }, Le = { class: "[&_tr:last-child]:border-0" }, Me = { key: 1 }, Oe = ["colspan"], _e = /* @__PURE__ */ L({
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({
167
185
  __name: "DataTable",
168
186
  props: {
169
187
  data: { default: () => [] },
@@ -189,19 +207,23 @@ const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
189
207
  emptyStateText: { default: "📭 No items found" }
190
208
  },
191
209
  emits: ["pageChange", "perPageChange", "searchChange", "sortChange", "retry", "update:rowSelection"],
192
- setup(e, { expose: T, emit: c }) {
193
- const g = c, l = e, m = P(() => Object.keys(l.rowSelection || {}).filter((o) => {
194
- var r;
195
- return (r = l.rowSelection) == null ? void 0 : r[o];
196
- }).length), C = P(() => Object.keys(l.rowSelection || {}).filter((o) => {
197
- var r;
198
- return (r = l.rowSelection) == null ? void 0 : r[o];
199
- })), R = P(() => !l.data || !l.rowSelection ? [] : l.data.filter((o) => l.rowSelection[l.getRowId(o)])), v = M({
210
+ setup(e, { expose: R, emit: i }) {
211
+ const c = i, l = e, m = P(() => Object.keys(l.rowSelection || {}).filter(
212
+ (n) => {
213
+ var s;
214
+ return (s = l.rowSelection) == null ? void 0 : s[n];
215
+ }
216
+ ).length), w = P(() => Object.keys(l.rowSelection || {}).filter(
217
+ (n) => {
218
+ var s;
219
+ return (s = l.rowSelection) == null ? void 0 : s[n];
220
+ }
221
+ )), $ = P(() => !l.data || !l.rowSelection ? [] : l.data.filter((n) => l.rowSelection[l.getRowId(n)])), x = V({
200
222
  get data() {
201
223
  return l.data || [];
202
224
  },
203
225
  columns: l.columns,
204
- getCoreRowModel: O(),
226
+ getCoreRowModel: z(),
205
227
  enableSorting: !0,
206
228
  manualSorting: !0,
207
229
  enableRowSelection: l.enableRowSelection,
@@ -209,182 +231,193 @@ const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
209
231
  state: {
210
232
  rowSelection: l.rowSelection || {}
211
233
  },
212
- onRowSelectionChange: (o) => {
213
- const r = typeof o == "function" ? o(l.rowSelection || {}) : o;
214
- g("update:rowSelection", r);
234
+ onRowSelectionChange: (n) => {
235
+ const s = typeof n == "function" ? n(l.rowSelection || {}) : n;
236
+ c("update:rowSelection", s);
215
237
  },
216
238
  enableMultiRowSelection: !0,
217
239
  enableSubRowSelection: !1
218
- }), D = () => C.value, j = () => R.value, $ = () => g("update:rowSelection", {}), y = () => {
219
- const o = { ...l.rowSelection };
220
- v.getRowModel().rows.forEach((r) => {
221
- o[r.id] = !0;
222
- }), g("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);
223
245
  }, d = () => {
224
- const o = { ...l.rowSelection };
225
- v.getRowModel().rows.forEach((r) => {
226
- delete o[r.id];
227
- }), g("update:rowSelection", o);
246
+ const n = { ...l.rowSelection };
247
+ x.getRowModel().rows.forEach((s) => {
248
+ delete n[s.id];
249
+ }), c("update:rowSelection", n);
228
250
  };
229
- return T({
230
- getSelectedRowIds: D,
251
+ return R({
252
+ getSelectedRowIds: T,
231
253
  getSelectedRowData: j,
232
- clearSelection: $,
233
- selectAllCurrentPage: y,
254
+ clearSelection: D,
255
+ selectAllCurrentPage: h,
234
256
  deselectAllCurrentPage: d,
235
257
  selectedRowCount: m,
236
- selectedRowIds: C,
237
- selectedRowData: R,
238
- table: v
239
- }), (o, r) => {
240
- var w, k;
241
- return n(), a("div", le, [
242
- t("div", ie, [
243
- t("div", de, [
244
- e.showSearch ? (n(), a("div", ce, [
258
+ selectedRowIds: w,
259
+ selectedRowData: $,
260
+ table: x
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, [
245
267
  t("input", {
246
268
  value: e.search,
247
269
  type: "search",
248
270
  placeholder: "Search...",
249
- 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",
250
- onInput: r[0] || (r[0] = (s) => g("searchChange", s.target.value))
251
- }, null, 40, ge)
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",
272
+ onInput: s[0] || (s[0] = (r) => c("searchChange", r.target.value))
273
+ }, null, 40, be)
252
274
  ])) : f("", !0),
253
- t("div", ue, [
254
- N(o.$slots, "filters")
275
+ t("div", he, [
276
+ B(n.$slots, "filters")
255
277
  ])
256
278
  ]),
257
- t("div", me, [
258
- N(o.$slots, "header")
279
+ t("div", pe, [
280
+ B(n.$slots, "header")
259
281
  ])
260
282
  ]),
261
- e.enableRowSelection && m.value > 0 ? (n(), a("div", fe, [
262
- t("div", be, [
263
- t("span", ye, i(m.value) + " " + i(e.itemName) + " selected ", 1),
264
- t("div", xe, " IDs: " + i(C.value.slice(0, 5).join(", ")) + i(C.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)
265
287
  ]),
266
- t("div", he, [
267
- N(o.$slots, "bulk-actions", {
268
- selectedIds: C.value,
269
- selectedData: R.value,
288
+ t("div", ke, [
289
+ B(n.$slots, "bulk-actions", {
290
+ selectedIds: w.value,
291
+ selectedData: $.value,
270
292
  selectedCount: m.value,
271
- clearSelection: $,
272
- selectAllCurrentPage: y,
293
+ clearSelection: D,
294
+ selectAllCurrentPage: h,
273
295
  deselectAllCurrentPage: d
274
296
  }),
275
- o.$slots["bulk-actions"] ? f("", !0) : (n(), a("button", {
297
+ n.$slots["bulk-actions"] ? f("", !0) : (o(), a("button", {
276
298
  key: 0,
277
- onClick: $,
299
+ onClick: D,
278
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"
279
301
  }, " Clear Selection "))
280
302
  ])
281
303
  ])) : f("", !0),
282
- e.isLoading && !e.data ? (n(), a("div", pe, [
283
- r[4] || (r[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)),
284
- t("div", ve, i(e.loadingText), 1)
285
- ])) : e.error ? (n(), a("div", we, [
286
- t("div", ke, "❌ " + i(e.errorTitle), 1),
287
- t("div", Ce, i(e.error.message), 1),
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),
288
310
  t("button", {
289
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",
290
- onClick: r[1] || (r[1] = (s) => g("retry"))
312
+ onClick: s[1] || (s[1] = (r) => c("retry"))
291
313
  }, " 🔄 Retry ")
292
- ])) : (n(), a("div", Se, [
293
- e.isLoading ? (n(), a("div", Pe, [...r[5] || (r[5] = [
314
+ ])) : (o(), a("div", De, [
315
+ e.isLoading ? (o(), a("div", Te, [...s[5] || (s[5] = [
294
316
  t("div", { class: "absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg" }, [
295
317
  t("div", { class: "w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" })
296
318
  ], -1)
297
319
  ])])) : f("", !0),
298
- t("div", Re, [
299
- t("table", $e, [
300
- e.showCaption ? (n(), a("caption", Te, [
301
- B(i(e.title) + " - Total: " + i(((k = (w = e.pagination) == null ? void 0 : w.meta) == null ? void 0 : k.total) || 0) + " " + i(e.itemName) + " ", 1),
302
- e.enableRowSelection && m.value > 0 ? (n(), a("span", De, " (" + i(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)
303
325
  ])) : f("", !0),
304
- t("thead", je, [
305
- (n(!0), a(p, null, S(b(v).getHeaderGroups(), (s) => (n(), a("tr", {
306
- key: s.id,
307
- class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
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"
308
330
  }, [
309
- (n(!0), a(p, null, S(s.headers, (u) => (n(), a("th", {
310
- key: u.id,
311
- colspan: u.colSpan,
312
- class: "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0"
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"
313
335
  }, [
314
- u.isPlaceholder ? f("", !0) : (n(), a("div", {
336
+ g.isPlaceholder ? f("", !0) : (o(), a("div", {
315
337
  key: 0,
316
- class: x([
338
+ class: k([
317
339
  "flex items-center gap-2",
318
- 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" : ""
319
341
  ]),
320
- onClick: (Ve) => u.column.getCanSort() ? g("sortChange", u.column.id) : void 0
342
+ onClick: (Ge) => g.column.getCanSort() ? c("sortChange", g.column.id) : void 0
321
343
  }, [
322
- h(b(I), {
323
- render: u.column.columnDef.header,
324
- props: u.getContext()
344
+ C(b(M), {
345
+ render: g.column.columnDef.header,
346
+ props: g.getContext()
325
347
  }, null, 8, ["render", "props"]),
326
- u.column.getCanSort() ? (n(), a("div", Ie, [
327
- h(b(A), {
328
- class: x([
329
- "w-3 h-3 transition-colors",
330
- e.sortBy === u.column.id && e.sortDirection === "asc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
331
- ])
332
- }, null, 8, ["class"]),
333
- h(b(G), {
334
- class: x([
335
- "w-3 h-3 -mt-1 transition-colors",
336
- e.sortBy === u.column.id && e.sortDirection === "desc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
337
- ])
338
- }, null, 8, ["class"])
348
+ g.column.getCanSort() ? (o(), a("div", Oe, [
349
+ e.sortBy !== g.column.id ? (o(), N(b(U), {
350
+ key: 0,
351
+ size: 10,
352
+ class: "text-gray-400"
353
+ })) : e.sortBy === g.column.id && e.sortDirection === "asc" ? (o(), N(b(H), {
354
+ key: 1,
355
+ size: 10,
356
+ class: "text-gray-900 dark:text-gray-100"
357
+ })) : e.sortBy === g.column.id && e.sortDirection === "desc" ? (o(), N(b(Q), {
358
+ key: 2,
359
+ size: 10,
360
+ class: "text-gray-900 dark:text-gray-100"
361
+ })) : f("", !0)
339
362
  ])) : f("", !0)
340
- ], 10, Be))
341
- ], 8, Ne))), 128))
363
+ ], 10, Ee))
364
+ ], 8, Ie))), 128))
342
365
  ]))), 128))
343
366
  ]),
344
- t("tbody", Le, [
345
- b(v).getRowModel().rows.length > 0 ? (n(!0), a(p, { key: 0 }, S(b(v).getRowModel().rows, (s) => (n(), a("tr", {
346
- key: s.id,
347
- class: x([
348
- "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
349
- e.enableRowSelection && s.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
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([
371
+ "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:border-gray-700 dark:hover:bg-gray-800",
372
+ e.enableRowSelection && r.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
350
373
  ])
351
374
  }, [
352
- (n(!0), a(p, null, S(s.getVisibleCells(), (u) => (n(), a("td", {
353
- key: u.id,
375
+ (o(!0), a(p, null, S(r.getVisibleCells(), (g) => (o(), a("td", {
376
+ key: g.id,
354
377
  class: "p-4 align-middle [&:has([role=checkbox])]:pr-0"
355
378
  }, [
356
- h(b(I), {
357
- render: u.column.columnDef.cell,
358
- props: u.getContext()
379
+ C(b(M), {
380
+ render: g.column.columnDef.cell,
381
+ props: g.getContext()
359
382
  }, null, 8, ["render", "props"])
360
383
  ]))), 128))
361
- ], 2))), 128)) : (n(), a("tr", Me, [
384
+ ], 2))), 128)) : (o(), a("tr", ze, [
362
385
  t("td", {
363
386
  colspan: e.columns.length,
364
- class: "h-24 text-center"
365
- }, i(e.emptyStateText), 9, Oe)
387
+ class: "h-24 text-center dark:text-gray-400"
388
+ }, u(e.emptyStateText), 9, Fe)
366
389
  ]))
367
- ])
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)
368
408
  ])
369
- ]),
370
- h(se, {
371
- pagination: e.pagination,
372
- "current-per-page": e.currentPerPage,
373
- "per-page-options": e.perPageOptions,
374
- "show-per-page-selector": e.showPerPageSelector,
375
- onPageChange: r[2] || (r[2] = (s) => g("pageChange", s)),
376
- onPerPageChange: r[3] || (r[3] = (s) => g("perPageChange", s))
377
- }, null, 8, ["pagination", "current-per-page", "per-page-options", "show-per-page-selector"])
409
+ ])
378
410
  ]))
379
411
  ]);
380
412
  };
381
413
  }
382
414
  });
383
- function He(...e) {
384
- return H(_(e));
415
+ function Xe(...e) {
416
+ return q(W(e));
385
417
  }
386
418
  export {
387
- _e as DataTable,
388
- se as DataTablePagination,
389
- He as cn
419
+ Ke as DataTable,
420
+ de as DataTablePagination,
421
+ Xe as cn,
422
+ Je as useDarkMode
390
423
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toniel/laravel-tanstack-datatable",
3
- "version": "0.1.4",
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",