import{defineComponent as b,ref as L,computed as h,watch as P,createVNode as i,Fragment as x}from"vue";import F from"../_util/classNames.mjs";import{booleanType as g}from"../_util/type.mjs";import c from"../_util/vue-types/index.mjs";import B from"../pagination/index.mjs";import K from"./ListItem.mjs";const M={prefixCls:String,filteredRenderItems:c.array.def([]),selectedKeys:c.array,disabled:g(),showRemove:g(),pagination:c.any,onItemSelect:Function,onScroll:Function,onItemRemove:Function};function N(n){if(!n)return null;const l={pageSize:10,simple:!0,showSizeChanger:!1,showLessItems:!1};return typeof n=="object"?{...l,...n}:l}const O=b({compatConfig:{MODE:3},name:"ListBody",inheritAttrs:!1,props:M,emits:["itemSelect","itemRemove","scroll"],setup(n,{emit:l,expose:v}){const o=L(1),p=e=>{const{selectedKeys:s}=n,r=s.includes(e.key);l("itemSelect",e.key,!r)},y=e=>{l("itemRemove",[e.key])},S=e=>{l("scroll",e)},t=h(()=>N(n.pagination));P([t,()=>n.filteredRenderItems],()=>{if(t.value){const e=Math.ceil(n.filteredRenderItems.length/t.value.pageSize);o.value=Math.min(o.value,e)}},{immediate:!0});const m=h(()=>{const{filteredRenderItems:e}=n;let s=e;return t.value&&(s=e.slice((o.value-1)*t.value.pageSize,o.value*t.value.pageSize)),s}),I=e=>{o.value=e};return v({items:m}),()=>{const{prefixCls:e,filteredRenderItems:s,selectedKeys:r,disabled:d,showRemove:u}=n;let f=null;t.value&&(f=i(B,{simple:t.value.simple,showSizeChanger:t.value.showSizeChanger,showLessItems:t.value.showLessItems,size:"small",disabled:d,class:`${e}-pagination`,total:s.length,pageSize:t.value.pageSize,current:o.value,onChange:I},null));const R=m.value.map(({renderedEl:C,renderedText:w,item:a})=>{const{disabled:k}=a,z=r.includes(a.key);return i(K,{disabled:d||k,key:a.key,item:a,renderedText:w,renderedEl:C,checked:z,prefixCls:e,onClick:p,onRemove:y,showRemove:u},null)});return i(x,null,[i("ul",{class:F(`${e}-content`,{[`${e}-content-show-remove`]:u}),onScroll:S},[R]),f])}}});export{O as default,M as transferListBodyProps};
