import{e as m,_ as A,P as F,d as _,f as D,i as H,b as t,o as s,a as l,r as g,k as d,j as V,C as M,F as k,l as f,n as b,h as p,t as x,g as K,u as z}from"./vendor-1-1-30.js";const I={key:0},U={class:"flex flex-col justify-center items-center bg-white rounded-md space-y-8 lg:px-48 px-4 lg:py-10 py-5"},q={class:"w-full bg-white divide-y divide-gray-200 dark:divide-neutral-700"},E={key:0,class:"text-xs text-gray-700 text-left bg-gray-50 dark:bg-gray-700 dark:text-gray-400"},O={key:0,class:"px-4 py-3",scope:"col"},P=["src","alt"],G={key:1},J=["colspan"],Q={class:"flex flex-col rounded items-center justify-center p-4"},R=["onMouseover","onMouseleave"],W={key:0,class:"px-4 py-3",scope:"col"},X=["value"],Y=["onClick"],Z={key:2,class:"text-xs text-gray-700 bg-white dark:bg-gray-700 dark:text-gray-400"},ee=["colspan"],ae={__name:"MdrTable",props:{headers:{type:Array,required:!0},items:{type:[Array,Object],default:()=>[]},selectable:{type:Boolean,default:!1},selectableKey:{type:String,default:"id"},noDataText:{type:String,default:"Veri bulunamadı."},showHeader:{type:Boolean,default:!0}},emits:["selected","tr-clicked","tr-mouseover","tr-mouseleave"],setup(a,{emit:T}){const y=T,i=a,w=e=>e===i.headers.length-1,B=e=>e===i.items.length-1,$=m(()=>i.selectable?i.headers.length+1:i.headers.length),C=m(()=>{var e,n;return!!((n=(e=A())==null?void 0:e.vnode.props)!=null&&n.onTrClicked)}),h=F(),u=_([]),v=_(!1),N=m(()=>!!h.footer),S=m(()=>!!h.noData);return D(v,e=>{e?u.value=i.items.map(n=>n[i.selectableKey]):u.value=[]}),D(u,e=>{y("selected",e)}),(e,n)=>{const j=H("magnifying-glass-icon");return a.items.length===0&&S.value?(s(),t("div",I,[l("div",U,[g(e.$slots,"noData")])])):(s(),t("div",{key:1,class:b(`border rounded-lg overflow-auto ${a.items.length===0?"p-1":"p-0"} dark:border-neutral-700`)},[g(e.$slots,"top"),l("table",q,[a.showHeader&&a.items.length>0?(s(),t("thead",E,[a.selectable?(s(),t("th",O,[V(l("input",{"onUpdate:modelValue":n[0]||(n[0]=o=>v.value=o),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"},null,512),[[M,v.value]])])):d("",!0),(s(!0),t(k,null,f(a.headers,(o,c)=>(s(),t("th",{key:c,scope:"col",class:b(`px-4 py-3 w-auto ${w(c)?"text-right":""} ${o.class?o.class:""} `)},[p(x(o.title)+" ",1),o.img?(s(),t("img",{key:0,src:o.img,alt:o.title,class:"size-8 rounded inline-block"},null,8,P)):d("",!0)],2))),128))])):d("",!0),a.items.length===0?(s(),t("tbody",G,[l("tr",null,[l("td",{colspan:$.value},[l("div",Q,[K(j,{class:"w-8 h-8"}),p(" "+x(a.noDataText),1)])],8,J)])])):d("",!0),l("tbody",null,[(s(!0),t(k,null,f(a.items,(o,c)=>(s(),t("tr",{key:c,class:b(`${C.value?"cursor-pointer":""} bg-white dark:bg-gray-800 ${B(c)?"":"border-b"} text-sm dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600`),onMouseover:r=>y("tr-mouseover",c),onMouseleave:r=>y("tr-mouseleave",c)},[a.selectable?(s(),t("td",W,[V(l("input",{"onUpdate:modelValue":n[1]||(n[1]=r=>u.value=r),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600",value:o[a.selectableKey]},null,8,X),[[M,u.value]])])):d("",!0),(s(!0),t(k,null,f(a.headers,(r,L)=>(s(),t("td",{key:r.key,class:b(`px-4 py-3 w-auto ${w(L)?"text-right":""} ${r.class?r.class:""} `),scope:"col",onClick:te=>C.value?y("tr-clicked",o,r):!1},[z(h)[r.key]?g(e.$slots,r.key,{key:0,item:o,index:c}):(s(),t(k,{key:1},[p(x(o[r.key]),1)],64))],10,Y))),128))],42,R))),128))]),N.value?(s(),t("tfoot",Z,[l("tr",null,[l("td",{class:"px-4 py-4",colspan:$.value},[g(e.$slots,"footer")],8,ee)])])):d("",!0)]),g(e.$slots,"bottom")],2))}}};export{ae as _};
