import * as React from 'react'; import Animate from 'rc-animate'; import raf from '../_util/raf'; import { Omit, tuple } from '../_util/type'; import { TransferItem } from '.'; import { TransferListProps, RenderedItem } from './list'; import ListItem from './ListItem'; export const OmitProps = tuple( 'handleFilter', 'handleSelect', 'handleSelectAll', 'handleClear', 'body', 'checkedKeys', ); export type OmitProp = (typeof OmitProps)[number]; type PartialTransferListProps = Omit; export interface TransferListBodyProps extends PartialTransferListProps { filteredItems: TransferItem[]; filteredRenderItems: RenderedItem[]; selectedKeys: string[]; } class ListBody extends React.Component { state = { mounted: false, }; private mountId: number; componentDidMount() { this.mountId = raf(() => { this.setState({ mounted: true }); }); } componentWillMount() { raf.cancel(this.mountId); } onItemSelect = (item: TransferItem) => { const { onItemSelect, selectedKeys } = this.props; const checked = selectedKeys.indexOf(item.key) >= 0; onItemSelect(item.key, !checked); }; render() { const { mounted } = this.state; const { prefixCls, onScroll, filteredRenderItems, lazy, selectedKeys } = this.props; return ( {filteredRenderItems.map(({ renderedEl, renderedText, item }: RenderedItem) => { const { disabled } = item; const checked = selectedKeys.indexOf(item.key) >= 0; return ( ); })} ); } } export default (props: TransferListBodyProps) => ;