import{defineComponent as Q,shallowRef as U,computed as l,watchEffect as W,createVNode as i,Fragment as E}from"vue";import I from"../../_util/classNames.mjs";import X from"../Cell/index.mjs";import{useInjectBody as Y}from"../context/BodyContext.mjs";import{useInjectTable as Z}from"../context/TableContext.mjs";import{getColumnsKey as _}from"../utils/valueUtil.mjs";import ee from"./ExpandedRow.mjs";const re=Q({name:"BodyRow",inheritAttrs:!1,props:["record","index","renderIndex","recordKey","expandedKeys","rowComponent","cellComponent","customRow","rowExpandable","indent","rowKey","getRowKey","childrenColumnName"],setup(e,{attrs:h}){const K=Z(),d=Y(),p=U(!1),m=l(()=>e.expandedKeys&&e.expandedKeys.has(e.recordKey));W(()=>{m.value&&(p.value=!0)});const f=l(()=>d.expandableType==="row"&&(!e.rowExpandable||e.rowExpandable(e.record))),C=l(()=>d.expandableType==="nest"),$=l(()=>e.childrenColumnName&&e.record&&e.record[e.childrenColumnName]),T=l(()=>f.value||C.value),w=(a,s)=>{d.onTriggerExpand(a,s)},x=l(()=>e.customRow?.(e.record,e.index)||{}),k=(a,...s)=>{d.expandRowByClick&&T.value&&w(e.record,a),x.value?.onClick?.(a,...s)},B=l(()=>{const{record:a,index:s,indent:r}=e,{rowClassName:n}=d;return typeof n=="string"?n:typeof n=="function"?n(a,s,r):""}),P=l(()=>_(d.flattenColumns));return()=>{const{class:a,style:s}=h,{record:r,index:n,rowKey:S,indent:c=0,rowComponent:y,cellComponent:v}=e,{prefixCls:t,fixedInfoList:j,transformCellText:L}=K,{flattenColumns:R,expandedRowClassName:N,indentSize:z,expandIcon:A,expandedRowRender:F,expandIconColumnIndex:V}=d,q=i(y,{...x.value,"data-row-key":S,class:I(a,`${t}-row`,`${t}-row-level-${c}`,B.value,x.value.class),style:[s,x.value.style],onClick:k},{default:()=>[R.map((o,u)=>{const{customRender:D,dataIndex:G,className:H}=o,J=P[u],M=j[u];let g;o.customCell&&(g=o.customCell(r,n,o));const O=u===(V||0)&&C.value?i(E,null,[i("span",{style:{paddingLeft:`${z*c}px`},class:`${t}-row-indent indent-level-${c}`},null),A({prefixCls:t,expanded:m.value,expandable:$.value,record:r,onExpand:w})]):null;return i(X,{cellType:"body",class:H,ellipsis:o.ellipsis,align:o.align,component:v,prefixCls:t,key:J,record:r,index:n,renderIndex:e.renderIndex,dataIndex:G,customRender:D,...M,additionalProps:g,column:o,transformCellText:L,appendNode:O},null)})]});let b;if(f.value&&(p.value||m.value)){const o=F({record:r,index:n,indent:c+1,expanded:m.value}),u=N&&N(r,n,c);b=i(ee,{expanded:m.value,class:I(`${t}-expanded-row`,`${t}-expanded-row-level-${c+1}`,u),prefixCls:t,component:y,cellComponent:v,colSpan:R.length,isEmpty:!1},{default:()=>[o]})}return i(E,null,[q,b])}}});export{re as default};
