@toniel/laravel-tanstack-datatable 0.1.4 → 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.
- package/dist/components/DataTable.vue.d.ts +1 -1
- package/dist/components/DataTable.vue.d.ts.map +1 -1
- package/dist/composables/useDarkMode.d.ts +5 -0
- package/dist/composables/useDarkMode.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +222 -200
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
currentPerPage?: number;
|
|
11
11
|
perPageOptions?: number[];
|
|
12
12
|
sortBy?: string | null;
|
|
13
|
-
sortDirection?:
|
|
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":"
|
|
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 @@
|
|
|
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
package/dist/index.d.ts.map
CHANGED
|
@@ -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"),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
|
|
2
|
-
import { useVueTable as
|
|
3
|
-
import { ChevronsLeft as
|
|
4
|
-
import { clsx as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
|
|
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
|
-
},
|
|
28
|
+
}, X = {
|
|
10
29
|
class: "flex items-center gap-1",
|
|
11
30
|
role: "navigation",
|
|
12
31
|
"aria-label": "pagination"
|
|
13
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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 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:
|
|
29
|
-
const
|
|
30
|
-
() =>
|
|
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
|
-
() =>
|
|
33
|
-
),
|
|
34
|
-
if (!
|
|
35
|
-
const y =
|
|
36
|
-
let
|
|
37
|
-
for (let s = 1; s <=
|
|
38
|
-
(s === 1 || 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
|
-
|
|
41
|
-
return
|
|
42
|
-
}),
|
|
43
|
-
typeof y == "number" &&
|
|
44
|
-
},
|
|
45
|
-
l.value &&
|
|
46
|
-
},
|
|
47
|
-
m.value &&
|
|
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 &&
|
|
50
|
-
},
|
|
51
|
-
m.value &&
|
|
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,
|
|
54
|
-
e.pagination && e.pagination.meta.last_page > 1 ? (
|
|
55
|
-
|
|
56
|
-
|
|
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:
|
|
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:
|
|
81
|
+
onClick: x
|
|
63
82
|
}, [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
], 10,
|
|
67
|
-
|
|
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:
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
], 10,
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
o !== "..." ? (
|
|
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:
|
|
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: (
|
|
87
|
-
},
|
|
105
|
+
onClick: (p) => $(o)
|
|
106
|
+
}, d(o), 11, te)) : (t(), n("span", ae, " ... "))
|
|
88
107
|
], 64))), 128))
|
|
89
108
|
]),
|
|
90
|
-
|
|
109
|
+
a("button", {
|
|
91
110
|
disabled: !m.value,
|
|
92
|
-
class:
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
], 10,
|
|
101
|
-
|
|
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:
|
|
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:
|
|
126
|
+
onClick: T
|
|
108
127
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
], 10,
|
|
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
132
|
])) : f("", !0),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
e.pagination && e.pagination.meta.total > 0 ? (
|
|
117
|
-
|
|
118
|
-
], 64)) : (
|
|
119
|
-
|
|
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 ? (
|
|
123
|
-
|
|
124
|
-
|
|
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:
|
|
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
|
-
(
|
|
148
|
+
(t(!0), n(h, null, S(e.perPageOptions, (o) => (t(), n("option", {
|
|
130
149
|
key: o,
|
|
131
150
|
value: o
|
|
132
|
-
},
|
|
133
|
-
], 40,
|
|
151
|
+
}, d(o), 9, ie))), 128))
|
|
152
|
+
], 40, le)
|
|
134
153
|
])) : f("", !0),
|
|
135
|
-
e.pagination ? (
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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-
|
|
154
|
-
},
|
|
172
|
+
class: "rounded-lg border bg-background dark:border-gray-700"
|
|
173
|
+
}, Te = {
|
|
155
174
|
key: 0,
|
|
156
175
|
class: "relative"
|
|
157
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
164
|
-
key: 0,
|
|
165
|
-
class: "flex flex-col"
|
|
166
|
-
}, Le = { class: "[&_tr:last-child]:border-0" }, Me = { key: 1 }, Oe = ["colspan"], _e = /* @__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 U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
|
|
|
189
205
|
emptyStateText: { default: "📭 No items found" }
|
|
190
206
|
},
|
|
191
207
|
emits: ["pageChange", "perPageChange", "searchChange", "sortChange", "retry", "update:rowSelection"],
|
|
192
|
-
setup(e, { expose:
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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:
|
|
224
|
+
getCoreRowModel: z(),
|
|
205
225
|
enableSorting: !0,
|
|
206
226
|
manualSorting: !0,
|
|
207
227
|
enableRowSelection: l.enableRowSelection,
|
|
@@ -211,180 +231,182 @@ const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
|
|
|
211
231
|
},
|
|
212
232
|
onRowSelectionChange: (o) => {
|
|
213
233
|
const r = typeof o == "function" ? o(l.rowSelection || {}) : o;
|
|
214
|
-
|
|
234
|
+
c("update:rowSelection", r);
|
|
215
235
|
},
|
|
216
236
|
enableMultiRowSelection: !0,
|
|
217
237
|
enableSubRowSelection: !1
|
|
218
|
-
}),
|
|
238
|
+
}), T = () => k.value, j = () => $.value, D = () => c("update:rowSelection", {}), y = () => {
|
|
219
239
|
const o = { ...l.rowSelection };
|
|
220
|
-
|
|
240
|
+
x.getRowModel().rows.forEach((r) => {
|
|
221
241
|
o[r.id] = !0;
|
|
222
|
-
}),
|
|
223
|
-
},
|
|
242
|
+
}), c("update:rowSelection", o);
|
|
243
|
+
}, g = () => {
|
|
224
244
|
const o = { ...l.rowSelection };
|
|
225
|
-
|
|
245
|
+
x.getRowModel().rows.forEach((r) => {
|
|
226
246
|
delete o[r.id];
|
|
227
|
-
}),
|
|
247
|
+
}), c("update:rowSelection", o);
|
|
228
248
|
};
|
|
229
|
-
return
|
|
230
|
-
getSelectedRowIds:
|
|
249
|
+
return R({
|
|
250
|
+
getSelectedRowIds: T,
|
|
231
251
|
getSelectedRowData: j,
|
|
232
|
-
clearSelection:
|
|
252
|
+
clearSelection: D,
|
|
233
253
|
selectAllCurrentPage: y,
|
|
234
|
-
deselectAllCurrentPage:
|
|
254
|
+
deselectAllCurrentPage: g,
|
|
235
255
|
selectedRowCount: m,
|
|
236
|
-
selectedRowIds:
|
|
237
|
-
selectedRowData:
|
|
238
|
-
table:
|
|
256
|
+
selectedRowIds: k,
|
|
257
|
+
selectedRowData: $,
|
|
258
|
+
table: x
|
|
239
259
|
}), (o, r) => {
|
|
240
|
-
var
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
e.showSearch ? (
|
|
245
|
-
|
|
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", {
|
|
246
266
|
value: e.search,
|
|
247
267
|
type: "search",
|
|
248
268
|
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) =>
|
|
251
|
-
}, null, 40,
|
|
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)
|
|
252
272
|
])) : f("", !0),
|
|
253
|
-
|
|
254
|
-
|
|
273
|
+
a("div", ye, [
|
|
274
|
+
B(o.$slots, "filters")
|
|
255
275
|
])
|
|
256
276
|
]),
|
|
257
|
-
|
|
258
|
-
|
|
277
|
+
a("div", he, [
|
|
278
|
+
B(o.$slots, "header")
|
|
259
279
|
])
|
|
260
280
|
]),
|
|
261
|
-
e.enableRowSelection && m.value > 0 ? (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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)
|
|
265
285
|
]),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
selectedIds:
|
|
269
|
-
selectedData:
|
|
286
|
+
a("div", we, [
|
|
287
|
+
B(o.$slots, "bulk-actions", {
|
|
288
|
+
selectedIds: k.value,
|
|
289
|
+
selectedData: $.value,
|
|
270
290
|
selectedCount: m.value,
|
|
271
|
-
clearSelection:
|
|
291
|
+
clearSelection: D,
|
|
272
292
|
selectAllCurrentPage: y,
|
|
273
|
-
deselectAllCurrentPage:
|
|
293
|
+
deselectAllCurrentPage: g
|
|
274
294
|
}),
|
|
275
|
-
o.$slots["bulk-actions"] ? f("", !0) : (
|
|
295
|
+
o.$slots["bulk-actions"] ? f("", !0) : (t(), n("button", {
|
|
276
296
|
key: 0,
|
|
277
|
-
onClick:
|
|
297
|
+
onClick: D,
|
|
278
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"
|
|
279
299
|
}, " Clear Selection "))
|
|
280
300
|
])
|
|
281
301
|
])) : f("", !0),
|
|
282
|
-
e.isLoading && !e.data ? (
|
|
283
|
-
r[4] || (r[4] =
|
|
284
|
-
|
|
285
|
-
])) : e.error ? (
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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", {
|
|
289
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",
|
|
290
|
-
onClick: r[1] || (r[1] = (s) =>
|
|
310
|
+
onClick: r[1] || (r[1] = (s) => c("retry"))
|
|
291
311
|
}, " 🔄 Retry ")
|
|
292
|
-
])) : (
|
|
293
|
-
e.isLoading ? (
|
|
294
|
-
|
|
295
|
-
|
|
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" })
|
|
296
316
|
], -1)
|
|
297
317
|
])])) : f("", !0),
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
e.showCaption ? (
|
|
301
|
-
|
|
302
|
-
e.enableRowSelection && m.value > 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)
|
|
303
323
|
])) : f("", !0),
|
|
304
|
-
|
|
305
|
-
(
|
|
324
|
+
a("thead", Me, [
|
|
325
|
+
(t(!0), n(h, null, S(b(x).getHeaderGroups(), (s) => (t(), n("tr", {
|
|
306
326
|
key: s.id,
|
|
307
|
-
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"
|
|
308
328
|
}, [
|
|
309
|
-
(
|
|
329
|
+
(t(!0), n(h, null, S(s.headers, (u) => (t(), n("th", {
|
|
310
330
|
key: u.id,
|
|
311
331
|
colspan: u.colSpan,
|
|
312
|
-
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"
|
|
313
333
|
}, [
|
|
314
|
-
u.isPlaceholder ? f("", !0) : (
|
|
334
|
+
u.isPlaceholder ? f("", !0) : (t(), n("div", {
|
|
315
335
|
key: 0,
|
|
316
|
-
class:
|
|
336
|
+
class: w([
|
|
317
337
|
"flex items-center gap-2",
|
|
318
338
|
u.column.getCanSort() ? "cursor-pointer select-none hover:bg-gray-50 dark:hover:bg-gray-800 p-2 rounded transition-colors" : ""
|
|
319
339
|
]),
|
|
320
|
-
onClick: (
|
|
340
|
+
onClick: (Ae) => u.column.getCanSort() ? c("sortChange", u.column.id) : void 0
|
|
321
341
|
}, [
|
|
322
|
-
|
|
342
|
+
C(b(M), {
|
|
323
343
|
render: u.column.columnDef.header,
|
|
324
344
|
props: u.getContext()
|
|
325
345
|
}, null, 8, ["render", "props"]),
|
|
326
|
-
u.column.getCanSort() ? (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
class:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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)
|
|
339
360
|
])) : f("", !0)
|
|
340
|
-
], 10,
|
|
341
|
-
], 8,
|
|
361
|
+
], 10, Ee))
|
|
362
|
+
], 8, Ie))), 128))
|
|
342
363
|
]))), 128))
|
|
343
364
|
]),
|
|
344
|
-
|
|
345
|
-
b(
|
|
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", {
|
|
346
367
|
key: s.id,
|
|
347
|
-
class:
|
|
348
|
-
"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",
|
|
349
370
|
e.enableRowSelection && s.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
|
|
350
371
|
])
|
|
351
372
|
}, [
|
|
352
|
-
(
|
|
373
|
+
(t(!0), n(h, null, S(s.getVisibleCells(), (u) => (t(), n("td", {
|
|
353
374
|
key: u.id,
|
|
354
375
|
class: "p-4 align-middle [&:has([role=checkbox])]:pr-0"
|
|
355
376
|
}, [
|
|
356
|
-
|
|
377
|
+
C(b(M), {
|
|
357
378
|
render: u.column.columnDef.cell,
|
|
358
379
|
props: u.getContext()
|
|
359
380
|
}, null, 8, ["render", "props"])
|
|
360
381
|
]))), 128))
|
|
361
|
-
], 2))), 128)) : (
|
|
362
|
-
|
|
382
|
+
], 2))), 128)) : (t(), n("tr", ze, [
|
|
383
|
+
a("td", {
|
|
363
384
|
colspan: e.columns.length,
|
|
364
|
-
class: "h-24 text-center"
|
|
365
|
-
},
|
|
385
|
+
class: "h-24 text-center dark:text-gray-400"
|
|
386
|
+
}, d(e.emptyStateText), 9, Fe)
|
|
366
387
|
]))
|
|
367
388
|
])
|
|
368
389
|
])
|
|
369
390
|
]),
|
|
370
|
-
|
|
391
|
+
C(ce, {
|
|
371
392
|
pagination: e.pagination,
|
|
372
393
|
"current-per-page": e.currentPerPage,
|
|
373
394
|
"per-page-options": e.perPageOptions,
|
|
374
395
|
"show-per-page-selector": e.showPerPageSelector,
|
|
375
|
-
onPageChange: r[2] || (r[2] = (s) =>
|
|
376
|
-
onPerPageChange: r[3] || (r[3] = (s) =>
|
|
396
|
+
onPageChange: r[2] || (r[2] = (s) => c("pageChange", s)),
|
|
397
|
+
onPerPageChange: r[3] || (r[3] = (s) => c("perPageChange", s))
|
|
377
398
|
}, null, 8, ["pagination", "current-per-page", "per-page-options", "show-per-page-selector"])
|
|
378
399
|
]))
|
|
379
400
|
]);
|
|
380
401
|
};
|
|
381
402
|
}
|
|
382
403
|
});
|
|
383
|
-
function
|
|
384
|
-
return
|
|
404
|
+
function Je(...e) {
|
|
405
|
+
return q(W(e));
|
|
385
406
|
}
|
|
386
407
|
export {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
408
|
+
qe as DataTable,
|
|
409
|
+
ce as DataTablePagination,
|
|
410
|
+
Je as cn,
|
|
411
|
+
We as useDarkMode
|
|
390
412
|
};
|
package/package.json
CHANGED