import{W as p}from"./WidgetCard-CLnTgmXL.js";import{_ as b,o as v}from"./index-BxIwIJfy.js";import{b as e,k as S,l as h,d as o,c as t,F as s,C as y,G as g,t as u,q as B,f as d,a7 as A,y as C}from"./vue-core-Di3IuVqe.js";const N={class:"widget-table"},W={key:0},x={key:1,class:"widget-table__empty"},D={__name:"WidgetTable",props:{title:{type:String,required:!0},icon:{type:String,default:"pi pi-list"},columns:{type:Array,required:!0},data:{type:[Array,Object,null],default:null},loading:{type:Boolean,default:!1},error:{type:String,default:""},editing:{type:Boolean,default:!1}},emits:["refresh","remove"],setup(i){const f=i,m=C(()=>Array.isArray(f.data)?f.data:[]);function c(l){if(!l)return"";try{const n=new Date(l);return isNaN(n.getTime())?String(l):n.toLocaleDateString("fr-FR")}catch{return String(l)}}return(l,n)=>(e(),S(p,{title:i.title,icon:i.icon,loading:i.loading,error:i.error,editing:i.editing,onRefresh:n[0]||(n[0]=r=>l.$emit("refresh")),onRemove:n[1]||(n[1]=r=>l.$emit("remove"))},{default:h(()=>[o("div",N,[m.value.length>0?(e(),t("table",W,[o("thead",null,[o("tr",null,[(e(!0),t(s,null,y(i.columns,r=>(e(),t("th",{key:r.key,style:g(r.style||{})},u(r.label),5))),128))])]),o("tbody",null,[(e(!0),t(s,null,y(m.value,(r,k)=>(e(),t("tr",{key:k},[(e(!0),t(s,null,y(i.columns,a=>(e(),t("td",{key:a.key,style:g(a.style||{}),class:B(a.cellClass||"")},[a.format==="currency"?(e(),t(s,{key:0},[d(u(A(v)(r[a.key]||0)),1)],64)):a.format==="date"?(e(),t(s,{key:1},[d(u(c(r[a.key])),1)],64)):a.format==="integer"?(e(),t(s,{key:2},[d(u(Math.round(r[a.key]||0).toLocaleString("fr-FR")),1)],64)):(e(),t(s,{key:3},[d(u(r[a.key]??""),1)],64))],6))),128))]))),128))])])):(e(),t("div",x,[...n[2]||(n[2]=[o("i",{class:"pi pi-inbox"},null,-1),o("span",null,"Aucune donnée",-1)])]))])]),_:1},8,["title","icon","loading","error","editing"]))}},$=b(D,[["__scopeId","data-v-eb8fc49f"]]);export{$ as W};
