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