@toniel/laravel-tanstack-datatable 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DataTable.vue.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +107 -110
- package/package.json +1 -1
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"DataTable.vue.d.ts","sourceRoot":"","sources":["../../src/components/DataTable.vue"],"names":[],"mappings":"AA4WA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAK5B,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACZ,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAG9B,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAA;IAG/B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAG7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AA8ID,iBAAS,cAAc;WA8TT,OAAO,IAA6B;;yBAZrB,GAAG;wBACJ,GAAG;;;;;;;;YACK,GAAG;;;;EAetC;AAsBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;gBAjgBN,yBAAyB,GAAG,IAAI;oBAK5B,MAAM,EAAE;oBADR,MAAM;yBAaD,OAAO;YAdpB,MAAM;UALR,GAAG,EAAE;WAsBJ,MAAM;eAnBF,OAAO;WACX,KAAK,GAAG,IAAI;YAIX,MAAM,GAAG,IAAI;mBACN,KAAK,GAAG,MAAM;kBAGf,iBAAiB;wBACX,OAAO;cACjB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;gBAGlB,OAAO;iBACN,OAAO;cAKV,MAAM;iBACH,MAAM;gBACP,MAAM;oBACF,MAAM;wFAmfvB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
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-10 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"),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;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { defineComponent as L, computed as P, createElementBlock as a, openBlock as n, createCommentVNode as
|
|
1
|
+
import { defineComponent as L, computed as P, createElementBlock as a, openBlock as n, createCommentVNode as f, createElementVNode as t, normalizeClass as x, createVNode as h, unref as b, Fragment as p, renderList as S, toDisplayString as i, createTextVNode as B, renderSlot as N } from "vue";
|
|
2
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
|
|
4
|
-
import { clsx as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
const
|
|
3
|
+
import { ChevronsLeft as V, ChevronLeft as E, ChevronRight as F, ChevronsRight as z, ChevronUp as A, ChevronDown as G } from "lucide-vue-next";
|
|
4
|
+
import { clsx as _ } from "clsx";
|
|
5
|
+
import { twMerge as H } from "tailwind-merge";
|
|
6
|
+
const U = { class: "flex flex-col gap-4 px-2 py-4" }, W = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "flex justify-center"
|
|
9
|
-
},
|
|
9
|
+
}, q = {
|
|
10
10
|
class: "flex items-center gap-1",
|
|
11
11
|
role: "navigation",
|
|
12
12
|
"aria-label": "pagination"
|
|
13
|
-
},
|
|
13
|
+
}, J = ["disabled"], K = ["disabled"], Q = { class: "flex items-center gap-1" }, X = ["onClick"], Y = {
|
|
14
14
|
key: 1,
|
|
15
15
|
class: "inline-flex items-center justify-center h-10 min-w-10 px-3 text-gray-500"
|
|
16
|
-
},
|
|
16
|
+
}, Z = ["disabled"], ee = ["disabled"], te = { class: "flex items-center justify-between text-sm text-gray-600 dark:text-gray-300" }, oe = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "flex items-center gap-2"
|
|
19
|
-
},
|
|
19
|
+
}, ae = ["value"], ne = ["value"], re = { key: 1 }, se = /* @__PURE__ */ L({
|
|
20
20
|
__name: "DataTablePagination",
|
|
21
21
|
props: {
|
|
22
22
|
pagination: { default: null },
|
|
@@ -32,15 +32,15 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
32
32
|
() => c.pagination ? c.pagination.meta.current_page < c.pagination.meta.last_page : !1
|
|
33
33
|
), C = P(() => {
|
|
34
34
|
if (!c.pagination) return [];
|
|
35
|
-
const
|
|
35
|
+
const y = c.pagination.meta.current_page, d = c.pagination.meta.last_page, o = 2, r = [], w = [];
|
|
36
36
|
let k;
|
|
37
37
|
for (let s = 1; s <= d; s++)
|
|
38
|
-
(s === 1 || s === d || s >=
|
|
38
|
+
(s === 1 || s === d || s >= y - o && s <= y + o) && r.push(s);
|
|
39
39
|
for (const s of r)
|
|
40
40
|
k && (s - k === 2 ? w.push(k + 1) : s - k !== 1 && w.push("...")), w.push(s), k = s;
|
|
41
41
|
return w;
|
|
42
|
-
}), R = (
|
|
43
|
-
typeof
|
|
42
|
+
}), R = (y) => {
|
|
43
|
+
typeof y == "number" && g("pageChange", y);
|
|
44
44
|
}, v = () => {
|
|
45
45
|
l.value && g("pageChange", 1);
|
|
46
46
|
}, D = () => {
|
|
@@ -50,68 +50,68 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
50
50
|
}, $ = () => {
|
|
51
51
|
m.value && c.pagination && g("pageChange", c.pagination.meta.current_page + 1);
|
|
52
52
|
};
|
|
53
|
-
return (
|
|
54
|
-
e.pagination && e.pagination.meta.last_page > 1 ? (n(), a("div",
|
|
55
|
-
t("nav",
|
|
53
|
+
return (y, d) => (n(), a("div", U, [
|
|
54
|
+
e.pagination && e.pagination.meta.last_page > 1 ? (n(), a("div", W, [
|
|
55
|
+
t("nav", q, [
|
|
56
56
|
t("button", {
|
|
57
57
|
disabled: !l.value,
|
|
58
|
-
class:
|
|
58
|
+
class: x([
|
|
59
59
|
"inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
|
|
60
60
|
l.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
|
|
61
61
|
]),
|
|
62
62
|
onClick: v
|
|
63
63
|
}, [
|
|
64
|
-
|
|
64
|
+
h(b(V), { class: "h-4 w-4" }),
|
|
65
65
|
d[1] || (d[1] = t("span", { class: "hidden sm:inline" }, "First", -1))
|
|
66
|
-
], 10,
|
|
66
|
+
], 10, J),
|
|
67
67
|
t("button", {
|
|
68
68
|
disabled: !l.value,
|
|
69
|
-
class:
|
|
69
|
+
class: x([
|
|
70
70
|
"inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
|
|
71
71
|
l.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
|
|
72
72
|
]),
|
|
73
73
|
onClick: j
|
|
74
74
|
}, [
|
|
75
|
-
|
|
75
|
+
h(b(E), { class: "h-4 w-4" }),
|
|
76
76
|
d[2] || (d[2] = t("span", { class: "hidden sm:inline" }, "Previous", -1))
|
|
77
|
-
], 10,
|
|
78
|
-
t("div",
|
|
77
|
+
], 10, K),
|
|
78
|
+
t("div", Q, [
|
|
79
79
|
(n(!0), a(p, null, S(C.value, (o, r) => (n(), a(p, { key: r }, [
|
|
80
80
|
o !== "..." ? (n(), a("button", {
|
|
81
81
|
key: 0,
|
|
82
|
-
class:
|
|
82
|
+
class: x([
|
|
83
83
|
"inline-flex items-center justify-center h-10 min-w-10 px-3 text-sm font-medium transition-colors rounded-md",
|
|
84
84
|
o === e.pagination.meta.current_page ? "bg-primary text-primary-foreground hover:bg-primary/90" : "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200"
|
|
85
85
|
]),
|
|
86
86
|
onClick: (w) => R(o)
|
|
87
|
-
}, i(o), 11,
|
|
87
|
+
}, i(o), 11, X)) : (n(), a("span", Y, " ... "))
|
|
88
88
|
], 64))), 128))
|
|
89
89
|
]),
|
|
90
90
|
t("button", {
|
|
91
91
|
disabled: !m.value,
|
|
92
|
-
class:
|
|
92
|
+
class: x([
|
|
93
93
|
"inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
|
|
94
94
|
m.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
|
|
95
95
|
]),
|
|
96
96
|
onClick: $
|
|
97
97
|
}, [
|
|
98
98
|
d[3] || (d[3] = t("span", { class: "hidden sm:inline" }, "Next", -1)),
|
|
99
|
-
|
|
100
|
-
], 10,
|
|
99
|
+
h(b(F), { class: "h-4 w-4" })
|
|
100
|
+
], 10, Z),
|
|
101
101
|
t("button", {
|
|
102
102
|
disabled: !m.value,
|
|
103
|
-
class:
|
|
103
|
+
class: x([
|
|
104
104
|
"inline-flex items-center justify-center gap-1 h-10 px-4 py-2 text-sm font-medium transition-colors rounded-md",
|
|
105
105
|
m.value ? "hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-200" : "opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600"
|
|
106
106
|
]),
|
|
107
107
|
onClick: D
|
|
108
108
|
}, [
|
|
109
109
|
d[4] || (d[4] = t("span", { class: "hidden sm:inline" }, "Last", -1)),
|
|
110
|
-
|
|
111
|
-
], 10,
|
|
110
|
+
h(b(z), { class: "h-4 w-4" })
|
|
111
|
+
], 10, ee)
|
|
112
112
|
])
|
|
113
|
-
])) :
|
|
114
|
-
t("div",
|
|
113
|
+
])) : f("", !0),
|
|
114
|
+
t("div", te, [
|
|
115
115
|
t("div", null, [
|
|
116
116
|
e.pagination && e.pagination.meta.total > 0 ? (n(), a(p, { key: 0 }, [
|
|
117
117
|
B(" Showing " + i(e.pagination.meta.from) + " to " + i(e.pagination.meta.to) + " of " + i(e.pagination.meta.total) + " entries ", 1)
|
|
@@ -119,7 +119,7 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
119
119
|
B(" No entries found ")
|
|
120
120
|
], 64))
|
|
121
121
|
]),
|
|
122
|
-
e.showPerPageSelector ? (n(), a("div",
|
|
122
|
+
e.showPerPageSelector ? (n(), a("div", oe, [
|
|
123
123
|
d[5] || (d[5] = t("span", null, "Rows per page:", -1)),
|
|
124
124
|
t("select", {
|
|
125
125
|
value: e.currentPerPage || e.perPageOptions[0],
|
|
@@ -129,41 +129,41 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
129
129
|
(n(!0), a(p, null, S(e.perPageOptions, (o) => (n(), a("option", {
|
|
130
130
|
key: o,
|
|
131
131
|
value: o
|
|
132
|
-
}, i(o), 9,
|
|
133
|
-
], 40,
|
|
134
|
-
])) :
|
|
135
|
-
e.pagination ? (n(), a("div",
|
|
132
|
+
}, i(o), 9, ne))), 128))
|
|
133
|
+
], 40, ae)
|
|
134
|
+
])) : f("", !0),
|
|
135
|
+
e.pagination ? (n(), a("div", re, " Page " + i(e.pagination.meta.current_page) + " of " + i(e.pagination.meta.last_page), 1)) : f("", !0)
|
|
136
136
|
])
|
|
137
137
|
]));
|
|
138
138
|
}
|
|
139
|
-
}),
|
|
139
|
+
}), le = { class: "flex flex-col gap-4" }, ie = { class: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" }, de = { class: "flex flex-col gap-2 sm:flex-row sm:items-center" }, ce = {
|
|
140
140
|
key: 0,
|
|
141
141
|
class: "relative w-full max-w-sm"
|
|
142
|
-
},
|
|
142
|
+
}, ge = ["value"], ue = { class: "flex items-center gap-2" }, me = { class: "flex items-center" }, fe = {
|
|
143
143
|
key: 0,
|
|
144
144
|
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
|
-
},
|
|
145
|
+
}, be = { class: "flex items-center gap-4" }, ye = { class: "text-sm font-medium text-blue-700 dark:text-blue-300" }, xe = { class: "text-xs text-blue-600 dark:text-blue-400" }, he = { class: "flex items-center gap-2" }, pe = {
|
|
146
146
|
key: 1,
|
|
147
147
|
class: "flex items-center justify-center p-8"
|
|
148
|
-
},
|
|
148
|
+
}, ve = { class: "text-lg text-gray-700 dark:text-gray-200" }, we = {
|
|
149
149
|
key: 2,
|
|
150
150
|
class: "flex flex-col items-center p-8"
|
|
151
|
-
},
|
|
151
|
+
}, ke = { class: "mb-2 text-lg text-red-600 dark:text-red-400" }, Ce = { class: "mb-4 text-sm text-gray-600 dark:text-gray-300" }, Se = {
|
|
152
152
|
key: 3,
|
|
153
153
|
class: "rounded-lg border bg-white dark:bg-gray-900"
|
|
154
|
-
},
|
|
154
|
+
}, Pe = {
|
|
155
155
|
key: 0,
|
|
156
156
|
class: "relative"
|
|
157
|
-
},
|
|
157
|
+
}, Re = { class: "relative w-full overflow-auto" }, $e = { class: "w-full caption-bottom text-sm" }, Te = {
|
|
158
158
|
key: 0,
|
|
159
159
|
class: "mt-4 text-sm text-muted-foreground"
|
|
160
|
-
},
|
|
160
|
+
}, De = {
|
|
161
161
|
key: 0,
|
|
162
162
|
class: "ml-2 text-blue-600 dark:text-blue-400"
|
|
163
|
-
},
|
|
163
|
+
}, je = { class: "[&_tr]:border-b" }, Ne = ["colspan"], Be = ["onClick"], Ie = {
|
|
164
164
|
key: 0,
|
|
165
165
|
class: "flex flex-col"
|
|
166
|
-
},
|
|
166
|
+
}, Le = { class: "[&_tr:last-child]:border-0" }, Me = { key: 1 }, Oe = ["colspan"], _e = /* @__PURE__ */ L({
|
|
167
167
|
__name: "DataTable",
|
|
168
168
|
props: {
|
|
169
169
|
data: { default: () => [] },
|
|
@@ -215,7 +215,7 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
215
215
|
},
|
|
216
216
|
enableMultiRowSelection: !0,
|
|
217
217
|
enableSubRowSelection: !1
|
|
218
|
-
}), D = () => C.value, j = () => R.value, $ = () => g("update:rowSelection", {}),
|
|
218
|
+
}), D = () => C.value, j = () => R.value, $ = () => g("update:rowSelection", {}), y = () => {
|
|
219
219
|
const o = { ...l.rowSelection };
|
|
220
220
|
v.getRowModel().rows.forEach((r) => {
|
|
221
221
|
o[r.id] = !0;
|
|
@@ -230,7 +230,7 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
230
230
|
getSelectedRowIds: D,
|
|
231
231
|
getSelectedRowData: j,
|
|
232
232
|
clearSelection: $,
|
|
233
|
-
selectAllCurrentPage:
|
|
233
|
+
selectAllCurrentPage: y,
|
|
234
234
|
deselectAllCurrentPage: d,
|
|
235
235
|
selectedRowCount: m,
|
|
236
236
|
selectedRowIds: C,
|
|
@@ -238,74 +238,71 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
238
238
|
table: v
|
|
239
239
|
}), (o, r) => {
|
|
240
240
|
var w, k;
|
|
241
|
-
return n(), a("div",
|
|
242
|
-
t("div",
|
|
243
|
-
t("div",
|
|
244
|
-
e.showSearch ? (n(), a("div",
|
|
245
|
-
t("div", ue, [
|
|
246
|
-
y(f(z), { class: "size-5 text-muted-foreground" })
|
|
247
|
-
]),
|
|
241
|
+
return n(), a("div", le, [
|
|
242
|
+
t("div", ie, [
|
|
243
|
+
t("div", de, [
|
|
244
|
+
e.showSearch ? (n(), a("div", ce, [
|
|
248
245
|
t("input", {
|
|
249
246
|
value: e.search,
|
|
250
|
-
type: "
|
|
247
|
+
type: "search",
|
|
251
248
|
placeholder: "Search...",
|
|
252
|
-
class: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 ps-
|
|
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",
|
|
253
250
|
onInput: r[0] || (r[0] = (s) => g("searchChange", s.target.value))
|
|
254
|
-
}, null, 40,
|
|
255
|
-
])) :
|
|
256
|
-
t("div",
|
|
251
|
+
}, null, 40, ge)
|
|
252
|
+
])) : f("", !0),
|
|
253
|
+
t("div", ue, [
|
|
257
254
|
N(o.$slots, "filters")
|
|
258
255
|
])
|
|
259
256
|
]),
|
|
260
|
-
t("div",
|
|
257
|
+
t("div", me, [
|
|
261
258
|
N(o.$slots, "header")
|
|
262
259
|
])
|
|
263
260
|
]),
|
|
264
|
-
e.enableRowSelection && m.value > 0 ? (n(), a("div",
|
|
265
|
-
t("div",
|
|
266
|
-
t("span",
|
|
267
|
-
t("div",
|
|
261
|
+
e.enableRowSelection && m.value > 0 ? (n(), a("div", fe, [
|
|
262
|
+
t("div", be, [
|
|
263
|
+
t("span", ye, i(m.value) + " " + i(e.itemName) + " selected ", 1),
|
|
264
|
+
t("div", xe, " IDs: " + i(C.value.slice(0, 5).join(", ")) + i(C.value.length > 5 ? "..." : ""), 1)
|
|
268
265
|
]),
|
|
269
|
-
t("div",
|
|
266
|
+
t("div", he, [
|
|
270
267
|
N(o.$slots, "bulk-actions", {
|
|
271
268
|
selectedIds: C.value,
|
|
272
269
|
selectedData: R.value,
|
|
273
270
|
selectedCount: m.value,
|
|
274
271
|
clearSelection: $,
|
|
275
|
-
selectAllCurrentPage:
|
|
272
|
+
selectAllCurrentPage: y,
|
|
276
273
|
deselectAllCurrentPage: d
|
|
277
274
|
}),
|
|
278
|
-
o.$slots["bulk-actions"] ?
|
|
275
|
+
o.$slots["bulk-actions"] ? f("", !0) : (n(), a("button", {
|
|
279
276
|
key: 0,
|
|
280
277
|
onClick: $,
|
|
281
278
|
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
279
|
}, " Clear Selection "))
|
|
283
280
|
])
|
|
284
|
-
])) :
|
|
285
|
-
e.isLoading && !e.data ? (n(), a("div",
|
|
281
|
+
])) : f("", !0),
|
|
282
|
+
e.isLoading && !e.data ? (n(), a("div", pe, [
|
|
286
283
|
r[4] || (r[4] = t("div", { class: "w-8 h-8 mr-3 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" }, null, -1)),
|
|
287
|
-
t("div",
|
|
288
|
-
])) : e.error ? (n(), a("div",
|
|
289
|
-
t("div",
|
|
290
|
-
t("div",
|
|
284
|
+
t("div", ve, i(e.loadingText), 1)
|
|
285
|
+
])) : e.error ? (n(), a("div", we, [
|
|
286
|
+
t("div", ke, "❌ " + i(e.errorTitle), 1),
|
|
287
|
+
t("div", Ce, i(e.error.message), 1),
|
|
291
288
|
t("button", {
|
|
292
289
|
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
290
|
onClick: r[1] || (r[1] = (s) => g("retry"))
|
|
294
291
|
}, " 🔄 Retry ")
|
|
295
|
-
])) : (n(), a("div",
|
|
296
|
-
e.isLoading ? (n(), a("div",
|
|
292
|
+
])) : (n(), a("div", Se, [
|
|
293
|
+
e.isLoading ? (n(), a("div", Pe, [...r[5] || (r[5] = [
|
|
297
294
|
t("div", { class: "absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-gray-900/70 rounded-lg" }, [
|
|
298
295
|
t("div", { class: "w-6 h-6 border-b-2 border-gray-900 dark:border-gray-100 rounded-full animate-spin" })
|
|
299
296
|
], -1)
|
|
300
|
-
])])) :
|
|
301
|
-
t("div",
|
|
302
|
-
t("table",
|
|
303
|
-
e.showCaption ? (n(), a("caption",
|
|
297
|
+
])])) : f("", !0),
|
|
298
|
+
t("div", Re, [
|
|
299
|
+
t("table", $e, [
|
|
300
|
+
e.showCaption ? (n(), a("caption", Te, [
|
|
304
301
|
B(i(e.title) + " - Total: " + i(((k = (w = e.pagination) == null ? void 0 : w.meta) == null ? void 0 : k.total) || 0) + " " + i(e.itemName) + " ", 1),
|
|
305
|
-
e.enableRowSelection && m.value > 0 ? (n(), a("span",
|
|
306
|
-
])) :
|
|
307
|
-
t("thead",
|
|
308
|
-
(n(!0), a(p, null, S(
|
|
302
|
+
e.enableRowSelection && m.value > 0 ? (n(), a("span", De, " (" + i(m.value) + " selected) ", 1)) : f("", !0)
|
|
303
|
+
])) : f("", !0),
|
|
304
|
+
t("thead", je, [
|
|
305
|
+
(n(!0), a(p, null, S(b(v).getHeaderGroups(), (s) => (n(), a("tr", {
|
|
309
306
|
key: s.id,
|
|
310
307
|
class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
|
|
311
308
|
}, [
|
|
@@ -314,40 +311,40 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
314
311
|
colspan: u.colSpan,
|
|
315
312
|
class: "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0"
|
|
316
313
|
}, [
|
|
317
|
-
u.isPlaceholder ?
|
|
314
|
+
u.isPlaceholder ? f("", !0) : (n(), a("div", {
|
|
318
315
|
key: 0,
|
|
319
|
-
class:
|
|
316
|
+
class: x([
|
|
320
317
|
"flex items-center gap-2",
|
|
321
318
|
u.column.getCanSort() ? "cursor-pointer select-none hover:bg-gray-50 dark:hover:bg-gray-800 p-2 rounded transition-colors" : ""
|
|
322
319
|
]),
|
|
323
|
-
onClick: (
|
|
320
|
+
onClick: (Ve) => u.column.getCanSort() ? g("sortChange", u.column.id) : void 0
|
|
324
321
|
}, [
|
|
325
|
-
|
|
322
|
+
h(b(I), {
|
|
326
323
|
render: u.column.columnDef.header,
|
|
327
324
|
props: u.getContext()
|
|
328
325
|
}, null, 8, ["render", "props"]),
|
|
329
|
-
u.column.getCanSort() ? (n(), a("div",
|
|
330
|
-
|
|
331
|
-
class:
|
|
326
|
+
u.column.getCanSort() ? (n(), a("div", Ie, [
|
|
327
|
+
h(b(A), {
|
|
328
|
+
class: x([
|
|
332
329
|
"w-3 h-3 transition-colors",
|
|
333
330
|
e.sortBy === u.column.id && e.sortDirection === "asc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
|
|
334
331
|
])
|
|
335
332
|
}, null, 8, ["class"]),
|
|
336
|
-
|
|
337
|
-
class:
|
|
333
|
+
h(b(G), {
|
|
334
|
+
class: x([
|
|
338
335
|
"w-3 h-3 -mt-1 transition-colors",
|
|
339
336
|
e.sortBy === u.column.id && e.sortDirection === "desc" ? "text-gray-900 dark:text-gray-100" : "text-gray-400"
|
|
340
337
|
])
|
|
341
338
|
}, null, 8, ["class"])
|
|
342
|
-
])) :
|
|
343
|
-
], 10,
|
|
344
|
-
], 8,
|
|
339
|
+
])) : f("", !0)
|
|
340
|
+
], 10, Be))
|
|
341
|
+
], 8, Ne))), 128))
|
|
345
342
|
]))), 128))
|
|
346
343
|
]),
|
|
347
|
-
t("tbody",
|
|
348
|
-
|
|
344
|
+
t("tbody", Le, [
|
|
345
|
+
b(v).getRowModel().rows.length > 0 ? (n(!0), a(p, { key: 0 }, S(b(v).getRowModel().rows, (s) => (n(), a("tr", {
|
|
349
346
|
key: s.id,
|
|
350
|
-
class:
|
|
347
|
+
class: x([
|
|
351
348
|
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
352
349
|
e.enableRowSelection && s.getIsSelected() ? "bg-blue-50 dark:bg-blue-900/20 border-l-4 border-l-blue-500" : ""
|
|
353
350
|
])
|
|
@@ -356,21 +353,21 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
356
353
|
key: u.id,
|
|
357
354
|
class: "p-4 align-middle [&:has([role=checkbox])]:pr-0"
|
|
358
355
|
}, [
|
|
359
|
-
|
|
356
|
+
h(b(I), {
|
|
360
357
|
render: u.column.columnDef.cell,
|
|
361
358
|
props: u.getContext()
|
|
362
359
|
}, null, 8, ["render", "props"])
|
|
363
360
|
]))), 128))
|
|
364
|
-
], 2))), 128)) : (n(), a("tr",
|
|
361
|
+
], 2))), 128)) : (n(), a("tr", Me, [
|
|
365
362
|
t("td", {
|
|
366
363
|
colspan: e.columns.length,
|
|
367
364
|
class: "h-24 text-center"
|
|
368
|
-
}, i(e.emptyStateText), 9,
|
|
365
|
+
}, i(e.emptyStateText), 9, Oe)
|
|
369
366
|
]))
|
|
370
367
|
])
|
|
371
368
|
])
|
|
372
369
|
]),
|
|
373
|
-
|
|
370
|
+
h(se, {
|
|
374
371
|
pagination: e.pagination,
|
|
375
372
|
"current-per-page": e.currentPerPage,
|
|
376
373
|
"per-page-options": e.perPageOptions,
|
|
@@ -383,11 +380,11 @@ const W = { class: "flex flex-col gap-4 px-2 py-4" }, q = {
|
|
|
383
380
|
};
|
|
384
381
|
}
|
|
385
382
|
});
|
|
386
|
-
function
|
|
387
|
-
return
|
|
383
|
+
function He(...e) {
|
|
384
|
+
return H(_(e));
|
|
388
385
|
}
|
|
389
386
|
export {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
_e as DataTable,
|
|
388
|
+
se as DataTablePagination,
|
|
389
|
+
He as cn
|
|
393
390
|
};
|
package/package.json
CHANGED