import{defineComponent as $,toRef as d,shallowRef as x,createVNode as o}from"vue";import{useInjectBody as H}from"../context/BodyContext.mjs";import{useProvideHover as S}from"../context/HoverContext.mjs";import{useInjectResize as D}from"../context/ResizeContext.mjs";import{useInjectTable as F}from"../context/TableContext.mjs";import M from"../hooks/useFlattenRecords.mjs";import{getColumnsKey as P}from"../utils/valueUtil.mjs";import V from"./BodyRow.mjs";import q from"./ExpandedRow.mjs";import A from"./MeasureCell.mjs";const ee=$({name:"TableBody",props:["data","getRowKey","measureColumnWidth","expandedKeys","customRow","rowExpandable","childrenColumnName"],setup(e,{slots:R}){const h=D(),b=F(),K=H(),g=M(d(e,"data"),d(e,"childrenColumnName"),d(e,"expandedKeys"),d(e,"getRowKey")),c=x(-1),u=x(-1);let i;return S({startRow:c,endRow:u,onHover:(l,t)=>{clearTimeout(i),i=setTimeout(()=>{c.value=l,u.value=t},100)}}),()=>{const{data:l,getRowKey:t,measureColumnWidth:v,expandedKeys:I,customRow:N,rowExpandable:z,childrenColumnName:E}=e,{onColumnResize:B}=h,{prefixCls:n,getComponent:m}=b,{flattenColumns:p}=K,T=m(["body","wrapper"],"tbody"),y=m(["body","row"],"tr"),C=m(["body","cell"],"td");let a;l.length?a=g.value.map((r,f)=>{const{record:w,indent:k,index:W}=r,s=t(w,f);return o(V,{key:s,rowKey:s,record:w,recordKey:s,index:f,renderIndex:W,rowComponent:y,cellComponent:C,expandedKeys:I,customRow:N,getRowKey:t,rowExpandable:z,childrenColumnName:E,indent:k},null)}):a=o(q,{expanded:!0,class:`${n}-placeholder`,prefixCls:n,component:y,cellComponent:C,colSpan:p.length,isEmpty:!0},{default:()=>[R.emptyNode?.()]});const j=P(p);return o(T,{class:`${n}-tbody`},{default:()=>[v&&o("tr",{"aria-hidden":"true",class:`${n}-measure-row`,style:{height:0,fontSize:0}},[j.map(r=>o(A,{key:r,columnKey:r,onColumnResize:B},null))]),a]})}}});export{ee as default};
