@toniel/laravel-tanstack-datatable 0.1.3 → 0.1.5

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;WA0UT,OAAO,IAA6B;;yBAZrB,GAAG;wBACJ,GAAG;;;;;;;;YACK,GAAG;;;;EAetC;AAuBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;gBA9gBN,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;wFAggBvB,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":"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"}
@@ -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"),B=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"},z={key:0,class:"flex items-center gap-2"},I=["value"],M=["value"],O={key:1},S=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",z,[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,I)])):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"},_={class:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"},A={class:"flex flex-col gap-2 sm:flex-row sm:items-center"},G={key:0,class:"relative w-full max-w-sm"},H={class:"pointer-events-none absolute inset-y-0 start-0 flex items-center ps-3"},U=["value"],W={class:"flex items-center gap-2"},J={class:"flex items-center"},K={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"},Q={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-white dark:bg-gray-900"},re={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"},de={key:0,class:"ml-2 text-blue-600 dark:text-blue-400"},ge={class:"[&_tr]:border-b"},ue=["colspan"],me=["onClick"],pe={key:0,class:"flex flex-col"},fe={class:"[&_tr:last-child]:border-0"},ye={key:1},ke=["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: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",_,[e.createElementVNode("div",A,[t.showSearch?(e.openBlock(),e.createElementBlock("div",G,[e.createElementVNode("div",H,[e.createVNode(e.unref(y.Search),{class:"size-5 text-muted-foreground"})]),e.createElementVNode("input",{value:t.search,type:"text",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,U)])):e.createCommentVNode("",!0),e.createElementVNode("div",W,[e.renderSlot(o.$slots,"filters")])]),e.createElementVNode("div",J,[e.renderSlot(o.$slots,"header")])]),t.enableRowSelection&&d.value>0?(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("div",Q,[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: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",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=>i("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",ie,[t.showCaption?(e.openBlock(),e.createElementBlock("caption",ce,[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",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"},[(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:he=>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",pe,[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,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",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",ye,[e.createElementVNode("td",{colspan:t.columns.length,class:"h-24 text-center"},e.toDisplayString(t.emptyStateText),9,ke)]))])])]),e.createVNode(S,{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 xe(...t){return C.twMerge(B.clsx(t))}exports.DataTable=be;exports.DataTablePagination=S;exports.cn=xe;
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;
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 b, createElementVNode as t, normalizeClass as h, createVNode as y, unref as f, 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 _, Search as z, ChevronUp as A, ChevronDown as G } from "lucide-vue-next";
4
- import { clsx as H } from "clsx";
5
- import { twMerge as U } from "tailwind-merge";
6
- const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
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";
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";
4
+ import { clsx as W } from "clsx";
5
+ import { twMerge as q } from "tailwind-merge";
6
+ function We() {
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 gap-4 px-2 py-4 bg-background text-foreground" }, K = {
7
26
  key: 0,
8
27
  class: "flex justify-center"
9
- }, J = {
28
+ }, X = {
10
29
  class: "flex items-center gap-1",
11
30
  role: "navigation",
12
31
  "aria-label": "pagination"
13
- }, K = ["disabled"], Q = ["disabled"], X = { class: "flex items-center gap-1" }, Y = ["onClick"], Z = {
32
+ }, Y = ["disabled"], Z = ["disabled"], ee = { class: "flex items-center gap-1" }, te = ["onClick"], ae = {
14
33
  key: 1,
15
34
  class: "inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"
16
- }, ee = ["disabled"], te = ["disabled"], oe = { class: "flex items-center justify-between text-sm text-gray-600 dark:text-gray-300" }, ae = {
35
+ }, oe = ["disabled"], ne = ["disabled"], re = { class: "flex items-center justify-between text-sm text-gray-600 dark:text-gray-300" }, se = {
17
36
  key: 0,
18
37
  class: "flex items-center gap-2"
19
- }, ne = ["value"], re = ["value"], se = { key: 1 }, le = /* @__PURE__ */ L({
38
+ }, le = ["value"], ie = ["value"], de = { key: 1 }, ce = /* @__PURE__ */ I({
20
39
  __name: "DataTablePagination",
21
40
  props: {
22
41
  pagination: { default: null },
@@ -25,145 +44,142 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
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 x = 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 >= x - o && s <= x + o) && r.push(s);
51
+ () => i.pagination ? i.pagination.meta.current_page < i.pagination.meta.last_page : !1
52
+ ), k = P(() => {
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);
39
58
  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 = (x) => {
43
- typeof x == "number" && g("pageChange", x);
44
- }, v = () => {
45
- l.value && g("pageChange", 1);
46
- }, D = () => {
47
- m.value && c.pagination && g("pageChange", c.pagination.meta.last_page);
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);
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 (x, d) => (n(), a("div", W, [
54
- e.pagination && e.pagination.meta.last_page > 1 ? (n(), a("div", q, [
55
- t("nav", J, [
56
- t("button", {
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", {
57
76
  disabled: !l.value,
58
- class: h([
77
+ class: w([
59
78
  "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
60
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"
61
80
  ]),
62
- onClick: v
81
+ onClick: x
63
82
  }, [
64
- y(f(V), { class: "h-4 w-4" }),
65
- d[1] || (d[1] = t("span", { class: "hidden sm:inline" }, "First", -1))
66
- ], 10, K),
67
- t("button", {
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", {
68
87
  disabled: !l.value,
69
- class: h([
88
+ class: w([
70
89
  "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
71
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"
72
91
  ]),
73
92
  onClick: j
74
93
  }, [
75
- y(f(E), { class: "h-4 w-4" }),
76
- d[2] || (d[2] = t("span", { class: "hidden sm:inline" }, "Previous", -1))
77
- ], 10, Q),
78
- t("div", X, [
79
- (n(!0), a(p, null, S(C.value, (o, r) => (n(), a(p, { key: r }, [
80
- o !== "..." ? (n(), a("button", {
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", {
81
100
  key: 0,
82
- class: h([
101
+ class: w([
83
102
  "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"
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"
85
104
  ]),
86
- onClick: (w) => R(o)
87
- }, i(o), 11, Y)) : (n(), a("span", Z, " ... "))
105
+ onClick: (p) => $(o)
106
+ }, d(o), 11, te)) : (t(), n("span", ae, " ... "))
88
107
  ], 64))), 128))
89
108
  ]),
90
- t("button", {
109
+ a("button", {
91
110
  disabled: !m.value,
92
- class: h([
111
+ class: w([
93
112
  "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
94
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"
95
114
  ]),
96
- onClick: $
115
+ onClick: D
97
116
  }, [
98
- d[3] || (d[3] = t("span", { class: "hidden sm:inline" }, "Next", -1)),
99
- y(f(F), { class: "h-4 w-4" })
100
- ], 10, ee),
101
- t("button", {
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", {
102
121
  disabled: !m.value,
103
- class: h([
122
+ class: w([
104
123
  "inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
105
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"
106
125
  ]),
107
- onClick: D
126
+ onClick: T
108
127
  }, [
109
- d[4] || (d[4] = t("span", { class: "hidden sm:inline" }, "Last", -1)),
110
- y(f(_), { class: "h-4 w-4" })
111
- ], 10, te)
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)
112
131
  ])
113
- ])) : b("", !0),
114
- t("div", oe, [
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 ")
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 ")
120
139
  ], 64))
121
140
  ]),
122
- e.showPerPageSelector ? (n(), a("div", ae, [
123
- d[5] || (d[5] = t("span", null, "Rows per page:", -1)),
124
- t("select", {
141
+ e.showPerPageSelector ? (t(), n("div", se, [
142
+ g[5] || (g[5] = a("span", null, "Rows per page:", -1)),
143
+ a("select", {
125
144
  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]))
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]))
128
147
  }, [
129
- (n(!0), a(p, null, S(e.perPageOptions, (o) => (n(), a("option", {
148
+ (t(!0), n(h, null, S(e.perPageOptions, (o) => (t(), n("option", {
130
149
  key: o,
131
150
  value: o
132
- }, i(o), 9, re))), 128))
133
- ], 40, ne)
134
- ])) : b("", !0),
135
- e.pagination ? (n(), a("div", se, " Page " + i(e.pagination.meta.current_page) + " of " + i(e.pagination.meta.last_page), 1)) : b("", !0)
151
+ }, d(o), 9, ie))), 128))
152
+ ], 40, le)
153
+ ])) : 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)
136
155
  ])
137
156
  ]));
138
157
  }
139
- }), ie = { class: "flex flex-col gap-4" }, de = { class: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" }, ce = { class: "flex flex-col gap-2 sm:flex-row sm:items-center" }, ge = {
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 = {
140
159
  key: 0,
141
160
  class: "relative w-full max-w-sm"
142
- }, ue = { class: "pointer-events-none absolute inset-y-0 start-0 flex items-center ps-3" }, me = ["value"], fe = { class: "flex items-center gap-2" }, be = { class: "flex items-center" }, ye = {
161
+ }, be = ["value"], ye = { class: "flex items-center gap-2" }, he = { class: "flex items-center" }, xe = {
143
162
  key: 0,
144
163
  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
- }, xe = { class: "flex items-center gap-4" }, he = { class: "text-sm font-medium text-blue-700 dark:text-blue-300" }, pe = { class: "text-xs text-blue-600 dark:text-blue-400" }, ve = { class: "flex items-center gap-2" }, we = {
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 = {
146
165
  key: 1,
147
166
  class: "flex items-center justify-center p-8"
148
- }, ke = { class: "text-lg text-gray-700 dark:text-gray-200" }, Ce = {
167
+ }, Se = { class: "text-lg text-gray-700 dark:text-gray-200" }, Pe = {
149
168
  key: 2,
150
169
  class: "flex flex-col items-center p-8"
151
- }, Se = { class: "mb-2 text-lg text-red-600 dark:text-red-400" }, Pe = { class: "mb-4 text-sm text-gray-600 dark:text-gray-300" }, Re = {
170
+ }, 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
171
  key: 3,
153
- class: "rounded-lg border bg-white dark:bg-gray-900"
154
- }, $e = {
172
+ class: "rounded-lg border bg-background dark:border-gray-700"
173
+ }, Te = {
155
174
  key: 0,
156
175
  class: "relative"
157
- }, Te = { class: "relative w-full overflow-auto" }, De = { class: "w-full caption-bottom text-sm" }, je = {
176
+ }, je = { class: "relative w-full overflow-auto" }, Be = { class: "w-full caption-bottom text-sm" }, Ne = {
158
177
  key: 0,
159
- class: "mt-4 text-sm text-muted-foreground"
160
- }, Ne = {
178
+ class: "mt-4 text-sm text-muted-foreground dark:text-gray-400"
179
+ }, Le = {
161
180
  key: 0,
162
181
  class: "ml-2 text-blue-600 dark:text-blue-400"
163
- }, Be = { class: "[&_tr]:border-b" }, Ie = ["colspan"], Le = ["onClick"], Me = {
164
- key: 0,
165
- class: "flex flex-col"
166
- }, Oe = { class: "[&_tr:last-child]:border-0" }, Ve = { key: 1 }, Ee = ["colspan"], Ue = /* @__PURE__ */ L({
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({
167
183
  __name: "DataTable",
168
184
  props: {
169
185
  data: { default: () => [] },
@@ -189,19 +205,23 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
189
205
  emptyStateText: { default: "📭 No items found" }
190
206
  },
191
207
  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({
208
+ setup(e, { expose: R, emit: i }) {
209
+ 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];
213
+ }
214
+ ).length), k = P(() => Object.keys(l.rowSelection || {}).filter(
215
+ (o) => {
216
+ var r;
217
+ return (r = l.rowSelection) == null ? void 0 : r[o];
218
+ }
219
+ )), $ = P(() => !l.data || !l.rowSelection ? [] : l.data.filter((o) => l.rowSelection[l.getRowId(o)])), x = V({
200
220
  get data() {
201
221
  return l.data || [];
202
222
  },
203
223
  columns: l.columns,
204
- getCoreRowModel: O(),
224
+ getCoreRowModel: z(),
205
225
  enableSorting: !0,
206
226
  manualSorting: !0,
207
227
  enableRowSelection: l.enableRowSelection,
@@ -211,183 +231,182 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
211
231
  },
212
232
  onRowSelectionChange: (o) => {
213
233
  const r = typeof o == "function" ? o(l.rowSelection || {}) : o;
214
- g("update:rowSelection", r);
234
+ c("update:rowSelection", r);
215
235
  },
216
236
  enableMultiRowSelection: !0,
217
237
  enableSubRowSelection: !1
218
- }), D = () => C.value, j = () => R.value, $ = () => g("update:rowSelection", {}), x = () => {
238
+ }), T = () => k.value, j = () => $.value, D = () => c("update:rowSelection", {}), y = () => {
219
239
  const o = { ...l.rowSelection };
220
- v.getRowModel().rows.forEach((r) => {
240
+ x.getRowModel().rows.forEach((r) => {
221
241
  o[r.id] = !0;
222
- }), g("update:rowSelection", o);
223
- }, d = () => {
242
+ }), c("update:rowSelection", o);
243
+ }, g = () => {
224
244
  const o = { ...l.rowSelection };
225
- v.getRowModel().rows.forEach((r) => {
245
+ x.getRowModel().rows.forEach((r) => {
226
246
  delete o[r.id];
227
- }), g("update:rowSelection", o);
247
+ }), c("update:rowSelection", o);
228
248
  };
229
- return T({
230
- getSelectedRowIds: D,
249
+ return R({
250
+ getSelectedRowIds: T,
231
251
  getSelectedRowData: j,
232
- clearSelection: $,
233
- selectAllCurrentPage: x,
234
- deselectAllCurrentPage: d,
252
+ clearSelection: D,
253
+ selectAllCurrentPage: y,
254
+ deselectAllCurrentPage: g,
235
255
  selectedRowCount: m,
236
- selectedRowIds: C,
237
- selectedRowData: R,
238
- table: v
256
+ selectedRowIds: k,
257
+ selectedRowData: $,
258
+ table: x
239
259
  }), (o, r) => {
240
- var w, k;
241
- return n(), a("div", ie, [
242
- t("div", de, [
243
- t("div", ce, [
244
- e.showSearch ? (n(), a("div", ge, [
245
- t("div", ue, [
246
- y(f(z), { class: "size-5 text-muted-foreground" })
247
- ]),
248
- t("input", {
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", {
249
266
  value: e.search,
250
- type: "text",
267
+ type: "search",
251
268
  placeholder: "Search...",
252
- 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",
253
- onInput: r[0] || (r[0] = (s) => g("searchChange", s.target.value))
254
- }, null, 40, me)
255
- ])) : b("", !0),
256
- t("div", fe, [
257
- N(o.$slots, "filters")
269
+ 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))
271
+ }, null, 40, be)
272
+ ])) : f("", !0),
273
+ a("div", ye, [
274
+ B(o.$slots, "filters")
258
275
  ])
259
276
  ]),
260
- t("div", be, [
261
- N(o.$slots, "header")
277
+ a("div", he, [
278
+ B(o.$slots, "header")
262
279
  ])
263
280
  ]),
264
- e.enableRowSelection && m.value > 0 ? (n(), a("div", ye, [
265
- t("div", xe, [
266
- t("span", he, i(m.value) + " " + i(e.itemName) + " selected ", 1),
267
- t("div", pe, " IDs: " + i(C.value.slice(0, 5).join(", ")) + i(C.value.length > 5 ? "..." : ""), 1)
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)
268
285
  ]),
269
- t("div", ve, [
270
- N(o.$slots, "bulk-actions", {
271
- selectedIds: C.value,
272
- selectedData: R.value,
286
+ a("div", we, [
287
+ B(o.$slots, "bulk-actions", {
288
+ selectedIds: k.value,
289
+ selectedData: $.value,
273
290
  selectedCount: m.value,
274
- clearSelection: $,
275
- selectAllCurrentPage: x,
276
- deselectAllCurrentPage: d
291
+ clearSelection: D,
292
+ selectAllCurrentPage: y,
293
+ deselectAllCurrentPage: g
277
294
  }),
278
- o.$slots["bulk-actions"] ? b("", !0) : (n(), a("button", {
295
+ o.$slots["bulk-actions"] ? f("", !0) : (t(), n("button", {
279
296
  key: 0,
280
- onClick: $,
297
+ onClick: D,
281
298
  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"
282
299
  }, " Clear Selection "))
283
300
  ])
284
- ])) : b("", !0),
285
- e.isLoading && !e.data ? (n(), a("div", we, [
286
- 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)),
287
- t("div", ke, i(e.loadingText), 1)
288
- ])) : e.error ? (n(), a("div", Ce, [
289
- t("div", Se, "❌ " + i(e.errorTitle), 1),
290
- t("div", Pe, i(e.error.message), 1),
291
- t("button", {
301
+ ])) : 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", {
292
309
  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",
293
- onClick: r[1] || (r[1] = (s) => g("retry"))
310
+ onClick: r[1] || (r[1] = (s) => c("retry"))
294
311
  }, " 🔄 Retry ")
295
- ])) : (n(), a("div", Re, [
296
- e.isLoading ? (n(), a("div", $e, [...r[5] || (r[5] = [
297
- t("div", { class: "absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg" }, [
298
- t("div", { class: "w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" })
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" })
299
316
  ], -1)
300
- ])])) : b("", !0),
301
- t("div", Te, [
302
- t("table", De, [
303
- e.showCaption ? (n(), a("caption", je, [
304
- 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),
305
- e.enableRowSelection && m.value > 0 ? (n(), a("span", Ne, " (" + i(m.value) + " selected) ", 1)) : b("", !0)
306
- ])) : b("", !0),
307
- t("thead", Be, [
308
- (n(!0), a(p, null, S(f(v).getHeaderGroups(), (s) => (n(), a("tr", {
317
+ ])])) : 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)
323
+ ])) : f("", !0),
324
+ a("thead", Me, [
325
+ (t(!0), n(h, null, S(b(x).getHeaderGroups(), (s) => (t(), n("tr", {
309
326
  key: s.id,
310
- class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
327
+ class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:hover:bg-gray-800"
311
328
  }, [
312
- (n(!0), a(p, null, S(s.headers, (u) => (n(), a("th", {
329
+ (t(!0), n(h, null, S(s.headers, (u) => (t(), n("th", {
313
330
  key: u.id,
314
331
  colspan: u.colSpan,
315
- class: "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0"
332
+ class: "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 dark:text-gray-400"
316
333
  }, [
317
- u.isPlaceholder ? b("", !0) : (n(), a("div", {
334
+ u.isPlaceholder ? f("", !0) : (t(), n("div", {
318
335
  key: 0,
319
- class: h([
336
+ class: w([
320
337
  "flex items-center gap-2",
321
338
  u.column.getCanSort() ? "cursor-pointer select-none hover:bg-gray-50 dark:hover:bg-gray-800 p-2 rounded transition-colors" : ""
322
339
  ]),
323
- onClick: (Fe) => u.column.getCanSort() ? g("sortChange", u.column.id) : void 0
340
+ onClick: (Ae) => u.column.getCanSort() ? c("sortChange", u.column.id) : void 0
324
341
  }, [
325
- y(f(I), {
342
+ C(b(M), {
326
343
  render: u.column.columnDef.header,
327
344
  props: u.getContext()
328
345
  }, null, 8, ["render", "props"]),
329
- u.column.getCanSort() ? (n(), a("div", Me, [
330
- y(f(A), {
331
- class: h([
332
- "w-3 h-3 transition-colors",
333
- e.sortBy === u.column.id && e.sortDirection === "asc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
334
- ])
335
- }, null, 8, ["class"]),
336
- y(f(G), {
337
- class: h([
338
- "w-3 h-3 -mt-1 transition-colors",
339
- e.sortBy === u.column.id && e.sortDirection === "desc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
340
- ])
341
- }, null, 8, ["class"])
342
- ])) : b("", !0)
343
- ], 10, Le))
346
+ u.column.getCanSort() ? (t(), n("div", Oe, [
347
+ e.sortBy !== u.column.id ? (t(), N(b(_), {
348
+ key: 0,
349
+ size: 10,
350
+ class: "text-gray-400"
351
+ })) : e.sortBy === u.column.id && e.sortDirection === "asc" ? (t(), N(b(H), {
352
+ key: 1,
353
+ size: 10,
354
+ class: "text-gray-900 dark:text-gray-100"
355
+ })) : e.sortBy === u.column.id && e.sortDirection === "desc" ? (t(), N(b(Q), {
356
+ key: 2,
357
+ size: 10,
358
+ class: "text-gray-900 dark:text-gray-100"
359
+ })) : f("", !0)
360
+ ])) : f("", !0)
361
+ ], 10, Ee))
344
362
  ], 8, Ie))), 128))
345
363
  ]))), 128))
346
364
  ]),
347
- t("tbody", Oe, [
348
- f(v).getRowModel().rows.length > 0 ? (n(!0), a(p, { key: 0 }, S(f(v).getRowModel().rows, (s) => (n(), a("tr", {
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", {
349
367
  key: s.id,
350
- class: h([
351
- "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
368
+ class: w([
369
+ "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted dark:border-gray-700 dark:hover:bg-gray-800",
352
370
  e.enableRowSelection && s.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
353
371
  ])
354
372
  }, [
355
- (n(!0), a(p, null, S(s.getVisibleCells(), (u) => (n(), a("td", {
373
+ (t(!0), n(h, null, S(s.getVisibleCells(), (u) => (t(), n("td", {
356
374
  key: u.id,
357
375
  class: "p-4 align-middle [&:has([role=checkbox])]:pr-0"
358
376
  }, [
359
- y(f(I), {
377
+ C(b(M), {
360
378
  render: u.column.columnDef.cell,
361
379
  props: u.getContext()
362
380
  }, null, 8, ["render", "props"])
363
381
  ]))), 128))
364
- ], 2))), 128)) : (n(), a("tr", Ve, [
365
- t("td", {
382
+ ], 2))), 128)) : (t(), n("tr", ze, [
383
+ a("td", {
366
384
  colspan: e.columns.length,
367
- class: "h-24 text-center"
368
- }, i(e.emptyStateText), 9, Ee)
385
+ class: "h-24 text-center dark:text-gray-400"
386
+ }, d(e.emptyStateText), 9, Fe)
369
387
  ]))
370
388
  ])
371
389
  ])
372
390
  ]),
373
- y(le, {
391
+ C(ce, {
374
392
  pagination: e.pagination,
375
393
  "current-per-page": e.currentPerPage,
376
394
  "per-page-options": e.perPageOptions,
377
395
  "show-per-page-selector": e.showPerPageSelector,
378
- onPageChange: r[2] || (r[2] = (s) => g("pageChange", s)),
379
- onPerPageChange: r[3] || (r[3] = (s) => g("perPageChange", s))
396
+ onPageChange: r[2] || (r[2] = (s) => c("pageChange", s)),
397
+ onPerPageChange: r[3] || (r[3] = (s) => c("perPageChange", s))
380
398
  }, null, 8, ["pagination", "current-per-page", "per-page-options", "show-per-page-selector"])
381
399
  ]))
382
400
  ]);
383
401
  };
384
402
  }
385
403
  });
386
- function We(...e) {
387
- return U(H(e));
404
+ function Je(...e) {
405
+ return q(W(e));
388
406
  }
389
407
  export {
390
- Ue as DataTable,
391
- le as DataTablePagination,
392
- We as cn
408
+ qe as DataTable,
409
+ ce as DataTablePagination,
410
+ Je as cn,
411
+ We as useDarkMode
393
412
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toniel/laravel-tanstack-datatable",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",