mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-01 23:29:30 +08:00
8501b708ea
* 📦 samller bundlesize limit * 🗑️ remove React static PropTypes * 🗑️ remove react-lifecycles-compat * 🗑️ remove matchMedia polyfill * 🗑️ remove Transfer buggy lazy prop * 🗑️ remove enquire.js dep * 🗑️ remove Transfer lazy related code and fix ci * 🗑️ remove used dom-closest * ⚡ replace dom-scroll-into-view to scroll-into-view for bundle size * ✅ fix eslint * 🆙 upgrade browserslist * ✅ fix test cases * 🗑️ remove @ant-design/create-react-context * 🆙 upgrade @ant-design/bisheng-plugin * 🆙 upgrade rc-slider * ✅ fix ci * 🆙 upgrade rc-tabs and rc-mentions * 📦 scroll-into-view -> scroll-into-view-if-needed * remove unused devDep * docs: 📝 update instruction about IE9/10 * 📦 reduce css bundle size by drop IE9/10 support * 🆙 upgrade rc-upload * 🗑️ drop unused swing motion css * ✅ update upload snapshots * 📦 lift css bundlesize limit to 55kb
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import * as React from 'react';
|
|
import { Omit, tuple } from '../_util/type';
|
|
import { TransferItem } from '.';
|
|
import { TransferListProps, RenderedItem } from './list';
|
|
import ListItem from './ListItem';
|
|
|
|
export const OmitProps = tuple('handleFilter', 'handleClear', 'checkedKeys');
|
|
export type OmitProp = typeof OmitProps[number];
|
|
type PartialTransferListProps = Omit<TransferListProps, OmitProp>;
|
|
|
|
export interface TransferListBodyProps extends PartialTransferListProps {
|
|
filteredItems: TransferItem[];
|
|
filteredRenderItems: RenderedItem[];
|
|
selectedKeys: string[];
|
|
}
|
|
|
|
class ListBody extends React.Component<TransferListBodyProps> {
|
|
onItemSelect = (item: TransferItem) => {
|
|
const { onItemSelect, selectedKeys } = this.props;
|
|
const checked = selectedKeys.indexOf(item.key) >= 0;
|
|
onItemSelect(item.key, !checked);
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
prefixCls,
|
|
onScroll,
|
|
filteredRenderItems,
|
|
selectedKeys,
|
|
disabled: globalDisabled,
|
|
} = this.props;
|
|
|
|
return (
|
|
<ul className={`${prefixCls}-content`} onScroll={onScroll}>
|
|
{filteredRenderItems.map(({ renderedEl, renderedText, item }: RenderedItem) => {
|
|
const { disabled } = item;
|
|
const checked = selectedKeys.indexOf(item.key) >= 0;
|
|
|
|
return (
|
|
<ListItem
|
|
disabled={globalDisabled || disabled}
|
|
key={item.key}
|
|
item={item}
|
|
renderedText={renderedText}
|
|
renderedEl={renderedEl}
|
|
checked={checked}
|
|
prefixCls={prefixCls}
|
|
onClick={this.onItemSelect}
|
|
/>
|
|
);
|
|
})}
|
|
</ul>
|
|
);
|
|
}
|
|
}
|
|
|
|
const ListBodyWrapper = (props: TransferListBodyProps) => <ListBody {...props} />;
|
|
|
|
export default ListBodyWrapper;
|